phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

Android >=8 play custom sound #2717

Open appzer opened 5 years ago

appzer commented 5 years ago

i have only a question about custom sounds in push notifications

Android <=7 works when i set the sound name

Android >=8 do not work. I only get it to work, when i create channels with defined sounds. Is this the only way to use custom sounds in Android 8 and higher???

Kevin

T3chTobi commented 5 years ago

I have the same problem, any news?

appzer commented 5 years ago

I think it a android restriction! Custom sounds you only can set up with notifications channels. For each sound i created a notification channel > it works.

puntiwari commented 5 years ago

var push = PushNotification.init({ android: { senderID: "", sound: true, vibrate: true, clearNotifications: true, // clear notifications from shade on app start forceShow: true // }, ios: {}, windows: {} });

    PushNotification.createChannel(() => {},() => {},
    {
    id: '',
    description: 'Custom Sound',
    importance: 5,
    vibration: true,
    sound: 'ring_and' //The file is in res/raw 
    });

This code is not working in latest android phone.

SharUpOff commented 4 years ago

This is not a plugin issue, just Android API changes. See https://developer.android.com/training/notify-user/channels and use Notification Channel API like @puntiwari wrote above.