2
votes

Does anyone know any plugin for local notifications that work in Phonegap 5.1.1 ?

I tried this (https://github.com/katzer/cordova-plugin-local-notifications) , but whether I can compile the application.

1
I am having problems with the cordova-plugin-local-notifications too. I made an issue at their repository. Maybe you have the same error(s) as me.Sjoerd Pottuit
I managed to get the plugin working and successfully received a notification. You should check the link above again.Sjoerd Pottuit
If the provided issue from Github above solved your problem I will move the documentation which I put in the issue on Github to StackOverflow and make an answer of it. This will help other people even better since they will see an answered question in their search results. Just let me know.Sjoerd Pottuit
No problem, SPottuit.Caio Ladislau

1 Answers

2
votes

I could't use the plugin cordova-plugin-local-notifications too. I had errors when trying to install the plugin or when I opened my app. I used the installation page of the plugins wiki and tried all the given options to install the plugin. After trying each option I removed all created files by the command.

Option 1:

Command:

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

Output:

Fetching plugin "https://github.com/katzer/cordova-plugin-local-notifications" via git clone
Repository "https://github.com/katzer/cordova-plugin-local-notifications" checked out to git ref "master".
Installing "de.appplant.cordova.plugin.local-notification" for android
Fetching plugin "cordova-plugin-device" via npm
cordova-plugin-device" will not install due to "C:\Users\Username\Documents\Node\app\plugins\org.apache.cordova.device" being installed.
Dependent plugin "org.apache.cordova.device" already installed on android.
Failed to install 'de.appplant.cordova.plugin.local-notification':CordovaError: Cannot find plugin.xml for plugin 'cordova-plugin-app-event'. Please try adding it again.
    at new PluginInfo (C:\Program Files\nodejs\node_modules\cordova\node_modules\cordova-lib\node_modules\cordova-common\src\PluginInfo\PluginInfo.js:338:15)
    at PluginInfoProvider.get (C:\Program Files\nodejs\node_modules\cordova\node_modules\cordova-lib\node_modules\cordova-common\src\PluginInfo\PluginInfoProvider.js:35:32)
    at runInstall (C:\Program Files\nodejs\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:284:43)
    at installDependency (C:\Program Files\nodejs\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:566:16)
    at C:\Program Files\nodejs\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:449:32
    at _fulfilled (C:\Program Files\nodejs\node_modules\cordova\node_modules\q\q.js:787:54)
    at self.promiseDispatch.done (C:\Program Files\nodejs\node_modules\cordova\node_modules\q\q.js:816:30)
    at Promise.promise.promiseDispatch (C:\Program Files\nodejs\node_modules\cordova\node_modules\q\q.js:749:13)
    at C:\Program Files\nodejs\node_modules\cordova\node_modules\q\q.js:810:14
    at flush (C:\Program Files\nodejs\node_modules\cordova\node_modules\q\q.js:108:17)

Error:

Error: Cannot find plugin.xml for plugin 'cordova-plugin-app-event'. Please try adding it again.

Option 2:

Command:

cordova plugin add [email protected]

Output:

Fetching plugin "[email protected]" via npm
Fetching plugin "[email protected]" via cordova plugins registry
Installing "de.appplant.cordova.plugin.local-notification" for android
Notice: org.apache.cordova.device has been automatically converted to cordova-plugin-device and fetched from npm. This is due to our old plugins registry shutting down.
Fetching plugin "cordova-plugin-device" via npm
cordova-plugin-device" will not install due to "C:\Users\Username\Documents\Node\app\plugins\org.apache.cordova.device" being installed.
Dependent plugin "org.apache.cordova.device" already installed on android.

        Your support is needed. If you use the plugin please support us in order to ensure further development.
        https://github.com/katzer/cordova-plugin-local-notifications/tree/example#how-can-i-support-the-further-development

        Thank you!
    
Installing "de.appplant.cordova.plugin.local-notification" for ios
Notice: org.apache.cordova.device has been automatically converted to cordova-plugin-device and fetched from npm. This is due to our old plugins registry shutting down.
Fetching plugin "cordova-plugin-device" via npm
cordova-plugin-device" will not install due to "C:\Users\Username\Documents\Node\app\plugins\org.apache.cordova.device" being installed.
Dependent plugin "org.apache.cordova.device" already installed on ios.

        Your support is needed. If you use the plugin please support us in order to ensure further development.
        https://github.com/katzer/cordova-plugin-local-notifications/tree/example#how-can-i-support-the-further-development

        Thank you!
    

Error:

Uncaught TypeError: Cannot read property 'subscribe' of undefined

The error occurs on:

file:///android_asset/www/plugins/de.appplant.cordova.plugin.local-notification/www/local-notification.js:751

// Called before 'deviceready' event
channel.onCordovaReady.subscribe(function () {
    // Device plugin is ready now
    channel.onCordovaInfoReady.subscribe(function () { //this is line 751
        // Merge platform specifics into defaults
        exports.applyPlatformSpecificOptions();
    });
});

The plugin was installed. I had the error above in the console when opening the apk on my android device. I also saw this after the error:

cordova.js:1186 deviceready has not fired after 5 seconds.

Option 3:

Command:

cordova plugin add https://github.com/katzer/cordova-plugin-local-notifications#0.8.1

Output:

Fetching plugin "https://github.com/katzer/cordova-plugin-local-notifications" via git clone
Repository "https://github.com/katzer/cordova-plugin-local-notifications" checked out to git ref "0.8.1".
Installing "de.appplant.cordova.plugin.local-notification" for android
Notice: org.apache.cordova.device has been automatically converted to cordova-plugin-device and fetched from npm. This is due to our old plugins registry shutting down.
Fetching plugin "cordova-plugin-device" via npm
cordova-plugin-device" will not install due to "C:\Users\Username\Documents\Node\app\plugins\org.apache.cordova.device" being installed.
Dependent plugin "org.apache.cordova.device" already installed on android.

        Your support is needed. If you use the plugin please support us in order to ensure further development.
        https://github.com/katzer/cordova-plugin-local-notifications/tree/example#how-can-i-support-the-further-development

        Thank you!
    
Installing "de.appplant.cordova.plugin.local-notification" for ios
Notice: org.apache.cordova.device has been automatically converted to cordova-plugin-device and fetched from npm. This is due to our old plugins registry shutting down.
Fetching plugin "cordova-plugin-device" via npm
cordova-plugin-device" will not install due to "C:\Users\Username\Documents\Node\app\plugins\org.apache.cordova.device" being installed.
Dependent plugin "org.apache.cordova.device" already installed on ios.

        Your support is needed. If you use the plugin please support us in order to ensure further development.
        https://github.com/katzer/cordova-plugin-local-notifications/tree/example#how-can-i-support-the-further-development

        Thank you!
    

Error:

Uncaught TypeError: Cannot read property 'subscribe' of undefined

The error occurs on:

file:///android_asset/www/plugins/de.appplant.cordova.plugin.local-notification/www/local-notification.js:751

// Called before 'deviceready' event
channel.onCordovaReady.subscribe(function () {
    // Device plugin is ready now
    channel.onCordovaInfoReady.subscribe(function () { //this is line 751
        // Merge platform specifics into defaults
        exports.applyPlatformSpecificOptions();
    });
});

The plugin was installed. I had the error above in the console when opening the apk on my android device. I also saw this after the error:

cordova.js:1186 deviceready has not fired after 5 seconds.

Solutions:

Solution for option 1:

Error: Cannot find plugin.xml for plugin 'cordova-plugin-app-event'. Please try adding it again.

I managed to solve the error above. What I did wrong was reinstalling the plugin: cordova-plugin-local-notifications, but I actually had to reinstall the plugin: cordova-plugin-app-event.

Solution for option 2 & 3:

Uncaught TypeError: Cannot read property 'subscribe' of undefined

cordova.js:1186 deviceready has not fired after 5 seconds

I managed to remove the errors above. Apparantly my plugin: cordova-plugin-device or org.apache.cordova.device wasn't installed properly. I had both installed for some reason so I removed both plugins from the following locations:

  • the /plugins folder
  • /plugins/android.json
  • /plugins/fetch.json
  • ios.json

I only need one of the plugins (cordova-plugin-device). The other plugin(org.apache.cordova.device) is from the outdated plugin repository if I am correct. I also noticed there was no device plugin in here: \platforms\android\platform_www\plugins (also not in ios platform_www). I noticed this because I wanted to remove the plugins from the platforms as well.

I installed the plugin cordova-plugin-device again, but I got the following error:

Error: Uh oh! "C:\Users\Username\Documents\Node\app\platforms\android\src\org\apache\cordova\device\Device.java" already exists!

So I removed the folder device and installed the plugin cordova-plugin-device again. Tested my app on a device and the errors were gone.

GitHub issue (shows what I have tried and is more detailed)