Post

Replies

Boosts

Views

Activity

Sing in with Apple logo alignment
My app offers login via Apple and Facebook and I would like the logos of both buttons to be aligned. By default apple's logo is centrally aligned on the leading side of the text and facebook's logo is aligned to the leading edge. It makes it look as follows: [__________X_Continue with Apple___________] [_Y__________Continue with Facebook________] (where X is the apple logo, Y is the Facebook logo and _ is whitespace). The closest hint I found on how to do that is this: Inset the logo if necessary. If you need to horizontally align the Apple logo with other authentication logos, you can adjust the space between the logo and the button’s leading edge. (source: https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple/overview/buttons/#:~:text=If%20you%20need%20to%20horizontally,8%25%20of%20the%20button's%20width.) But how do I do that? I use SwiftUI and I wrap the login with Apple button with a UIViewRepresentable. The ASAuthorizationAppleIDButton class doesn't offer logo alignment property (only ButtonType and ButtonStyle). Any advice on how to do it would be appreciated.
0
1
1.1k
Mar ’21
Showing the correct price based on user's location
Hi, I am preparing to launch an app that will use subscription model. I am a solo developer and I have recently discovered the price tiers, which sound great to me, because I will be able to pick one price tier and have Apple adjust the price and currency for different regions. My problem is, once I pick a price tier, how do I know which price and currency to display in the app. It would be ideal if I could set up the pricing in App Store Connect and then use a built-in API to fetch the pricing in the app and it would magically already display the price and currency matching the user's region. Any hints?
0
0
553
Apr ’21
SplitView navigation broken on iPad
I have two tabs in my app that contain a view with a list of items. When user taps an item, the navigation to detail view is triggered. On iPhone the list view takes the whole screen and it works just fine. However, on iPad those views are rendered in SplitView with the list of items on the left and the detail view on the right and the navigation works only for the first tap. After that, tapping any item doesn't change the detail view at all. I can see the following message in the console: Unable to present. Please file a bug. One of the views has an option to switch between SplitView and StackedView and the navigation works just fine in the StackedView on iPad. So clearly there is a problem with navigation in the SplitView. I just updated my iPad OS to 14.7 and still doesn't work, but it worked just fine on iPad OS 13 and 14... 40% of my app on iPad has become useless, because user simply cannot navigate to the simplest detail view :/ Has anyone else encountered this?
0
0
544
Jul ’21
Do I need separate SKProduct for subscription with and without trial?
Hi, I am setting up auto-renewable subscriptions for my app. I have set up 4 subscriptions for 1,3,6, and 12 months with a one week free trial. Works like a charm, everything is displayed properly on device, etc. But now I need to take into account multiple cases and one of them is when the user has already consumed the free trial, cancelled the subscription, and then is about to subscribe again. I don't want to present "1 Week Free Trial" on the payment screen and certainly I don't want the user, who has already used the trial, to be eligible to use it again. So the question is if I need 2 sets of subscriptions in total? With Trial: my_app_1_month_trial my_app_3_months_trial my_app_6_months_trial my_app_12_months_trial And without trial: my_app_1_month my_app_3_months my_app_6_months my_app_12_months And then when user has already used the free trial (this piece of information will be either fetched from my server or an apple receipt), I add use the SKProducts from the "without trial" set and the user is charged immediately.
1
0
837
Aug ’21
AVSpeechSynthesizer - how to run callback onError
I use AVSpeechSynthesizer to pronounce some text in German. Sometimes it works just fine and sometimes it doesn't for some unknown to me reason (there is no error, because the speak() method doesn't throw and the only thing I am able to observe is the following message logged in the console): _BeginSpeaking: couldn't begin playback I tried to find some API in the AVSpeechSynthesizerDelegate to register a callback when error occurs, but I have found none. The closest match was this (but it appears to be only available for macOS, not iOS): https://developer.apple.com/documentation/appkit/nsspeechsynthesizerdelegate/1448407-speechsynthesizer?changes=_10 Below you can find how I initialize and use the speech synthesizer in my app: class Speaker: NSObject, AVSpeechSynthesizerDelegate {   class func sharedInstance() -> Speaker {     struct Singleton {       static var sharedInstance = Speaker()     }     return Singleton.sharedInstance   }       let audioSession = AVAudioSession.sharedInstance()   let synth = AVSpeechSynthesizer()       override init() {     super.init()     synth.delegate = self   }       func initializeAudioSession() {     do {       try audioSession.setCategory(.playback, mode: .spokenAudio, options: .duckOthers)       try audioSession.setActive(true, options: .notifyOthersOnDeactivation)     } catch {             }   }       func speak(text: String, language: String = "de-DE") { guard !self.synth.isSpeaking else { return }     let utterance = AVSpeechUtterance(string: text)     let voice = AVSpeechSynthesisVoice.speechVoices().filter { $0.language == language }.first!           utterance.voice = voice     self.synth.speak(utterance)   } } The audio session initialization is ran during app started just once. Afterwards, speech is synthesized by running the following code: Speaker.sharedInstance.speak(text: "Lederhosen") The problem is that I have no way of knowing if the speech synthesis succeeded—the UI is showing "speaking" state, but nothing is actually being spoken.
0
0
991
Aug ’21
Limit available app languages
I have my app localized for many languages, but I'd like to limit the available app languages to only a subset of those, because the content is not ready for all of them. I don't want to delete localization files, because they contain some useful translations that I will use in the future. The only thing I was able to find and try out is this piece of code: class AppDelegate: NSObject, UIApplicationDelegate {   func application(     _ application: UIApplication,     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?   ) -> Bool {           UserDefaults.standard.set(["Base", "pl", "de", "ru"], forKey: "AppleLanguages")     UserDefaults.standard.synchronize()           ApplicationDelegate.shared.application(       application,       didFinishLaunchingWithOptions: launchOptions     )     return true   } } but unfortunately it does not work. When I launch Settings of my app, I can still choose from about 20-30 languages that I have already some translations for.
4
0
1.9k
Aug ’21
Switching language sometimes makes the app freeze
I followed the advice from one of the latest WWDC videos on how to handle localization and in my app I launch Settings of my app when the user wants to change the app language (not system language). The user can then select one of the available languages that my app is localized for. The localization part works well, but sometimes it happens that when I click the < My app button in the leading, top corner or just navigate back to my app, I encounter a frozen screen and then the app just quits and restarts after 2-3 seconds. I don't need to preserve any state when the user changes the language, but I would certainly like to prevent this freeze from happening. The desired behaviour would be that the app restarts once the use changes the app language. I use SwiftUI as the UI framework. I use the following code to open the Settings of my app for the user: UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!) How can I achieve that?
1
0
1.6k
Sep ’21
Unable to reach server on WiFi, but always able on cellular
I am slowly distributing my app to Beta testers via TestFlight. A few of them have already reported that the app showed “No Internet connection” while on WiFi. As soon as they switched to cellular everything started to work. But the WiFi worked for them for everything else. One of the testers installed the app today for the first time. Still no Internet connection after switching back to WiFi from cellular. I use Alamofire as a framework to make HTTPRequests and when these requests fail, “No Internet connection” error is displayed. My backend service is hosted on Google Cloud, my domain is registered using AWS Route 53. I use SSL certificates managed by Google. All HTTPRequests are sent to https://api.myapp.com (where myapp.com is hosted on AWS). All of the testers have Automatic DNS resolution set in Settings -&gt; WiFi -&gt; (i) -&gt; DNS So far it occurred on iPhone XR and iPhone 12. iOS versions 14.X Any ideas how I can further investigate this issue? Thanks
9
0
4.1k
Sep ’21
Unable to set applicationUsername on SKPayment
I am following "What's New in StoreKit" from WWDC17 to set up payment for subscriptions in my app and the author of the talk recommends to set applicationUsername to an opaque user ID. When I tried to set it, it turned out it is readonly. (iOS 15) Is this still a recommended practice, to set that property on SKPayment? Thanks
1
0
1.1k
Sep ’21
Detecting free trial end for auto-renewable subscriptions
I have been following these resources to set up auto-renewable subscriptions in my app written in SwiftUI: What's new in StoreKit (WWDC17) Advanced StoreKit (WWDC17) https://blckbirds.com/post/how-to-use-in-app-purchases-in-swiftui-apps/ I basically have a class that implements SKProductsRequestDelegate instantiated in SubscribeView that processes the transactions. I was able to complete the entire flow in Sandbox (got the receipt and the server notification, created a corresponding subscription entry in my database). The response coming from the verifyReceipt endpoint is quite complex and I am not sure if I understand it correctly. I am looking for an easy solution to get the latest subscription state. I don't want to focus on churn rate or anything else now. Questions: Does on-device receipt get automatically modified when the user cancels or modifies the subscriptions or when the trial period ends? If yes, can I rely on resubmitting the latest receipt from the device to my backend in order to keep track of the latest subscription state? I could resubmit the latest receipt on app startup, the server would verify and possibly update the subscription. In the Advanced StoreKit (WWDC17) talk, it is mentioned to implement SKProductsRequestDelegate as soon as possible (e.g. in the AppDelegate). Do I even need that if I already have that delegate implemented in the SubscribeView? If I understood correctly, the purpose of that would be to be notified of the transactions done after some time (subscription change, cancellation, entering grace period, etc.). I'd prefer to ignore these for now and just rely on resubmitting the latest receipt to check the current subscription.
0
0
1.2k
Sep ’21
KeyChain returns nil for a value that is set
I store the information whether the user has premium subscription in the KeyChain. I just have a global function called doesUserHavePremium that reads a value from the KeyChain. It appears that sometimes that value is read from the KeyChain incorrectly—even though I am 100% sure it is set, it returns nil. This happens only when the app was launched, then left for some time (probably screen got locked), and then I reentered the app again without relaunching it from scratch. I tried the following things: loosening the KeyChain access the the least restrictive the following piece of code to notify UI elements whenfalse/trueis read for that value after previously not being able to access it let protectedDataAvailabilityNotificationName = UIApplication.protectedDataDidBecomeAvailableNotification func observeProtectedDataAvailability() {   let selector = #selector(Self.protectedDataAvailableNotification)   switch UIApplication.shared.isProtectedDataAvailable {   case true: break   case false:     NotificationCenter.default.addObserver(self,                         selector: selector,                         name: protectedDataAvailabilityNotificationName,                         object: nil)   } } @objc func protectedDataAvailableNotification(notification: NSNotification) {   NotificationCenter.default.removeObserver(self, name: protectedDataAvailabilityNotificationName, object: nil)   dataDidBecomeAvailable() } func dataDidBecomeAvailable() {   refreshSubscriptionStatusSubscribers() } But it doesn't seem to work. The problem is that I cannot debug it, because the app has to enter background in order for this problem to manifest itself. I have read several threads related to this issue here and on GitHub and it seems like there isn't any great solution. I am looking for some workarounds. Any hints are welcome. I will try the following now: Try to store that value in UserDefaults instead—it is not really a secret like a password/token, but I need to be sure it cannot be tampered with. Not sure if UserDefaults suffer from the same problem. Try to refactor to code to wrap the doesUserHavePremium and cache its return value in a property. That seems promising, because it never happens during fresh start thus I could always set that property on the app startup.
0
1
1.6k
Oct ’21
Are Introductory Offer Dates Inclusive?
Let's say I want to create an introductory offer starting from the 1st of November till the end of the year. (it should begin at 01-11-2021 00:00:00 and expire at 31-12-2021 23:59:59) Which of the options below is correct in that case? Option 1 Start date: 1 November End Date: 31 December Option 2 Start date: 1 November End Date: 1st of January
1
0
1.2k
Nov ’21
What are the results of changing the deployment target?
Hi, I have launched an app built with SwiftUI for iOS 14+. It turned out that SwiftUI for iOS 15+ introduced some quite important changes for my app (most of all better support for NavigationLinks and managing keyboard with FocusState). From now on, I'd like to only release updates for iOS 15+, but I don't want to lose any users and any ratings/reviews on the App Store. Could someone please let me know what the exact outcomes of setting the deployment target to a newer iOS are? Is it that the users with iOS older than iOS 15, will simply not see/receive updates? Will all the ratings and reviews be intact? Thank you
0
0
900
Nov ’21
SwiftUI - geometry inconsistent on iPad simulator and real device
After running automated UI tests it turned out that my app looks quite different on iPad simulator than on real iPad. I have my iPad Pro 12,9" right next to me and the app looks completely fine, but on Simulator (same device model on Simulator) the geometry is simply wrong. I use SwiftUI's GeometryReader to properly place elements, add horizontal padding if the screen width is wide and in landscape orientation. It is not the worst case, because on real device everything looks fine, but I wanted to use screenshots generated by these tests and the ones taken on iPad Simulators are simply useless. iPhone Simulator is totally fine. Am I doing something wrong? Has anybody encountered this? I run the tests in the following way: projectName="./MyProject.xcodeproj" schemeName="MyProject" simulators=( ...    "iPhone 12 Pro Max" ...    "iPad Pro (12.9-inch) (5th generation)" ... ) languages=(   "en" ... ) appearances=(   "light"   "dark" ) xcrun simctl boot "$simulator" xcrun simctl ui "$simulator" appearance $appearance xcodebuild -testLanguage $language -scheme $schemeName -project $projectName -derivedDataPath '/tmp/MyProjectDerivedData/' -destination "platform=iOS
1
0
2.0k
Dec ’21
Provisional Notifications - no device token
I have been following the official Apple documentation on how to set up notifications in my app: https://developer.apple.com/documentation/usernotifications/asking_permission_to_use_notifications I noticed there is this option .provisional, which doesn't ask the user for authorization, but instead it is granted right away and then notifications are delivered quietly to the notification center's history. So far so good, but once I am granted authorization for sending .provisional notifications, the callback with the DeviceToken does not fire. I have this method in my AppDelegate:    func application(     _ application: UIApplication,     didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data   ) {     let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }     let token = tokenParts.joined()     ManagementService.sharedInstance().storeDeviceToken(token: token)   } And it fires when authorization for normal notifications is granted, but it doesn't for the provisional notifications. So the question is—how can I deliver the provisional notifications if I don't have the device token? My plan was to do the following: ask for authorization to send provisional notifications on first app launch and send the device token to my server ask for authorization to send normal notifications some time later (let's say after a week or after completing some action in the app) EDIT: Found the problem—I was calling the same method to register for remote notification after being granted authorization for both provisional and normal notifications:    func getNotificationSettings() {    UNUserNotificationCenter.current().getNotificationSettings { settings in      guard settings.authorizationStatus == .authorized else { return }             DispatchQueue.main.async {       UIApplication.shared.registerForRemoteNotifications()      }           }   } In this case settings.authorizationStatus == .authorized is false for provisional notifications (even though they are always authorized...). So I just omitted checking of settings.authorizationStatus for provisional notifications and the device token is there.
2
0
1.5k
Jan ’22