简体   繁体   中英

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.

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM