My ios app has stopped playing sound for push notification since quite long. We have azure notification hub as our backend for sending notifications.
As per our discussion with MS Azure team, they informed that in order to enable the sound, we would need to include "Sound" property as per new APIs. But using azure notification hub this API would become bad request as "Sound" property is not supported by them. There is nothing else can be performed from azure notification side and they suggested to reach out to APNS to seek any alternatives, if any.
They are still working to add support for Critical Alerts on APNS.
Is there any work around? Has anyone faced such issue? Any help would be greatly appreciaated.
Below is the code for registering for push notifications:
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound], completionHandler: {(_ granted: Bool, _ error: Error?) -> Void in
if error == nil {
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
})
To play the default system sound, create your sound object using the default method.
By default, a notification contains an alert message that is displayed to the user without playing a sound. If you want to play a sound when a notification arrives, Apple provides one “default” sound that you can specify.
{"aps":{"sound":"default"}}
References: https://developer.apple.com/documentation/usernotifications/unnotificationsound
"sound": "default"
should trigger a sound. - Alex AIT