Phonegap本地通知插件?

时间:2015-08-20 14:11:58

标签: cordova phonegap-plugins

有没有人知道任何适用于Phonegap 5.1.1的本地通知插件?

我试过这个(https://github.com/katzer/cordova-plugin-local-notifications),但是我是否可以编译应用程序。

1 个答案:

答案 0 :(得分:2)

我也无法使用插件cordova-plugin-local-notifications。我在尝试安装插件或打开应用程序时遇到错误。我使用the installation page of the plugins wiki并尝试了所有给定的选项来安装插件。在尝试每个选项后,我通过命令删除了所有创建的文件。

选项1:

<强>命令:

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

<强>输出:

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)

错误:

  

错误:找不到插件'cordova-plugin-app-event'的plugin.xml。请尝试重新添加。

选项2:

<强>命令:

cordova plugin add de.appplant.cordova.plugin.local-notification@0.8.1

<强>输出:

Fetching plugin "de.appplant.cordova.plugin.local-notification@0.8.1" via npm
Fetching plugin "de.appplant.cordova.plugin.local-notification@0.8.1" 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!

错误:

  

未捕获的TypeError:无法读取未定义的属性“subscribe”

错误发生在:

文件:///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();
    });
});

插件已安装。在我的Android设备上打开apk时,我在控制台中出现了上述错误。错误之后我也看到了这个:

  

cordova.js:1186 deviceready在5秒后没有发射。

选项3:

<强>命令:

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

<强>输出:

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!

错误:

  

未捕获的TypeError:无法读取未定义的属性“subscribe”

错误发生在:

文件:///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();
    });
});

插件已安装。在我的Android设备上打开apk时,我在控制台中出现了上述错误。错误之后我也看到了这个:

  

cordova.js:1186 deviceready在5秒后没有发射。

解决方案:

选项1的解决方案:

  

错误:找不到插件'cordova-plugin-app-event'的plugin.xml。请尝试重新添加。

我设法解决了上面的错误。我错误的是重新安装插件: cordova-plugin-local-notifications ,但实际上我不得不重新安装插件: cordova-plugin-app-event

选项2&amp;的解决方案3:

  

未捕获的TypeError:无法读取未定义的属性“subscribe”

     

cordova.js:1186 deviceready在5秒后没有被解雇

我设法删除了上述错误。显然我的插件: cordova-plugin-device org.apache.cordova.device 未正确安装。我出于某种原因安装了两个插件,因此我从以下位置删除了两个插件:

  • / plugins文件夹
  • /plugins/android.json
  • /plugins/fetch.json
  • ios.json

我只需要其中一个插件( cordova-plugin-device )。如果我是正确的,另一个插件( org.apache.cordova.device )来自过时的插件存储库。我还注意到这里没有设备插件: \ platforms \ android \ platform_www \ plugins (也不在ios platform_www中)。我注意到了这一点,因为我也希望从平台上删除插件。

我再次安装了插件 cordova-plugin-device ,但我收到以下错误:

  

错误:哦哦! “C:\ Users \ Username \ Documents \ Node \ app \ platforms \ android \ src \ org \ apache \ cordova \ device \ Device.java”已经存在!

所以我删除了文件夹设备并再次安装了插件 cordova-plugin-device 。在设备上测试了我的应用程序,错误消失了。

GitHub issue(显示我尝试过并且更详细)