Problem with custom APN notification

I have set up remote notifications and it works fine. However, I have to play my own sound when I receive a notification (when the application is NOT in the foreground). I added a file called customSound.wav to my application package and made sure that โ€œadd to targetsโ€ is selected when I drag it into my project (is this the right way?). On the server side: one file name was specified as "sound": "customSound.wav". In my didReceiveRemoteNotification, I print the userInfo dictionary, and it looks like this:

aps = { alert = "Good Evening Sir"; badge = 1; "custom_filed1" = 1; "custom_field2" = "AAA-BBB-CCC"; name = "Sir Hubert"; sound = default; }; 

As you can see, the sound is still "default". I know that if the specified sound cannot be found, the default sound is played - whether the sound value in the dictionary will also be โ€œdefaultโ€ or should there be a file name specified in the json payload. The order in which they are indicated in the payload is important. I tried offers from other threads, but did not work for me. I can not show json since I do not have access to the system at the moment. Any suggestions on what I might be doing wrong?

+6
source share
1 answer

Your sound key should not have the name of the sound file that you want to play.

 { aps = { alert = "message"; sound = "sound file name.extension"; badge = 1; }; } 

for example: {aps = {alert = "message"; sound = "tone.caf"; }; }

I use this and receive a successful custom alert in my notification; keep the playing time as short as possible . I did this with this file format: aiff, caf

If you want to check the notification, then you can try this application https://itunes.apple.com/us/app/easy-apns-provider-push-notification/id989622350?mt=12

I do not label this application, but it is good for testing push notifications.

+10
source

All Articles