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
()
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.
The list of events to setup triggers and track goals, user properties that allows to personalize messages and to target better.
()
Getting Started
Prerequisites
Flutter SDK supported version is >= 3.0.1.
Set TAGs for Widgets
In order to display actions on Widgets, you can set tags for widgets using ValueKey with String as a value to it. It is highly recommended to set TAGs for Widgets which are Scrollable or contains multiple child widgets.
To avoid getting the elements from previous screens add the following in build method
Widget build(BuildContext context) {
ApxorFlutter.setContext("{Enter you route name here}", context);
}
Step 4: Handle deeplink redirection
Use setDeeplinkListener to listen on deeplink redirection from Apxor SDK and handle redirection logic (including external redirection) within application logic as follows
ApxorFlutter.setDeeplinkListener((url) {
// interpret the URL and handle redirection within the application
_routeState.go(url!);
// Or, to an external URL which will be opened in Browser
});
If you do not have a proguard-rules.pro file in android folder then create one and configure the below rules in that proguard-rules.pro file. If you already have a proguard-rules.pro file in android folder then just configure the below rules in the existing file.
-keep class com.apxor.** { *; }
-dontwarn com.apxor.**
Add the following in <project>/android/app/build.gradle
Exoplayer enables to configure Picture In Picture videos from Apxor dashboard and typically increases the app size by ~1Mb, if you are already using exoplayer in your app this step is not needed else add the following dependency in the application build.gradle file
Path: <project>/<app-module>/build.gradle:
com.apxor.androidx:apxor-android-sdk-rtm:2.3.6@aar version onwards
This step is needed only if you use Apxor's Video InApp messages.
Note
In the Android Gradle Plugin 3.5.0, we desugar & dex using Gradle artifact tranforms, which allow more parallelism and caching. This mechanism relies on libraries having the correct Maven information, because we use dependencies specified in POM files to set up the desugaring classpath. In cases we are unable to see all dependencies when desugaring a class it is required to disable parallel transformation to faciliate the process by adding the property as mentioned below.
Add the following in gradle.properties
Path: <project>/<app-module>/gradle.properties:
android.enableDexingArtifactTransform = false
Step 7: 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 :
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
Note
Apxor uploads data only when the app is minimized to the background. If you are running from Android Studio (emulators or devices), do not stop the app, just press on the "home" button in order for data to be uploaded.
Step 8: 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.
iOS Integration
Step 1: Auto initialize SDK
To Auto initialize SDK (Recommended), add the following inside your application plist file.
Open your application's Info.plist as source code.Open Plist as Source Code
Copy paste the below piece of code, to create an entry for ApxorSDK.
If you are unable to find our plugins in your pods after flutter run, then dopod update
Step 2: Configuring Test Device
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:
go to your project settings
select Targets
Click on the Info 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
Note
Make sure the URL scheme has the value of your bundle identifier that was provided in the dashboard while registering with us. Also, the app must have the same bundle identifier.
Step 3: Handling the deep link
Enable Apxor to handle Apxor specific deeplinks.
In your application's AppDelegate file, in the function application(_:open:options:), add the following code at the beginning,
// Swift
let urlStr = url.absoluteString
if (urlStr.contains("add-test-device")) {
ApxorSDK.handleDeeplink(url)
}
Step 4: 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.
Embed Slot
Note
For using Apxor Embedded Cards the versions of the following plugins should be greater than or equal the ones mentioned below
Core: 2.10.26
RTA: 1.09.26
CE: 1.05.16
WYSIWYG: 1.02.67
In all areas of the app where you may want to show an in-line widget, insert the following code
const ApxorEmbedWidget(valueKey: <Tag>)
Rename <Tag> to any unique ID (any positive Integer). Ensure that you keep the ID unique across different IDs and across different ApxorEmbedWidget instances.
Story Slot
Note
For using Apxor Stories the versions of the following plugins should be greater than or equal the ones mentioned below
Core: 2.10.26
RTA: 1.09.26
CE: 1.05.16
WYSIWYG: 1.02.67
In all areas of the app where you may want to show stories, insert the following code
const ApxorStoryWidget(id: <ID>)
Replace <ID> with any unique integer(any positive Integer). Ensure that you keep the ID unique across different ApxorStoryWidget instances.
Web Integration
Step 1: Add integration scripts and Initialize Apxor
Add the following integration scripts to your index.html file in the head tag(project/web/index.html)
Add your site ID and app version in the code below
Add meta-data tag in AndroidManifest.xml file with your unique APP_ID as a value. You need to replace YOUR_APP_ID with your actual App Id. to know how to get app-id.
to log user properties, events and event properties.
to log user properties, events and event properties.