Cordova
Things to keep handy before starting your integration with Apxor
Please have the following handy before beginning the integration:
Application identifier generated on the Apxor dashboard for your app (Read more on how to fetch the application identifier from Apxor dashboard)
App Bundle Id : Every app has a unique application ID that looks like
com.example.myapp
. This id uniquely identifies the app on the device and also on the app store. (Know more about bundle ids here)The list of events to setup triggers and track goals, user properties that allows to personalize messages and to target better. (Read more on how you can setup here)
Cordova Integration
Step 1: Getting started
Run the following command in your terminal from the project folder. This command will fetch the apxor plugins for you.
cordova plugin add cordova-plugin-apxor-sdk
Step 2: Handle deeplink redirection
Use registerDeeplinkHandler
to listen on deeplink redirection from Apxor SDK and handle redirection logic (including external redirection) within application logic as follows
ApxorSDK.registerDeeplinkHandler((deeplinkUrl) => {
// Whenever redirection happens from InApp notification buttons,
// this callback will be executed.
switch (deeplinkUrl) {
case "scheme://about":
// Redirect to About Component
break;
default:
// Check if it's external URL and redirect to Browser
break;
// and so on
}
});
Android Integration
Step 1: Add dependencies
Add plugin dependencies to your application build.gradle
file
Path: <project>/<app-module>/build.gradle
:
Check the latest release notes here.
1.1 ApxorSDK dependencies (mandatory)
dependencies {
//...
// Event tracking and a must-have dependency for other plugins
implementation 'com.apxor.androidx:apxor-android-sdk-core:3.1.9@aar'
// Add these for Realtime Actions and Surveys
implementation 'com.apxor.androidx:apxor-android-sdk-qe:1.8.5@aar'
implementation 'com.apxor.androidx:apxor-android-sdk-rtm:2.6.4@aar'
implementation 'com.apxor.androidx:surveys:2.2.7@aar'
// Helper plugin to create walkthroughs
implementation 'com.apxor.androidx:wysiwyg:1.6.3@aar'
// Add the below two dependencies to establish an SSE connection for WYSIWYG
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'com.launchdarkly:okhttp-eventsource:2.5.0'
//...
}
1.2 Add exoplayer in your app (optional)
Step 2: Add Proguard Rules
Configure the below rules in your proguard-rules.pro
file
Path: <project>/<app-module>/gradle.properties
:
-keep class com.apxor.** { *; }
-dontwarn com.apxor.**
Step 2: Initialize Apxor Android SDK
To Auto initialize SDK (Recommended), add following
meta-data
tag inside yourapplication
tag in yourAndroidManifest.xml
file<application> <!-- You must replace your app in android:value attribute --> <meta-data android:name="APXOR_APP_ID" android:value="APP_ID" /> </application>
To manually initialize SDK, call
ApxorSDK.initialize
method in yourApplication
class//... import com.apxor.androidsdk.core.ApxorSDK; public class MyApplication extends Application { @Override public void onCreate() { // ... ApxorSDK.initialize(<YOUR_APP_ID>, this.getApplicationContext()); } }
Step 3: Enable uninstall tracking for your users [Optional]
Apxor uses your firebase server key to send silent push notifications to track uninstalls in order to measure outcomes of your campaign. To enable this please do the following :
Path : app/build.gradle
Step 4: To view tooltips, Coachmark and Badges
In your MainActivity
onCreate
method you must set the tag for the WebView
as follows to view the tooltips.
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Your logic goes here
appView.getView().setTag("MyWebView");
}
}
Step 5: Ensuring ApxorSDK is initialised successfully
We have to verify for two things as follows :
SDK Initialisation
On running your android project lookout for the following log in logcat :
ApxorSDK(v3**) successfully initialized for: APP_ID

Plugin Initialisation
By default, only error logs are enabled. To see debug logs for plugin initialisation and to confirm tracking event triggers, user properties. Please run the below command in terminal
adb shell setprop log.tag.Apxor VERBOSE

Step 6: Log data to set up triggers and measure goals
Now as we are done with basic integration, we can go ahead to setup event triggers, capture data for targeting and to personalize messaging.
Please follow the guide here to log user properties, events and event properties.
iOS integration
Initialize Apxor iOS SDK
To Auto initialize SDK, add the following inside your
application
plist file.Open your application's Info.plist as source code.
Copy paste the below piece of code, to create an entry for ApxorSDK.
<key>Apxor</key>
<dict>
<key>Core</key>
<string>{YOUR_APP_ID}</string>
<key>APXSurveyPlugin</key>
<true/>
<key>APXRTAPlugin</key>
<true/>
<key>APXWYSIWYGPlugin</key>
<true/>
</dict>
Configuring Test Device
First, you need to configure your app to ensure there is a URL Scheme with your application's bundle identifier as the value.
If your app already has a URL Scheme with your application's bundle identifier as the value, you can skip this step.
Configuring URL Scheme
To configure URL scheme, goto your project settings, select
Targets
. Click on theInfo
tab.Select the
URL Types
, and click on the+
button to add a new URL Scheme.Add a new URL Scheme with your
bundle identifier
as the value.Your bundle identifer will be in the format,
com.xxxx.xxxx
Use the image below for reference.

Handling the deep link
To show tooltips
In your
MainViewController
(the ViewController extending theCDVViewController
)init
method you must set the tag for theWebView
as follows to view the tooltips.
// ...
if (self.webView != null) {
[self.webView setTag:123];
NSLog(@"My webview is: %@", self.webView);
} else {
NSLog(@"Error in setting TAG to webview");
}
// ...
You have to init the APXWKScriptHandler and call registerEventsAndScripts method to make sure any the calls made in the webview are taken care by the native SDK. It's as follows,
If you don't already have a bridging header, checkout how to create a bridging header.
Add the following in the bridging header file.
#import "APXRTAPlugin/APXWKScriptHandler.h"
Now, add the following to the init method of your webview
let apxHandler: APXWKScriptHandler = APXWKScriptHandler.init(handlerFor: webView) apxHandler.registerEventsAndScripts()
Here's how to do the same thing in objective-C.
Make sure there's a proper WKUserContentController set to your WkWebView, if not please init it and use that config to initialise your WKWebView.
#import "APXRTAPlugin/APXWKScriptHandler.h"
... // add apxor's script handler APXWKScriptHandler *scriptHandler = [[APXWKScriptHandler alloc] initWithHandlerForWebView:_webView]; [scriptHandler registerEventsAndScripts];
Ensuring ApxoriOSSDK is initialised successfully
Lookout for the following log in
console output
,ApxoriOSSDK (2XX) : initialized!
Additional features API Guide
Click here for guides to log user properties, events and event properties.
Last updated