Search code examples
azurepush-notificationwindows-phone-8.1azure-mobile-serviceswns

App-specific Notification Sound, Badge and Toast (WNS)


Want I remember to have heard was that with WNS, you can specify a special sound for the notification you send, as is done for Android.

I have looked on different sites msdn, urban and microsoft examples, only reference I have found regarding toast sounds does not seem to specify it.

Am I missing something ? Is it not possible for WNS?

Further is it possible to send a badge message together with toast and sound? Or what are the limits, cannot seem to find it in the above links.

I would like a link or a XML example I can try on my server. Thanks!


Solution

  • First, to specify a custom toast notification sound via WNS you need to create the payload with the audio tag for example:

    <toast launch=\"$param\">
       <audio src=\"ms-appx:///Assets/Sounds/sound.wav\"/>
       <visual>
           <binding template=\"ToastText04\">
               <text id=\"1\">$title</text>
               <text id=\"2\">$msg</text>
           </binding>
       </visual>
    </toast>
    

    Note the path to the audio file. For the sound to play, you need to have the audio file (which can be mp3 too i think) prepackaged with your app. In this case the audio file is in the Assets/Sounds folder in your project. If the specified path does not exist, the default notification sound will play.

    For the badge notifications, sound is not supported. You must send a seperate notification with the badge schema.