I know there are many topics handle this problem. But so far I was not able to understand why my own plugins are not getting called.
First of all:
I use phonegap 3.6.3, XCode 6.1, iOS 8.1 Beta
I am upgrading phonegap 2.9.0 to 3.6.3 with CLI. In 2.9.0 my Plugin 'Notification' worked just fine.
I read about upgrading from 2.x to 3.x and did all the stuff mentioned.
I added core plugins with CLI which (almost) all are working.
I read about adding plugins with CLI, but I don't have a git source, and I just want to put this plugin into xCode so that I can call it from js as CDVPlugin just as before in 2.9.0
My config.xml (in myApp/ folder) looks like:
<?xml version='1.0' encoding='utf-8'?>
<widget id="ch.itis.share" version="2.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>MyApp</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev#cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<feature name="com.popup.test.plugins.Notification" required="true">
<param name="ios-package" value="Notification" />
</feature>
</widget
I have my Notification.h and Notifiaction.m class files inside myApp/Plugins folder and added them to the Build Phase in XCode.
I executed the command 'cordova prepare' to update the staging folder.
The staging config.xml has never the defined obove included!
When I call the plugin from js like:
Cordova.exec(
function(result){//do something},
function(error){//do something},
"com.popup.test.plugins.Notification",
"initDeviceNotification",
[]);
All I get from Phonegap is:
Plugin 'com.popup.test.plugins.Notification' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
I have many plugins like that. And nothing works anymore. Can anybody help?
UPDATE:
If I add the section manually to the staging config.xml it works. So how can I accomplish that the CLI prepare command will include my feature?
Related
Since I do not have Mac and iPhone, the only option for me is to use Ionic Cloud to build my native binaries. However, first I wanted to play with it and see how will it work with android builds.
My application uses https://github.com/fechanique/cordova-plugin-fcm
So I can build application with ionic cordova build android and run it on my emulator without any problems. However if I execute ionic package build android and then ionic package info I get message that my build FAILED.
Examine this failure with ionic package BUILD_ID I get this message:
Error: cordova-plugin-fcm: You have installed platform android but file 'google-services.json' was not found in your Cordova project root folder.
So, looks like that my google-services.json does not get uploaded to the cloud. So searching I find few posts of people that had same problem but none of them provided me with solution. I also found this:
https://cordova.apache.org/docs/en/latest/config_ref/index.html#resource-file
So I have tried to tell to ionic to include this google-services.json file with package like this:
<?xml version='1.0' encoding='utf-8'?>
<widget id="me.citybeep.partnerapp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<!-- ... -->
<platform name="android">
<!-- ... -->
<resource-file src="google-services.json" target="platforms/android/google-services.json" />
</platform>
<!-- ... -->
<engine name="android" spec="^6.2.3" />
<plugin name="cordova-plugin-device" spec="^1.1.4" />
<plugin name="cordova-plugin-fcm" spec="^2.1.2" />
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
<plugin name="cordova-plugin-statusbar" spec="^2.2.2" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
<plugin name="cordova-sqlite-storage" spec="^2.0.4" />
<plugin name="de.appplant.cordova.plugin.local-notification" spec="^0.8.5" />
<plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
</widget>
And also tried this:
<resource-file src="google-services.json" target="google-services.json" />
But we no success, however now I get another message:
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: me.citybeep.partnerapp
Name: City_Beep_Partner
Activity: MainActivity
Android target: android-25
Subproject Path: CordovaLib
Android project created with cordova-android#6.2.3
Error: Source path does not exist: google-services.json
I think this error is just that google-services.json did not get uploaded.
I am really dependent now on this plugin and using Ionic Push notifications is not an options at the moment...
So is there any way to tell ionic to include this google-services.json file when uploading to the cloud (and also .plist file). And I repeat, it is not problem with google-services.json file or my firebase project as everything works fine while performing build on my machine.
i tried several solutions, but the only one worked for me was specifying src and target with relative path of the google-services.json.
In your case change
<resource-file src="google-services.json" target="platforms/android/google-services.json" />
to
<resource-file src="platforms/android/google-services.json" target="platforms/android/google-services.json" />
this should work.
I have added the cordova Contacts plugin to a project as follows:
% cordova plugin add org.apache.cordova.contacts
Then did a build like this:
% cordova build ios
But the plugin is unusable - no code that refers to it gets run. The app just stops at that point. When I look in the cordova docs at https://github.com/apache/cordova-plugin-contacts/blob/master/doc/index.md there's nothing about setting config.xml. My curent config looks like this:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.OurApp.OurApp" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Our App</name>
<description>
Our descriptions.
</description>
<author email="dev#ourteam.com" href="http://cordova.io">
Our Team
</author>
<content src="index.html" />
<access origin="*" />
</widget>
I know that the build was supposed to update config.xml, but it didn't. What do I need to add to get ver 3.5 Contacts to work? And is there a list of all these config settings somewhere? TIA.
EDIT: I tried adding
<plugin name="Contacts" value="CDVContacts" />
within the widget tag - no dice.
I guess you are looking into config.xml of root folder. Please note now cordova maintaines two config files. One at root folder which have setting related to app. There is second config file at platform/ios/projectName/config.xml. this is the final config xml with all plugin related details. Please look into this config after build command. plugins must be there if they are installed. you can see all the installed plugins using command
cordova plugin plugin-list
I hope It will give you right direction. If it won't help, Please post error message from console.
Trying to port my PhoneGap javascript code into Xcode for debugging in iOS.
Using Cordova-3.0.0.
When I call:
navigator.connection.type
I am getting an 'undefined' for navigator.connection.
Did I not include the network connection plugin correctly in my config.xml, or is something else amiss? Yes, I included the correct cordova.js file specifically for iOS. Yes, deviceready has been fired.
Update: I am currently only running this on the iOS emulator.
My config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.app.test" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Hello Cordova</name>
<description>
Description
</description>
<author email="dev#callback.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<access origin="*" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<plugins>
<plugin name="NetworkStatus" value="CDVConnection" />
</plugins>
</widget>
Thank you for your help!
Been doing my research on this one, and finally came up with the solution.
Apparently PhoneGap (Adobe) recently updated their documentation, and filled in a lot of the holes I was running into for Phonegap 3.0.0
1) To do this using the command-line interface, you have to have git installed to be able to run those commands. Get git here.
2) They added to the Connection plugin documentation to use the following command-line interface commands to add the plugin to the project:
$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git
$ cordova plugin rm org.apache.cordova.core.network-information
3) They updated the declaration in the config.xml file to the following (for iOS):
<feature name="NetworkStatus">
<param name="ios-package" value="CDVConnection" />
</feature>
If you simply want to know if you are connected or not try using navigator.onLine in your js instead. Works for me on IOS 8 & Android 2.3 and doesn't require any plugins
I am using PushPlugin https://github.com/phonegap-build/PushPlugin and Cordova 2.5 for an iOS applicaiton.
In my Plugins folder I have these files:
Appdelegate+notification.h
Appdelegate+notification.m
PushPlugin.h
PushPlugin.m
In config.xml I have included the plugin like this:
<plugin name="PushPlugin" value="PushPlugin" />
I have also PushNotification.js in my www folder and included that in index.html.
When I run the application and execute the line in my push.js file:
pushNotification.register(this.tokenHandler,this.errorHandler, {"badge":"true","sound":"true","alert":"true","ecb":app.onNotificationAPN"});
Then I get this error:
Error: Plugin 'PushPlugin' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml
Is PushPlugin compatible with Cordova 2.5?
I had this same issue when trying to get the pushplugin to work. I got it working by putting this block of code inside the config.xml (not the one in the www folder, but the one in the project folder)
<!-- ios -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="PushPlugin">
<param name="ios-package" value="PushPlugin"/>
</feature>
</config-file>
<source-file src="src/ios/AppDelegate+notification.m" />
<source-file src="src/ios/PushPlugin.m" />
<header-file src="src/ios/AppDelegate+notification.h" />
<header-file src="src/ios/PushPlugin.h" />
</platform>
If you download the sample project from git, there's a file called plugin.xml that has a bunch of stuff that needs to be added to the xml (I think).
Hope that helps.
I downloaded the BlackBerry 10 jQuery Mobile theme and I wanted to try how it works on the Dev Alpha.
I created this config.xml
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0.0" rim:header="JQKS">
<author href="http://www.dandandin.net/"
rim:copyright="Copyright 2012 Dandandin.net">Dandandin.net</author>
<name>JQ Kitchensink</name>
<description>An app to test jquery</description>
<icon src="img/generic_81_81_placeholder.png" />
<content src="index.html"/>
<feature id="blackberry.invoke" version="1.0.0"/>
</widget>
and I placed it on /kitchensink
Then I packaged /kitchensink and loaded on my dev alpha, but I get this when I launch it:
I can press OK, but the application is frozen.
If I load it on my local webserver, and browse from the dev alpha it works, what's wrong?
In order to make it work, you have to update to the latest 1.0.3.8 SDK.
I had 1.0.2 and it didn't work.