Manually integrate the Apache Cordova plug-in

This article is archived and no longer updated.

You can manually integrate an older version of the Campaign SDK (3.8.7 and below) into your iOS or Android app. We recommend using a current version of the SDK as described in Integrate the Campaign Cordova SDK into your app.

  1. Open your iOS project up in XCode.
  2. Under Signing & Capabilities, make sure that your project has the push notifications capability added.
  3. From the Acoustic Cordova SDK repository, go to the plugins/co.acoustic.mobile.push.sdk/src/ios directory and copy the *.h and *.m files into the Classes folder in XCode.
  4. From the General tab, in the Frameworks, Libraries, and Embedded Content section, add the following frameworks:
    • AcousticMobilePush.xcframework(you can find this under the plugins/co.acoustic.mobile.push.sdk/src/ios directory),
    • CoreLocation.framework,
    • libsqlite3.dylib, and
    • CoreTelephony.framework.
  5. Copy the plugins/co.acoustic.mobile.push.sdk/www/js/MCEPlugin.js file into your www directory.
  6. Include the MCEPlugin.js in a script tag in your application's HTML. For example,
    <body> ... <script type="text/javascript" src="js/MCEPlugin.js"></script> ... </body>
  7. Add the following lines to your config.xml file inside the widget tag:

    📘

    Note:

    In the examples, the strings beginning with $ are variables. Replace all variables with their corresponding values.

    <platform name="ios"> <config-file target="config.xml" parent="/*"> <feature name="MCEPlugin"> <param name="ios-package" value="MCEPlugin"/> </feature> <preference name="baseUrl" value="$SERVER_URL" /> <preference name="prodAppKey" value="$IOS_PROD_APPKEY" /> <preference name="devAppKey" value="$IOS_DEV_APPKEY" /> <preference name="autoInitialize" value="$AUTO_INITIALIZE" /> <preference name="loglevel" value="$LOGLEVEL" /> <preference name="invalidateExistingUser" value="$INVALIDATE_EXISTING_USER" /> <preference name="autoReinitialize" value="$AUTO_REINITIALIZE" /> </config-file> <config-file target="*-Info.plist" parent="UIBackgroundModes"> <array> <string>remote-notification</string> </array> </config-file> <config-file target="*-Info.plist" parent="NSLocationAlwaysAndWhenInUseUsageDescription"> <string>Be notified when interesting things are nearby</string> </config-file> <config-file target="*-Info.plist" parent="NSLocationAlwaysUsageDescription"> <string>Be notified when interesting things are nearby</string> </config-file> <config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription"> <string>Be notified when interesting things are nearby</string> </config-file> </platform>
  8. You can now build and run your application.
  1. From the Acoustic Cordova SDK repository, copy the contents of the following folders as follows:

    • plugins/co.acoustic.mobile.push.sdk/src/android/src directory into the platforms/android/app/src/main/java folder.
    • acoustic-mobile-push-android-sdk-.aar_ to _platforms/android/app/src/main/libs* folder.
    • plugins/co.acoustic.mobile.push.sdk/www/js/MCEPlugin.js into your applications www directory.
  2. Include the MCEPlugin.js in a script tag in your application's HTML.

  3. Open your project in the Android studio and complete the following steps:

    1. Add the following dependencies:
      • com.google.android.gms:play-services-base:18.1.0
      • com.google.android.gms:play-services-auth:20.3.0
      • com.google.code.gson:gson:2.10
      • com.google.firebase:firebase-core:19.0.1
      • com.google.firebase:firebase-messaging:22.0.0
      • com.google.firebase:firebase-iid:21.1.0
      • acoustic-mobile-push-android-sdk-3.8.6.aar
    2. Add the following to app/repositories.gradle inside the ext.repos block:
      flatDir { dirs 'src/main/libs' }
  4. In your app's config.xml file, add the following lines inside the <platform name=’android'> tag:

    <preference name="GradlePluginGoogleServicesEnabled" value= "true"/> <preference name="AndroidXEnabled" value="true" /> <config-file target="res/xml/config.xml" parent="/widget"> <feature name="MCEPlugin"> <param name=" android-package" value= "co.acoustic.mobile.push.plugin.cordova.MceCordovaPlugin"/> </feature> </config-file>
  5. Go to your android manifest file and complete the following:

    📘

    Note:

    In the examples, the strings beginning with $ are variables. Replace all variables with their corresponding values.

    a. Add the following permissions inside the manifest tag: (If you already have some of these permissions you don't need to add those).

    <!-- INTERNET is required for calling the MCE server --> <uses-permission android:name= "android.permission.INTERNET"/> <!-- WAKE_LOC is required for running scheduled tasks --> <uses-permission android:name= "android.permission.WAKE_LOCK"/> <!-- RECEIVE_BOOT_COMPLETED is required for performing SDK task on device startup --> <uses-permission android:name= "android.permission.RECEIVE_BOOT_COMPLETED"/> <!-- VIBRATE is required for notification configuration --> <uses-permission android:name= "android.permission.VIBRATE"/> <queries> <intent> <action android:name= "android.intent.action.DIAL"/> </intent> <intent> <action android:name= "android.intent.action.VIEW"/> <data android:scheme="https"/> </intent> </queries>

    b. Add the following meta-data properties inside the manifest/application tag:

    <!-- MCE API26 properties --> <meta-data android:name="channelName" android:value="$CHANNEL_NAME" /> <meta-data android:name="channelDescription" android:value="$CHANNEL_DESCRIPTION" /> <meta-data android:name="channelId" android:value="$CHANNEL_ID" /> <!-- MCE properties --> <meta-data android:name="autoInitialize" android:value="$AUTO_INITIALIZE" /> <meta-data android:name="autoReinitialize" android:value="$AUTO_REINITIALIZE" /> <meta-data android:name="mceAppKey" android:value="@string/appkey" /> <meta-data android:name="loglevel" android:value="$LOGLEVEL" /> <meta-data android:name="mceSessionEnabled" android:value= "true"/> <meta-data android:name="mceSessionDuration" android:value= "5"/> <meta-data android:name="mceServer" android:value="$SERVER_URL" /> <meta-data android:name="invalidateExistingUser" android:value="$INVALIDATE_EXISTING_USER" /> <meta-data android:name=" com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <receiver android:exported="false" android:name="co.acoustic.mobile.push.sdk.js.JsonMceBroadcastReceiver"> <intent-filter> <action android:name= "co.acoustic.mobile.push.sdk.NOTIFIER"/> </intent-filter> </receiver> <!-- AlarmReceiver is required for SDK scheduled tasks and device status updates --> <receiver android:exported="false" android:name= "co.acoustic.mobile.push.sdk.wi.AlarmReceiver"> <intent-filter> <action android:name= "android.intent.action.BOOT_COMPLETED "/> </intent-filter> <intent-filter> <action android:name= "android.intent.action.TIMEZONE_CHANGED "/> </intent-filter> <intent-filter> <action android:name= "android.intent.action.PACKAGE_REPLACED "/> <data android:scheme="package" /> </intent-filter> <intent-filter> <action android:name= "android.intent.action.LOCALE_CHANGED "/> </intent-filter> </receiver> <!-- NotifActionReceiver is required for notification handling --> <receiver android:exported="false" android:name= "co.acoustic.mobile.push.sdk.notification.NotifActionReceiver "/> <service android:name= "co.acoustic.mobile.push.sdk.session.SessionTrackingIntentService "/> <!-- EventsAlarmListener is required for eventhandling --> <service android:name= "co.acoustic.mobile.push.sdk.events.EventsAlarmListener"/> <!-- PhoneHomeIntentService is required to allow the client to contact the server to update state --> <service android:name= "co.acoustic.mobile.push.sdk.registration.PhoneHomeIntentService "/> <!-- RegistrationIntentService is required for SDKregistration --> <service android:name= "co.acoustic.mobile.push.sdk.registration.RegistrationIntentService "/> <!-- AttributesQueueConsumer is required for attributes handling --> <service android:name= "co.acoustic.mobile.push.sdk.attributes.AttributesQueueConsumer "/> <!-- InboxUpdateService is optional. It is used for retrieving ibox updates from the MCE server. It is required only if the inbox is used --> <service android:name= "co.acoustic.mobile.push.sdk.plugin.inbox.InboxUpdateService "/> <!-- MdeJobService is used for launching a job while the app is in the foreground. This service is only used in Android O and above --> <service android:name= "co.acoustic.mobile.push.sdk.job.MceJobService" android:permission= "android.permission.BIND_JOB_SERVICE "/>

    c. Add the following attributes to the application tag:

    android:name= "co.acoustic.mobile.push.sdk.js.MceJsonApplication" android:label="@string/app_name" tools:replace=" android:name"

    d. Add the following attributes to the namespace tag:

    xmlns:tools= "http://schemas.android.com/tools"
  6. Add the appkey in your strings.xml file:

    <string name="appkey">$ANDROID_APPKEY</string>
  7. You can now build and run your application.

Install the InApp plugin for the SDK manual integration

  1. Copy the contents of plugins/co.acoustic.mobile.push.plugin.inapp/assets to your main _www/ _folder.

  2. Add a reference to the 4 CSS files in your HTML.

    < link rel = "stylesheet" type = "text/css" href = "css/inapp_media.css" /> < link rel = "stylesheet" type = "text/css" href = "css/inapp_banner.css" /> < link rel = "stylesheet" type = "text/css" href = "css/inapp_image.css" /> < link rel = "stylesheet" type = "text/css" href = "css/inapp_video.css" />
  3. Add the plugin to your Cordova project:

    cordova plugin add ./path-to-mce-cordova- sdk/plugins/co.acoustic.mobile.push.plugin.inapp
  4. Add the 3 JQuery files located in applications/samples/Sample/www/js to your projects www/ folder.

  5. Reference the 3 JQuery files to your HTML with a script tag:

    < script src="js/jquery-1.11.1.min.js">undefined</ script> < script src="js/jquery.mobile-1.4.5.min.js">undefined</ script> < script src="js/jquery-ui-1.11.4.min.js">undefined</ script>
  6. You can now build and run your application with the InApp plugin enabled.

Add additional plugins

You can install additional plugins using the cordova plugin add CLI command. For more information, see Add the Cordova SDK to your app.