Hello,
I want to use a vendor cordova plugin called AppConnectCordovaConfigPlugin in my ionic project, but it did not work. I got error on my device ACConfigPlugin.testMe()
is not a function.
I think perhaps I do not use plugin correctly or the generated package.json is wrong? Please help!!!
Here are my steps:
- I copy the folder AppConnectCordovaConfigPlugin in my project.
- Because of the fact, that the cordova plugin has no package.json I execute npm init in the plugin folder to build package.json.
- Execute ionic cordova plugin add AppConnectCordovaConfigPlugin. Entries are made in my apps config.xml and package.json.
- Usage in my code. I add a function into vendor code ACConfigPlugin.js testMe() which returns any value for testing.
declare var ACConfigPlugin: any;
....
initializeApp() {
this.platform.ready().then(() => {
ACConfigPlugin.testMe();
);
});
}
Here is the folder structure of vendor plugin
-src
--android
---ACConfigPlugin.java
---AppConnectConfigService.java
-www
--android
---ACConfigPlugin.js
-plugin.xml
The plugin.xml
<!--
Distributed by MobileIron, Inc.
Customers and partners may freely copy and re-use.
-->
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-appconnect-config"
version="999.999.999">
<name>cordova-plugin-appconnect-config</name>
<author>MobileIron</author>
<description>
This plugin allows your application to receive app-specific configuration from Core
</description>
<engines>
<engine name="cordova" version=">=4.1.0" />
</engines>
<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="ACConfigPlugin">
<param name="android-package" value="com.mobileiron.cordova.appconnect.ACConfigPlugin"/>
<param name="onload" value="true" />
</feature>
</config-file>
<config-file target="AndroidManifest.xml" parent="/manifest">
<!-- <uses-sdk android:minSdkVersion="19" /> -->
<permission android:name="com.mobileiron.CONFIG_PERMISSION" android:protectionLevel="signature" />
<uses-permission android:name="com.mobileiron.CONFIG_PERMISSION" />
</config-file>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<service android:name="com.mobileiron.cordova.appconnect.AppConnectConfigService"
android:enabled="true"
android:permission="com.mobileiron.CONFIG_PERMISSION">
<intent-filter>
<action android:name="com.mobileiron.HANDLE_CONFIG" />
</intent-filter>
</service>
</config-file>
<js-module src="www/android/ACConfigPlugin.js" name="ACConfigPlugin">
<clobbers target="ACConfigPlugin" />
</js-module>
<source-file src="src/android/AppConnectConfigService.java" target-dir="src/com/mobileiron/cordova/appconnect" />
<source-file src="src/android/ACConfigPlugin.java" target-dir="src/com/mobileiron/cordova/appconnect" />
</platform>
</plugin>
The generated package.json
{
“name”: “ACConfigPlugin”,
“version”: “1.0.0”,
“description”: “## Description”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”
},
“author”: “”,
“license”: “ISC”
}