Post

Replies

Boosts

Views

Activity

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 -> WiFi -> (i) -> 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.3k
Sep ’21
Where can I get used Offer Codes from?
I would like to programmatically keep track of offer codes that have been used. I just configured a Test Offer Code (Reference name), which contains 500 codes (Offer Codes) to buy a 1-month subscription for 0,49€. I was able to redeem the code and everything works, but I was expecting to receive the used code. Instead I received the Reference name in the payload from the App Store Server Notification in the field offer_code_ref_name="Test Offer Code". (expected was sth like offer_code_ref_name="JFFDS61SBJDBJ5BXJS4BX") I would be able to identify the Reference name by the code, if it was provided, because I have the following table in my app's backend: reference_name | code | url | expires_at | used | reserved Test Offer Code | xadz | zzz | 31-07-2022 | t | f Test Offer Code | asdf | xxx | 31-07-2022 | f | f The used code doesn't seem to be included in the latest receipt. How can I obtain it? Can I somehow call App Store Connect API? Thanks
5
0
2.7k
Apr ’24
Offer Codes cannot be redeemed
I have been using the Offer Codes that can be generated in App Store Connect (up to 25k per quarter). They had worked before, but at some point of time they just stopped working. My production device (iPhone 13 Pro) doesn't even render the redemption screen properly and says the code expired, even if it didn't. (already submitted a bug report, sadly without answer till this day: https://feedbackassistant.apple.com/feedback/12261784) Apart from that, I asked some friends to try to redeem a test offer code for me and surprisingly, the native redemption screen is rendered properly, but the code cannot be redeemed. (Clicking "Redeem" doesn't show the payment sheet) Any idea what the cause can be and how to fix it? To me it looks like it is a problem with StoreKit API, because I followed the documentation on how to use the native iOS offer code redemption sheet and I don't even receive an app store notification. Looks like there is a problem between the device and Apple's API.
5
1
2.1k
Dec ’23
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
Automatically add device frames to screenshots
I need to add frames to auto-generated screenshots for multiple devices and multiple languages so that I can display these on my app's landing page. I guess it must be quite a standard task so my question is: Is there anything that can be reused to get this job done? All screenshot file names contain: language device name generation I would prefer not to have to manually add frames to 10 screenshots * number_of_devices * number_of_languages. Right now I actually only need iPhone Pro (not Max) and iPad Pro 12.9 (newest gen), but in the future I might need it for other devices too.
4
0
8.5k
Mar ’23
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
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
852
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 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.2k
Sep ’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
2k
Dec ’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
Introductory offer - Trial + Reduced Price
Hi, I would like to create an introductory offer that includes a 1-week trial period and a reduced price for the initial period. But it seems that with the Introductory offers it is either or. Apple's documentation says that I should be using "Introductory offers to attract new customers" so I don't want to use Promotional offers for that. Also, I'd like to have the benefit of Introductory offers, which allows them to be claimed only once and not be available after that anymore. Any advice how I can implement this? Thanks
1
0
2.8k
Apr ’22
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
563
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
554
Jul ’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
1k
Aug ’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
Replies
9
Boosts
0
Views
4.3k
Activity
Sep ’21
Where can I get used Offer Codes from?
I would like to programmatically keep track of offer codes that have been used. I just configured a Test Offer Code (Reference name), which contains 500 codes (Offer Codes) to buy a 1-month subscription for 0,49€. I was able to redeem the code and everything works, but I was expecting to receive the used code. Instead I received the Reference name in the payload from the App Store Server Notification in the field offer_code_ref_name="Test Offer Code". (expected was sth like offer_code_ref_name="JFFDS61SBJDBJ5BXJS4BX") I would be able to identify the Reference name by the code, if it was provided, because I have the following table in my app's backend: reference_name | code | url | expires_at | used | reserved Test Offer Code | xadz | zzz | 31-07-2022 | t | f Test Offer Code | asdf | xxx | 31-07-2022 | f | f The used code doesn't seem to be included in the latest receipt. How can I obtain it? Can I somehow call App Store Connect API? Thanks
Replies
5
Boosts
0
Views
2.7k
Activity
Apr ’24
Offer Codes cannot be redeemed
I have been using the Offer Codes that can be generated in App Store Connect (up to 25k per quarter). They had worked before, but at some point of time they just stopped working. My production device (iPhone 13 Pro) doesn't even render the redemption screen properly and says the code expired, even if it didn't. (already submitted a bug report, sadly without answer till this day: https://feedbackassistant.apple.com/feedback/12261784) Apart from that, I asked some friends to try to redeem a test offer code for me and surprisingly, the native redemption screen is rendered properly, but the code cannot be redeemed. (Clicking "Redeem" doesn't show the payment sheet) Any idea what the cause can be and how to fix it? To me it looks like it is a problem with StoreKit API, because I followed the documentation on how to use the native iOS offer code redemption sheet and I don't even receive an app store notification. Looks like there is a problem between the device and Apple's API.
Replies
5
Boosts
1
Views
2.1k
Activity
Dec ’23
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.
Replies
4
Boosts
0
Views
1.9k
Activity
Aug ’21
Automatically add device frames to screenshots
I need to add frames to auto-generated screenshots for multiple devices and multiple languages so that I can display these on my app's landing page. I guess it must be quite a standard task so my question is: Is there anything that can be reused to get this job done? All screenshot file names contain: language device name generation I would prefer not to have to manually add frames to 10 screenshots * number_of_devices * number_of_languages. Right now I actually only need iPhone Pro (not Max) and iPad Pro 12.9 (newest gen), but in the future I might need it for other devices too.
Replies
4
Boosts
0
Views
8.5k
Activity
Mar ’23
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.
Replies
2
Boosts
0
Views
1.5k
Activity
Jan ’22
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.
Replies
1
Boosts
0
Views
852
Activity
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?
Replies
1
Boosts
0
Views
1.6k
Activity
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
Replies
1
Boosts
0
Views
1.2k
Activity
Sep ’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
Replies
1
Boosts
0
Views
2k
Activity
Dec ’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
Replies
1
Boosts
0
Views
1.2k
Activity
Nov ’21
Introductory offer - Trial + Reduced Price
Hi, I would like to create an introductory offer that includes a 1-week trial period and a reduced price for the initial period. But it seems that with the Introductory offers it is either or. Apple's documentation says that I should be using "Introductory offers to attract new customers" so I don't want to use Promotional offers for that. Also, I'd like to have the benefit of Introductory offers, which allows them to be claimed only once and not be available after that anymore. Any advice how I can implement this? Thanks
Replies
1
Boosts
0
Views
2.8k
Activity
Apr ’22
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?
Replies
0
Boosts
0
Views
563
Activity
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?
Replies
0
Boosts
0
Views
554
Activity
Jul ’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.
Replies
0
Boosts
0
Views
1k
Activity
Aug ’21