Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play custom sound file when user get push notification? [duplicate]

I have a sound file in the app bundle, i want to play that sound file when user will get push notification.

IS it possible in iOS if yes, then please suggest the way to achieve this.

Thanks,

like image 935
Parveen Tyagi Avatar asked Jan 17 '14 06:01

Parveen Tyagi


People also ask

Can push notifications have sound?

On Android devices, it is possible to choose individual push notification sounds.


1 Answers

To play this sound you must specify the filename of the sound in the notification payload. For example, lets say you've added a sound file named example.caf into your application, we can play this sound with the notification payload as below:

{
    aps =     
    {
        alert = "test example notification message";
        sound = "example.caf";
    };
}

Then the custom sound will play when your notification arrives.

like image 107
Bhavin_m Avatar answered Sep 28 '22 18:09

Bhavin_m