Build the sample Cordova app

Overview

You can use the sample app provided with our Cordova SDK to customize and test your mobile app messages with minimal effort.

Before you begin

  • Download the Cordova package and change to the samples/Sample folder.
  • Install TypeScript compiler version 3 or later. Run npm install typescript to install the TypeScript compiler.

Rename the Android app package id

  1. Go to applications/samples/Sample/config.xml and modify the following:
  • change widget node’s android-packageName value to your preferred Android package name.
  • change the widget node’s CFBundleIdentifier to your preferred iOS Bundle Identifier.
  1. Modify package.json name value to match the preferred Android package name.

Add support for FCM

To enable FCM support, copy the google-services.json file to the applications/samples/sample directory.

Prepare the project

  1. Change directory to sample app directory.
cd applications/samples/sample
  1. Open the postinstall_cordova.sh file in the applications/samples/sample directory.
  2. Configure your plug-in variables in the postinstall_cordova.sh file. When you complete this configuration, you no longer need to run the plug-in variables manually. For example,
location --variable SYNC_RADIUS=10000  --variable SYNC_INTERVAL=60
beacon --variable UUID=<UUID>
  1. Save the file.
  2. Run npm install to build your plugins. The Android and iOS platforms and all the plugins are added to your project.
  3. Run Cordova prepare.

📘

Note:

For the SERVER_URL for your pod, see Setting the baseURL.

Set up your iOS app

  1. In Xcode, go to Project > Target > Capabilities and enable Push Notifications.
  2. Open the Xcodeproj file in platforms/ios/.xcodeproj. In the iOS sample app, you must change the app ID of the sample app to match the certificate’s app ID after you open it in Xcode.

📘

Remember

If you do not set your team and provisioning profile, the app will not have permission to get the APNs deviceToken.

Set up your Android app

Set the ANDROID_HOME variable. For example, export ANDROID_HOME=/Applications/android.

Test your Apache Cordova iOS and Android apps

  1. Run the emulator for your sample apps.
  2. Build and run your Android and iOS apps.

Did this page help you?