Reputation: 4138
Using Backendless for Push Notifications, and my devices successfully receive them. But when I try to set the "ios-sound" parameter of the message to an mp3 I added to my project, it does not play any sound:
Here in the Backendless docs it says that setting "ios-sound" does the following:
Sets either a URL for the sound notification to play on the device or an array of bytes for the sound to play.
I can't figure out what I'm doing wrong. Hmm...
Upvotes: 1
Views: 2455
Reputation: 4138
The problem was resolved by calling registerUserNotificationSettings in addition to registerForRemoteNotifications() which I was already doing.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
backendless.initApp(APP_ID, secret:SECRET_KEY, version:VERSION_NUM)
//NEEDED TO DO THE FOLLOWING TWO LINES
let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(settings)
UIApplication.sharedApplication().registerForRemoteNotifications()
return true
}
The reason I was not calling this before was because the Backendless Docs said that simply calling .registerForRemoteNotifications() covers alerts, badges, and sounds. However this seems to be incorrect.
Upvotes: 2
Reputation: 46
if you are recieving notification successfully on ur device , then there might be chances that your audio file is large
Custom sounds must be under 30 seconds when played. If a custom sound is over that limit, the default system sound is played instead.,so make sure that your custom sound is less than 30 sec.
Your audio data must be in an aiff, wav, or caf file.
the file name on server and your file in bundle should be of same name . and just convert your mp3 into one of the given format then only sound bud play when app is in inactive state.
Upvotes: 2