Cordova notification plugin failed installation (C

2019-04-14 06:13发布

I've updated a project from Cordova 3.4 to 3.6.3 and everything has fallen apart (as usual).

But specifically, here, the org.apache.cordova.dialogs plugin is not working in runtime on ios.

Cordova says the plugin is installed:

$ 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:

<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):

navigator.notification.alert("Test alert", null);

I get this error thrown in the XCode debugger (I added line breaks for legibility)

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.

So: "CDVPlugin class CDVNotification (pluginName: Notification) does not exist."?

Cordova says it's installed, how can I solve this?

4条回答
做个烂人
2楼-- · 2019-04-14 06:24

Here is what I did in order to fix this issue.

In Xcode, you have to add the plugin sources in the build phases.

  1. select your project
  2. select the target of your project
  3. click on the build phases tab
  4. add the missing *.m files
  5. compile

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. 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)

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

xcode configuration

查看更多
倾城 Initia
3楼-- · 2019-04-14 06:32

I globally downgraded to Cordova 3.5 and now it seems OK.

sudo npm uninstall cordova -g
sudo npm install -g cordova@3.5.0-0.2.7
查看更多
老娘就宠你
4楼-- · 2019-04-14 06:37

@icl1c Your answer didn't quite work for me, got another error after adding CDVNotification.m to the build phase.

What I had to do was to add the dependent framework: AudioToolbox.framework as well to make it work.

enter image description here

查看更多
做个烂人
5楼-- · 2019-04-14 06:44

@jBoive answer plus adding below code in config.xml, fixed my issue:

<feature name="Notification">
    <param name="ios-package" value="CDVNotification" />
</feature>
查看更多
登录 后发表回答