I’m using a home made PHP script to send my iPhone app push notifications. The payload looks a little like this.
$body['aps'] = array( 'alert' => $message, 'sound' => 'default', 'badge' => $badge, 'content-available' => '1' );
This works fine as long as you’re happy with the default tone. But what I need is the ability for a push notification to wake someone up from a deep deep sleep.
A little digging and I found out that I can create a custom notification sound and have that played when I receive a push notification. I’ve found that i can create a 30 second sound clip and save it as an .m4a file and add it to my xcode project. Now all I need to do is change the code to the following and I can get the notification to play whatever sound I like.
$body['aps'] = array( 'alert' => $message, 'sound' => $sound, 'badge' => $badge, 'content-available' => '1' );
I’ve parameterised the $sound variable so that my apps can decide what notification sound is played.
Now I can have the default tone for any non critical notifications that don’t need to wake up people and switch to a full-on 30 second get you out of bed, scare the bejesus out of you notification sound.
Now all I need to do is update my C# apps to start passing a sound variable to my PHP script.
Life is good when you code.