RaviPatidar
RaviPatidar

Reputation: 1486

cordova local notification sound not working in ios and Android

I am using cordova-plugin-local-notifications plugin. Now I have issue to get my sound file in both Android and iOS.

window.plugin.notification.local.add({
    id:         '0001',   
    date:       new Date,      
    message:    'hello',
    title:      'title',  
    badge:      1,
    sound:      'www/resources/audio/beep.mp3', 
    autoCancel: true, 
    ongoing:    true 
});

What I need to do I need to change in native side my app in sencha touch.

Upvotes: 3

Views: 7145

Answers (1)

Rohit Sharma
Rohit Sharma

Reputation: 136

I think the plugin is updated and the "window.plugin.notification.local.add" method is deprecated now, now it is "window.plugin.notification.local.schedule", the "date" is now "at" and "message" is now "text".

To install plugin use below command:

cordova plugin add de.appplant.cordova.plugin.local-notification && cordova prepare

I have a plugin version installed: 0.8.1, before it is 0.7.4 at my end.

Set "sound" as like below:

sound: "file://resources/audio/beep.mp3"

so your new method will be like below:

window.plugin.notification.local.schedule({
    id:         '0001',
    at:         new Date,
    text:       'hello',
    title:      'title',
    badge:      1,
    sound:      'file://resources/audio/beep.mp3',
    autoCancel: true,
    ongoing:    true
});

It is working fine for me on iOS and Android devices. Hope it will be helpful to you :)

Upvotes: 7

Related Questions