【问题标题】:Phonegap local notification plugin?Phonegap本地通知插件?
【发布时间】:2015-08-20 14:11:57
【问题描述】:

有人知道在 Phonegap 5.1.1 中工作的本地通知插件吗?

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

【问题讨论】:

  • 我也遇到了 cordova-plugin-local-notifications 的问题。我做了an issue at their repository。也许你和我有同样的错误。
  • 我设法让插件工作并成功收到通知。您应该再次检查上面的链接。
  • 如果上面提供的 Github 问题解决了您的问题,我会将我在 Github 上的问题中的文档移动到 StackOverflow 并给出答案。这将更好地帮助其他人,因为他们会在搜索结果中看到已回答的问题。请告诉我。
  • 没问题,SPottuit。

标签: cordova phonegap-plugins


【解决方案1】:

我也无法使用插件 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!
    

错误:

未捕获的类型错误:无法读取未定义的属性“订阅”

错误发生在:

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();
    });
});

插件已安装。在我的 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!
    

错误:

未捕获的类型错误:无法读取未定义的属性“订阅”

错误发生在:

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();
    });
});

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

cordova.js:1186 deviceready 5 秒后未触发​​。

解决方案:

选项 1 的解决方案:

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

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

选项 2 和 3 的解决方案:

未捕获的类型错误:无法读取未定义的属性“订阅”

cordova.js:1186 deviceready 5 秒后未触发​​

我设法消除了上述错误。显然我的插件:cordova-plugin-deviceorg.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(显示我尝试过的,更详细)

【讨论】:

    猜你喜欢
    • 2017-11-20
    • 2012-11-22
    • 2015-08-03
    • 1970-01-01
    • 1970-01-01
    • 2013-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多