Installing Tapleader Android SDK
The following tutorial will guide you to Install Tapleader SDK via gradle.
Before install, create a tapleader account.
- Add it in your root
build.gradle
at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency to your app module
build.gradle
dependencies {
compile 'com.github.tapleader:tapleader-sdk-android:1.4.5'
//...
}
- Now you should add your
Client Key
andApplication Id
to theAndroidManifest.xml
file in Application scope:
<meta-data
android:name="com.tapleader.APPLICATION_ID"
android:value="YOUR_APPLICATION_IP"/>
<meta-data
android:name="com.tapleader.CLIENT_KEY"
android:value="YOUR_CLIENT_KEY" />
<meta-data
android:name="com.tapleader.CAMPAIGN_ID"
android:value="YOUR_CAMPAIGN_CODE" />
Campaign_Code is optional. Usually you shouldn't provide campaign code in manifest file. Just in case you want to Tracking Without Campaign Link
- Add following lines for permissions(before Application scope):
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Initial Tapleader in your Application class:
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
Tapleader.initialize(this);
}
}
Don't forget to register your App class in AndroidManifest.xml :
<application
android:name=".App"
<!-- other attributes -->
>
Tapleader need Some Safe permission to track user information, If your app covering device with API 23 and above you should grant permissions:
public class ManiActivity extends AppCompatActivity {
private static final int REQUEST_READ_PHONE_STATE = 99;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//check for permission
int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE);
//if permission doesn't granted you should request permission
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, REQUEST_READ_PHONE_STATE);
}
}
}
Each event have three main part :
- Name
- name or key for event
- value
- value of event!type of value is
double
- value of event!type of value is
- details
- a key-value array to pass more information about this event! type of details is
HashMap<String,Double>
- a key-value array to pass more information about this event! type of details is
HashMap<String,Double> details=new HashMap<>();
for(int i=0;i<count;i++){
details.put("My details key "+i,new Random().nextDouble());
}
Tapleader.event("MY_EVENT_NAME",0.1,details);
if you don't need to pass extra details for event:
Tapleader.event("MY_EVENT_NAME",0.1);