How to add resources file to my phonegap project

我的未来我决定 提交于 2019-12-03 20:13:31

As I understand it, you should put your sound file in the res/raw folder instead of res/sounds (as you see in the plugin call : +/raw/beep).

There is no /res/sounds folder in android, datas that do not fit in other categories should be put in /res/raw. You can have a look at the sdk doc

d1jhoni1b

Yes you are right you should just create the missing var and assign your package name (the one you use when created the phonegap/cordova project with the command line something like this for example:

cordova create LocalNotification com.example.localnotification LocalNotification

Should be used in the plugin with these values:

var package_name = "com.example.localnotification";
window.plugin.notification.local.add({
        date        : Math.round(new Date().getTime()/1000 + 5),
        title       : "Android App Tes Local Notification", 
        message       : "This is a new local notification.",
        repeat        : "daily",
        sound       : 'android.resource://' + package_name + '/raw/beep',
        badge           : 0,
        id             : 666,
        foreground      : function(notificationId){
        console.log("Hello World! This alert was triggered by notification " + notificationId);
    },
    background  : function(notificationId){
        console.log("Hello World! This alert was triggered by notification " + notificationId);
    }           
});

And just in case someone is interested on creating local notifications for android this is absolutely beautiful and working just fine!

Download local notification plugin (working on Android ONLY)

Download beep.mp3

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