[英]Cordova notification plugin failed installation (Cordova 3.6)
I've updated a project from Cordova 3.4 to 3.6.3 and everything has fallen apart (as usual). 我已经从Cordova 3.4到3.6.3更新了一个项目,一切都已经崩溃了(像往常一样)。
But specifically, here, the org.apache.cordova.dialogs
plugin is not working in runtime on ios. 但具体来说,这里的
org.apache.cordova.dialogs
插件在运行时不能在ios上运行。
Cordova says the plugin is installed: Cordova表示插件已安装:
$ cordova plugins ls
org.apache.cordova.dialogs 0.2.9 "Notification"
org.apache.cordova.vibration 0.3.10 "Vibration"
In config.xml (the one outside of the platforms directory) I have added: 在config.xml(平台目录之外的那个)中,我添加了:
<feature name="Notification">
<param name="ios-package" value="CDVNotification" />
</feature>
When, in JavaScript, I try to create an alert like this (and yes device is ready): 在JavaScript中,我尝试创建这样的警报(并且设备已准备就绪):
navigator.notification.alert("Test alert", null);
I get this error thrown in the XCode debugger (I added line breaks for legibility) 我在XCode调试器中抛出了这个错误(为了清晰起见我添加了换行符)
2014-09-18 15:03:26.327 Milk[3045:60b]
CDVPlugin class CDVNotification (pluginName: Notification) does not exist.
2014-09-18 15:03:26.328 Milk[3045:60b]
ERROR: Plugin 'Notification' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2014-09-18 15:03:26.329 Milk[3045:60b]
-[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
"INVALID",
"Notification",
"alert",
[
"Test alert",
"Alert",
"OK"
]
]
I have tried cordova plugin rm
/ cordova plugin add
and also running cordova platform rm
to add and remove ios. 我已经尝试过
cordova plugin rm
/ cordova plugin add
并运行cordova platform rm
来添加和删除ios。
So: "CDVPlugin class CDVNotification (pluginName: Notification) does not exist."? 所以:“CDVPlugin类CDVNotification(pluginName:Notification)不存在。”?
Cordova says it's installed, how can I solve this? 科尔多瓦说已安装,我该如何解决?
Here is what I did in order to fix this issue. 以下是我为解决此问题所做的工作。
In Xcode, you have to add the plugin sources in the build phases. 在Xcode中,您必须在构建阶段添加插件源。
You can give it a try easily by updating via sudo npm update -g cordova
and reverting with your commands if it does not work. 您可以通过
sudo npm update -g cordova
更新并轻松尝试,如果它不起作用则还原您的命令。 Let me know. 让我知道。
Also if you have still some errors after that, make sure you included all the frameworks required: 此外,如果之后仍有一些错误,请确保包含所需的所有框架:
In the same tab (Build phases), you have Link Binary With Libraries (xx items) 在相同的选项卡(构建阶段)中,您有链接二进制文件库(xx项目)
for the contact plugin you need: 对于您需要的联系插件:
AddressBook.framework
AddressBookUI.framework
for the camera plugin you need: 对于您需要的相机插件:
OpenAL.framewrok
ImageIO.framework
for the notification plugin you need: 对于您需要的通知插件:
AudioToolBox.framewrok
for the device plugin you need: 对于您需要的设备插件:
AssetsLibrary.framework
Cheers 干杯
@icl1c Your answer didn't quite work for me, got another error after adding CDVNotification.m to the build phase. @ icl1c您的回答对我来说不太有用,在将CDVNotification.m添加到构建阶段后又出现了另一个错误。
What I had to do was to add the dependent framework: AudioToolbox.framework as well to make it work. 我必须做的是添加依赖框架:AudioToolbox.framework以使其工作。
I globally downgraded to Cordova 3.5 and now it seems OK. 我全球降级到Cordova 3.5,现在看来还行。
sudo npm uninstall cordova -g
sudo npm install -g cordova@3.5.0-0.2.7
@jBoive answer plus adding below code in config.xml, fixed my issue: @jBoive回答加上在config.xml中添加以下代码,解决了我的问题:
<feature name="Notification">
<param name="ios-package" value="CDVNotification" />
</feature>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.