objective c - iOS Unable to play custom sound for remote notifications -


i have been trying implement custom sound notifications on ios.

according apple's documentation in example 3 here. need ensure push notification payload should like:

{ "aps" : {         "alert" : "you got emails.",         "badge" : 9,         "sound" : "bingbong.aiff"     } } 

and bingbong.aiff has placed in application bundle.

also if app in active state advised add following code:

- (void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo {     if (application.applicationstate == uiapplicationstateactive)     {         nsstring *path = [[nsbundle mainbundle] pathforresource:@"bingbong" oftype:@"aiff"];         theaudio = [[avaudioplayer alloc] initwithcontentsofurl:[nsurl fileurlwithpath:path]error:null];          theaudio.delegate = self;         [theaudio play];     } } 

"bingbong.aiff" placed in "supportingfiles"

i still donot custom sound remote notification.

i have gone through other questions similar these not different doing.

  1. how play custom sound file when user push notification?

  2. custom sounds in remote notifications ios 10, swift 3

  3. change push notification sound

for default sound:

according apple documentation & guidelines play default sound must have send "default" value in sound file. other wise not play default sound either.

for custom sound:

you need pass custom sound file name in place of default inside php script**.

  1. for custom sound file must exist in xcode project in resources.
  2. make sure sound file duration no longer 30 seconds. otherwise play default sound.
  3. and must add below key uilocalnotificationdefaultsoundname inside .plist file. see below image:

enter image description here


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -