Posts

Post not yet marked as solved
0 Replies
141 Views
I'm presenting a view controller inside a UIAction handler from the new UIButton init configuration API. But when I do it, its deinit won't get called. I'm thinking there's some sort of retain cycle? I've tried capturing [weak self] inside the closure with no success. Using the addTarget method instead, the deinit gets called as expected. What am I doing wrong? let testVC = TestViewController() lazy var testButton: UIButton = { var configuration = UIButton.Configuration.filled() //button.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside) let button = UIButton(configuration: configuration, primaryAction: UIAction(handler: { action in self.present(testVC, animated: true, completion: nil) })) return button }()
Posted
by Nasonov.
Last updated
.
Post not yet marked as solved
0 Replies
515 Views
I have an iOS app with a companion watchOS app. On the main app I set up an auto renewing subscription. By purchasing it you unlock the Apple Watch app. If you are not subscribed, a paywall view is shown in the watch app. If you are, you get to see the whole app. The thing is when a user completes the purchase on the main app, the watchOS view won't update. The Watch Connectivity framework is set up just fine and I get to communicate successfully to/from both devices. But to reflect the new state change, from the purchase made on the phone, I need to close the watch app and open it again. In doing so, the home page opens up and the users will finally get to navigate the app. Is there a way so that upon receiving the message from the Connectivity framework, I get to refresh/reload the view so that the user doesn't have to close the app and open it again? The pseudocode would be: I receive the object from the main app I check that the user has successfully purchased the subscription I reload the app/reload the view so that the user after tapping the app on the watch gets to see the home page with no extra steps. Thank you!
Posted
by Nasonov.
Last updated
.
Post marked as solved
2 Replies
622 Views
I was experimenting with NSSpellChecker on a macOS app with Swift and I noticed that when there are no spelling mistakes it returns an out of bounds range, specifically one with a lowerBound equals to the max value of a 64-bit signed integer. Am I doing something wrong or is it a bug on Apple's part? let sentence = "What a beautiful world." let range = NSSpellChecker.shared.checkSpelling(of: sentence, startingAt: 0) // "What a beautiful world." range: {9223372036854775807, 0} // "What a beautiful worldk." range: {17, 6}
Posted
by Nasonov.
Last updated
.
Post marked as solved
1 Replies
8.9k Views
Hi! I created a branch to add push notifications to my iOS app but when I try distributing it with Xcode I get several errors: Profile doesn't support Push Notifications Profile doesn't include the aps-environment entitlement No profiles for 'com.[...].notificationService' were found. Xcode couldn't find any iOS App Store provisioning profiles matching 'com.[...].notificationService' But everything is set up just right! I've never had these kind of issues. I used Firebase to add Push Notifications, following every step to include them (adding capabilities etc). The app works just fine along with notifications and the notifications service extension. Also my certificates are up to date. (Both the Apple Development and Apple Distribution one) I tried deleting all the provisioning profiles here: Library/MobileDevice/Provisioning Profiles and then downloading them manually but nothing. Also, in the main branch I noticed the project relies on the provisioning profiles found in the folder above. If I delete them I can't distribute the main branch either with a similar error. And I can't seem to generate them again. What am I doing wrong and what am I missing?
Posted
by Nasonov.
Last updated
.
Post not yet marked as solved
0 Replies
647 Views
Hi! I'm using Firebase to handle push notifications. For each notification received, I create a NotificationItem struct which gets saved to the cache (the app's document folder) in an array of NotificationItems. I also send images through Firebase's Notification Composer and in App Delegate I retrieve them by accessing the attachment like this: if let attachmentURL = notification.request.content.attachments.first.url The url retrieved is like this: file:///var/mobile/Library/UserNotifications/6FA[...]B84E9F7/Attachments/527[...]fc.jpeg Finally, in the table view controller with the list of all the notification items, I'm trying to set the UIImageView's image like this: if let imageURL = notificationItem.attachmentURL { cell.imageView?.image = UIImage(contentsOfFile: imageURL.path) } But when I run it, it's blank and no image gets loaded. My question is: how should I load the file into an UIImage? If I'm not mistaken the act of downloading the image is all handled by Firebase, by using a notification service extension and by populating the notification content with this line of code: FIRMessagingExtensionHelper().populateNotificationContent(bestAttemptContent, withContentHandler: contentHandler). So I'm left with the act of loading the image file into an UIImage.
Posted
by Nasonov.
Last updated
.
Post not yet marked as solved
0 Replies
782 Views
Hi! How can I make it so users can unlock the watchOS app by purchasing a subscription on the parent iOS app? Everything is set up correctly StoreKit wise, I'm a bit confused as to what I should do to hide the watchOS app if a user is not subscribed. Any insight on this? It's my first time setting up an Apple Watch app. Thank you
Posted
by Nasonov.
Last updated
.
Post not yet marked as solved
1 Replies
999 Views
Hi! I was trying to develop a workout app on the Apple Watch by following the sample code Apple provides here - https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/speedysloth_creating_a_workout. I originally planned to use a standard Foundation Timer object to keep track of time: timer = Timer.scheduledTimer( timeInterval: 1, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true ) but in the sample code they make use of Combine and of a Timer Publisher: start = Date() cancellable = Timer.publish(every: 1, on: .main, in: .default) &#9;&#9;.autoconnect() &#9;&#9;.sink { [weak self] _ in guard let self = self else { return } } It seems to be working both way but there's a problem on pausing the workout. If I use a Foundation Timer and I pause the session it crashes on session.pause with multiple errors of this type: Unable to transition to the desired state from the Paused(4) state (event 3). Allowed transitions from the current state are: {   7 = "<error(7): Paused(4) -> Ended(3)>";   6 = "<end(6): Paused(4) -> Ended(3)>";   5 = "<stop(5): Paused(4) -> Stopped(6)>";   4 = "<resume(4): Paused(4) -> Running(2)>"; } On the other hand, if I use a Timer Publisher like in the sample code given above, everything works just fine. I'm not familiar with Combine so I'm wondering why it's behaving like that. There's no apparent link between the timer object and the session object. Thank you.
Posted
by Nasonov.
Last updated
.
Post marked as solved
5 Replies
5.4k Views
Hi! We don't collect any data from the users nor we do any kind of tracking but we've added AdMob and a simple banner in our app. Should we answer yes to the first question asking whether we collect any data or not? If so, what data types should we include for AdMob?
Posted
by Nasonov.
Last updated
.
Post not yet marked as solved
0 Replies
491 Views
Hi! Would it be fine, per apple's guidelines, if I show a view controller (upon launch) inviting users to download the new updated app which is going to substitute the one they are currently using? Sadly, I couldn't just update the old app. I had to develop a brand new project.
Posted
by Nasonov.
Last updated
.
Post marked as solved
1 Replies
1.3k Views
Hi! I'm looping over an array of strings and I need to make a URLRequest call on each element (id). For each JSON there could be a href linking to other pages with additional data in it. How can I chain multiple URLRequests? Currently, in parse(data: data), I check to see if the href key is not null and then I call retrievePages(with url: URL) which is similar to retrieveRelease(). It gets messy. Duplicate code. I get somehow the results I want but I don't think it's the best approach at all. How could I get the next page of results? Considering that I'm also inside a loop in retrieveRelease() func retrieveRelease() { dataTask?.cancel() for id in idArray {     idUrl = URL(string: "url+id")! let request = NSMutableURLRequest(url: idUrl)    let session = URLSession.shared dataTask = session.dataTask(with: request as URLRequest) { data, response, error in if let error = error as NSError? {           return } else if let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 { if let data = data { self.parse(data: data) DispatchQueue.main.async {         //update views }             return       } } } dataTask?.resume() } } }
Posted
by Nasonov.
Last updated
.
Post not yet marked as solved
2 Replies
2.8k Views
This is what I did: Set AVAudioSession to active and its category to .playback on app launch Registered to observe notifications of type interruptionNotification Added Background Modes in the project settings under Signing &amp; Capabilities When I get an interruption I check under case .ended: if the music was playing before the interruption. If so, I resume the playback, something like this (correct me if I'm wrong): if options.contains(.shouldResume) { if musicWasPlaying { audioPlayer.play() } } This seems to be working fine when the app is in foreground. But, when it's in background and I get an interruption, the audio doesn't resume and I get this error: [aurioc] 1540: AUIOClient_StartIO failed (560557684) error 2 Error Domain=NSOSStatusErrorDomain Code=560557684 "(null)" Is there a way to resume the audio in this specific state?
Posted
by Nasonov.
Last updated
.
Post not yet marked as solved
2 Replies
1.2k Views
Hi,I'm trying to make use of the Google Sheets API using Swift. By looking at the documentation I only see a reference to a client library for Objective-C to setup iOS projects only.Do you know if there's somenthing more recent? Which supports swift and possibily macOS apps too?Thank you
Posted
by Nasonov.
Last updated
.
Post not yet marked as solved
1 Replies
768 Views
Hi everyone,I've created a new version of an app which is currently live on the app store. I get the error mentioned in the title whenever I try to save some edits done on the iOS APP version info page, on the App Store Connect.(Check means: form completed within the character limits)What's New in This Version: CheckApp Previews and Screenshots: loaded 4 screenshots for every size requiredPromotional Text: CheckDescription: CheckKeywords: CheckSupport and Marketing URL: CheckBuild: LoadedVersion and Age Rating: CheckCopyright: CheckContact Information under App Review Information: CheckVersion Release: CheckPhased Release for Automatic Updates: CheckReset iOS Summary Rating: CheckApp Information and Pricing: Check (I've correctly set a title, a privacy policy URL, both a primary and secondary category, and a price tier)I then click on Save but nothing. A red warning appears saying: "There are one or more errors on the page". No visual clue or textual representation of where the errors might be.I've also created another app for testing purposes, not meant to be published on the app store.The info I've added on both of them is identical, but on the official app I get the error. Whereas on the test app, with the same screenshots and textfields I can save with no issues.What am I doing wrong?
Posted
by Nasonov.
Last updated
.