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.
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
**.
- for custom sound file must exist in
xcode
project in resources. - make sure sound file duration no longer 30 seconds. otherwise play default sound.
- and must add below key
uilocalnotificationdefaultsoundname
inside.plist
file. see below image:
Comments
Post a Comment