Integration
Integrate NotifyVisitors SDK into your android app.
This section will describe how to install the NotifyVisitors SDK and configure the Android SDK easily. NotifyVisitors provides users with an Android SDK that helps the app developers to track, segment and engage users.
Requirements
- An Android 6.0 or greater device or emulator with "Google Play Store (Services)" installed
- Android Studio
- Configured NotifyVisitors App and Platform
Installation
1. Import the NotifyVisitors SDK in your project
I. Add the following repository to your project-level' build.gradle
file.
repositories {
google()
mavenCentral()
}
II. Add the following dependency to your apps' build.gradle
file.
dependencies {
implementation 'com.notifyvisitors.notifyvisitors:notifyvisitors:v5.4.9.3'
implementation 'com.android.installreferrer:installreferrer:2.1'
//Make sure to include the necessary libraries if you haven't done so already (feel free to skip any that are already included)
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation 'androidx.cardview:cardview:1.0.0'
}
2. Configure AndroidManifest.xml
You must include your NotifyVisitors credentials in the AndroidManifest.xml file of your application to connect your Android app to your NotifyVisitors account.
I. Insert the below XML snippet inside the application tag of your AndroidManifest.xml
file.
<application>
<meta-data android:name="notifyvisitors_bid"
android:value="11xx" />
<meta-data android:name="notifyvisitors_bid_e"
android:value="F8665C849AB6xxxxxxxxxxxxxxxxxx" />
.......
</application>
Info
In above example Dummy Brand ID and Secret keys are shown. Kindly login your NV_account to see your credentials.
II. Insert the below XML snippet inside manifest tag of your AndroidManifest.xml
file.
<manifest>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
1. Import the NotifyVisitors SDK in your project
I. Add the following repository to your project-level' build.gradle
file.
repositories {
google()
mavenCentral()
}
II. Add the following dependency to your App's build.gradle
file.
dependencies {
implementation 'com.notifyvisitors.notifyvisitors:notifyvisitors:v5.4.10.6'
implementation 'com.android.installreferrer:installreferrer:2.1'
//Make sure to include the necessary libraries if you haven't done so already (feel free to skip any that are already included)
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation 'androidx.cardview:cardview:1.0.0'
}
2. Configure AndroidManifest.xml
Add the permissions below to the manifest tag of your AndroidManifest.xml\
file.
<manifest>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
Initialization
1. If you don’t have your own application class, then you can register our application class in your apps' manifest file.
<application android:name="com.notifyvisitors.notifyvisitors.NotifyVisitorsApplication">
OR
2. If you have your own application class.
I. Add the undermentioned Import Statement in your application class.
import com.notifyvisitors.notifyvisitors.NotifyVisitorsApplication;
import com.notifyvisitors.notifyvisitors.NotifyVisitorsApplication
II. Initialize the SDK in the onCreate()
callback of your application class.
@Override
public void onCreate() {
super.onCreate();
NotifyVisitorsApplication.register(this);
}
override fun onCreate() {
super.onCreate()
NotifyVisitorsApplication.register(this)
}
Include our registration method into the onCreate() function of your application class. If you haven't created your own yet, go ahead and set one up.
package com.example;
import android.app.Application;
import com.notifyvisitors.notifyvisitors.NotifyVisitorsApplication;
public class ApplicationClass extends Application {
// NOTE: Replace the below with your own NOTIFYVISITORS_BRAND_ID & NOTIFYVISITORS_BRAND_ENCRYPTION_KEY
private String NOTIFYVISITORS_BRAND_ENCRYPTION_KEY = "##################################";
private int NOTIFYVISITORS_BRAND_ID = #####;
@Override
public void onCreate() {
super.onCreate();
NotifyVisitorsApplication.register(this, NOTIFYVISITORS_BRAND_ID, NOTIFYVISITORS_BRAND_ENCRYPTION_KEY);
}
}
package com.example
import android.app.Application
import com.notifyvisitors.notifyvisitors.NotifyVisitorsApplication
class MyApplication : Application() {
// NOTE: Replace the below with your own NOTIFYVISITORS_BRAND_ID & NOTIFYVISITORS_BRAND_ENCRYPTION_KEY
private val NOTIFYVISITORS_BRAND_ENCRYPTION_KEY: String = "##################################"
private val NOTIFYVISITORS_BRAND_ID: Int = #####
override fun onCreate() {
super.onCreate()
NotifyVisitorsApplication.register(this, NOTIFYVISITORS_BRAND_ID, NOTIFYVISITORS_BRAND_ENCRYPTION_KEY);
}
}
Updated 14 days ago