Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

APN custom notification sound issue

I have remote notifications setup and working fine. I however have to play a custom sound when a notification is received (when app is NOT in foreground). I have added a file called customSound.wav to my app bundle and made sure "add to targets" is selected when i drag and drop it into my project (is this the correct way?). Server-side: the same file name has been specified as "sound": "customSound.wav". In my didReceiveRemoteNotification i am printing the userInfo dictionary and it is coming up 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, sound is still "default". I am aware of the fact that if the sound specified can not be found, the default sound is played- will the sound value in the dictionary also be "default" or it should be the file name that was specified in payload json. Is the order in which these are specified in the payload important. I have tried suggestions from other threads but not working for me. I can not show the json as I do not have access to the system at the moment. Any suggestions as to what I may be doing wrong ?

like image 917
pnizzle Avatar asked Nov 12 '12 10:11

pnizzle


People also ask

Why is my custom notification Sound not working?

Try these steps: Go to Settings > Sound & Notification > App Notifications. Select the app, and make sure that Notifications are turned on and set to Normal. Make sure that Do Not Disturb is turned off.

How does APN push notification work?

Once you've completed setting up push notifications on your providers and in your app, your providers can send notification requests to APNs. APNs then delivers the notification to each targeted device. Once APNs receives a notification, the system delivers the notification to the appropriate app on the device.

How do I get custom notification sounds on my iPhone?

With your iPhone connected to your PC, drag and drop your notification sound to your iPhone on the sidebar of the Music App. Grab your iPhone, tap Settings, Sounds & Haptics, and select an alert to change. Scroll down to Ringtones and choose your custom notification sound. You're all set for future alerts!


1 Answers

No your sound key should have the sound file name you want to play.

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

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

I am using this and getting successful custom alert on my notification; keep sound duration as small as possible. I did with this file format: aiff, caf

if u want to test notification then u can try this app https://itunes.apple.com/us/app/easy-apns-provider-push-notification/id989622350?mt=12

I am not doing any marking of this app but it is good for testing push notification

like image 168
spider1983 Avatar answered Oct 20 '22 12:10

spider1983