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
- 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.
- 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
- Change directory to sample app directory.
cd applications/samples/sample
- Open the postinstall_cordova.sh file in the applications/samples/sample directory.
- 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>
- Save the file.
- Run
npm install
to build your plugins. The Android and iOS platforms and all the plugins are added to your project. - Run
Cordova prepare
.
Note:
For the SERVER_URL for your pod, see Setting the baseURL.
Set up your iOS app
- In Xcode, go to Project > Target > Capabilities and enable Push Notifications.
- 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
- Run the emulator for your sample apps.
- Build and run your Android and iOS apps.
Updated 10 months ago