Manually integrate the Apache Cordova plug-in

You can manually integrate the Cordova plug-in for Android app development.

Add library dependencies

  1. Add the Google Play service library and appsupport v4 library dependencies to your project.
  2. Add the MCE SDK library (Acoustic-mobile-push-android-sdk-.aar) as an Android library to the project.
  3. Add the MCE Cordova plug-in libraries (Acoustic-mobile-push-android-sdk-js-.aar and Acoustic-mobile-push-android-plugin-cordova-.aar) as Android libraries to the project.

Prepare the plug-ins

We’ve historically deployed our Cordova SDK with JS files already generated in the ZIP file package. We upgraded Cordova SDK version 3.8.4 to use TypeScript to provide you with more flexibility. You can now generate the JS files using the Typescript compiler version 3 or later by running the build.sh command.

Typescript is a language for application-scale JavaScript. It provides developers with auto-complete, IntelliSense capabilities, and supports a tighter integration with your editor. TypeScript compiles to readable, standards-based JavaScript. For more information, see TypeScript.

If you have an existing project that uses the TypeScript compiler or if you intend to use the TypeScript compiler for a new project, then check the SDK TS config files in each plug-in directory to ensure that all your plug-ins are in the same directory.

📘

Note:

If you have highly customized configurations to your build environments, you may need to change the TS config files accordingly.

Add the plug-ins

📘

Note:

Ensure that you have built the plugins first before you add the plug-ins to your project. For more information, see Prepare the plug-ins

  1. Add the Cordova plug-in to config.xml under the widget node:
<feature name="MCEPlugin">
 <param name="android-package" value="co.acoustic.mobile.push.plugin.cordova.MceCordovaPlugin" />
</feature>
  1. Add MCEPlugin.js to the project.

Add your app key

In your string.xml file, add your app key as follows:

<string name="appkey">$ANDROID_APPKEY</string>

where $ANDROID_APPKEY is your app key.

Modify the AndroidManifest.xml

  1. In the AndroidManifest.xml file, make the following modifications.
  • Update the $PACKAGE_NAME with your application package name.
  • Update the $SERVER_URL with the MCE baseURL. For the $SERVER_URL for your pod, see Setting the base URL
  1. Add metadata under application node as follows:
<!-- MCE properties -->
<meta-data android:name="messagingService" android:value="fcm" />
<meta-data android:name=”mceSenderId” android:value=”” />
<meta-data
 android:name="mceAppKey"
 android:value="@string/appkey" />
<meta-data
 android:name="mceSessionEnabled"
 android:value="true" />
<meta-data
 android:name="mceSessionDuration"
 android:value="5" />
<!--
 MCE server definition:
 "us" - American server
 "eu" - EU server
 The value can also be a custom URL like "https://myserver.api.mce.com"
 If not defined, the default value is "US"
-->
<meta-data
 android:name="mceServer"
 android:value="$SERVER_URL" />
<meta-data android:name="com.google.android.gms.version"
 android:value="@integer/google_play_services_version"  

<!– FCM Messages –>
<service android:name=”co.acoustic.mobile.push.sdk.fcm.FcmMessagingService”>
<intent-filter> 
<action android:name=”com.google.firebase.MESSAGING_EVENT”/>
</intent-filter>
</service>
  1. Set the application node android:name attribute value to co.acoustic.mobile.push.sdk.js.MceJsonApplication.

Did this page help you?