I'm trying to get the LocalNotification plugin working (for either ios or android), but am having trouble finding the right documentation. Does anyone know what I'm doing wrong or what I need to add? I'm trying the following:

Added the plugin using the following from the command line

phonegap local plugin add https://github.com/katzer/cordova-plugin-local-notifications.git

Tried both of the following in the config.xml:

<plugin name="LocalNotification" value="LocalNotification" />

and

<feature name="LocalNotification">
    <param name="ios-package" value="LocalNotification"/>
</feature>

Added local-notification.js to the www folder and included it in the index.html file with the following:

<script src="local-notification.js"></script>

And have the following to use the plugin in the controller (I'm using Angular):

$scope.localNotify = function(){
        var d = new Date();
        d = d.getTime() + 5*1000; //60 seconds from now
        d = new Date(d);
        window.plugins.localNotification.add({
            date: d,
            repeat:'daily',
            message: 'This just fired after a minute!',
            hasAction: true,
            badge: 1,
            id: '1',
            sound:'horn.caf',
            background:'app.background',
            foreground:'app.running'
        });
    };

I see in the readme here https://github.com/simplec-dev/LocalNotification/blob/45867c94ee96aaa90966d22b62acabfc03807cb3/README.md they say to modify CDVPlugin.m and CDVPlugin.h, but I don't see these files anywhere in my project.

Any help would be appreciated, thanks!

有帮助吗?

解决方案

Got it working! I'm not sure if it's because the version I was using was meant for an earlier version of PhoneGap, but I found this repo https://github.com/hiattp/Phonegap-LocalNotification, followed the directions there, and now it's working. Didn't need to make any edits to config.xml, add a localnotification.js file, or make any changes to index.html. Just followed the directions at that link and it works!

其他提示

You need to install Cordova device plugin:

phonegap local plugin add org.apache.cordova.device

For the record (cause I was stuck here). You were building a PhoneGap iOS project not a Cordova iOS project and then using a Cordova (only) project. To build in PhoneGap:
phonegap build ios

To build in Cordova: cordova platform add ios

The PhoneGap plugin you referenced: https://github.com/hiattp/Phonegap-LocalNotification

Is the most uptodate so use that!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top