Domanda

I use HTML5 and PhoneGap,

On application I have Local Notification.

Below is the code:

Local Notification

The Android implementation for local notification uses a similar interface as the existing iOS localnotification plugin. The plugin depends on the Android AlarmManager in combination with the Notification Bar.

Here my js:

function appReady() {
    alert('Start appReady');
    var LN = cordova.require("cordova/plugin/LocalNotification");
    alert('LN');
    LN.add({
        date: new Date(2012, 10, 11, 15, 20, 0, 0),
        message: "DeviceReady",
        ticker: "This is a sample ticker text",
        repeatDaily: false,
        id: 1
    });
    alert('End appReady');
}

the alert 'LN' does not appear.

here my plugin in config.xml file:

<cordova>
    <access origin="http://127.0.0.1*"/> <!-- allow local pages -->
    <access origin=".*"/>

    <log level="DEBUG"/>
    <preference name="useBrowserHistory" value="true" />
    <preference name="exit-on-suspend" value="false" />

    <plugins>
       ...
      <plugin name="LocalNotification" value="org.apache.cordova.plugins.LocalNotification"/>
    </plugins>
</cordova>

It looks like the JS does not know the plugin, can anyone help?

È stato utile?

Soluzione

You should be using navigator.notification.alert

This can be found in the docs

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top