cordova local notification sound not working in ios and Android

こ雲淡風輕ζ 提交于 2020-01-01 06:30:29

问题


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.


回答1:


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 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.add({
    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 :)



来源:https://stackoverflow.com/questions/31341856/cordova-local-notification-sound-not-working-in-ios-and-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!