Uninstall Insights Android SDK
Uninstall SDK helps you understand the reasons for your app uninstalls, reduce the uninstall rate using a powerful predictive engine and also get app Re-installs through a unique actionable channel (Android version 2.3.3 and above).
This guide will provide you step by step details on how to integrate the SDK in few minutes. Following steps outline the integration process in detail.
- Clone the github repository or download the zipped file.
- Add UninstallIO_12.2.jar SDK file to project.
- Set the SDK “Token and Secret” in your project's string.xml file.
- Push Notification Configuration
- Configure SDK settings in the your project's AndroidManifest.xml file.
- Initialize the SDK in the MainActivity class.
- Pass information to SDK from the App.
- Proguard
- Uninstall permission requirements
Clone the github repository
git clone https://github.com/uninstallio/android-sdk.git
or download the zipped file.
https://github.com/uninstallio/android-sdk/archive/master.zip
Unzip the "android-sdk-master.zip" file.
If you are using Eclipse, then follow the below steps to add the jar file.
How to add a jar file
If you are using Android Studio, then follow the below steps to add the jar file.
How to add a jar file
In eclipse, goto project's root folder --> res folder --> values folder --> strings.xml file. Add the following lines in the file.
<string name="notiphi_app_token">TOKEN_GIVEN_BY_UNINSTALL_SEPARATELY</string>
<string name="notiphi_app_secret">APP_SECRET_GIVEN_BY_UNINSTALL_SEPARATELY</string>
Note: If you do not have the token and secret then please drop a mail with name and email to sdk_integration@uninstall.io to get these credentials for your app.
####4.Push Notification Configuration If you are using your own or a third party push notification facility for your app, then
a) Add the following line to string.xml file of your project
<string name="vendor_gcm_sender_id" translatable="false">YOUR_GCM_SENDER_ID </string>
You can get this from your Google Console or your third party push provider.
b) Follow below instruction to ignore GCM message from Uninstall.
Add below code snippet at beginning of the following functions, Class which handle the GCM messages (Either by Play service or GCM jar respective order) respective order.
a) onHandleIntent(Intent intent)
b) onMessage(Context context, Intent intent)
if (mIntent.getStringExtra("is_notiphi") != null) {
return;
}
After adding the JAR into your project, modify your AndroidManifest.xml file as mentioned below:
- Android Version: Set the minimum android SDK version to 14 or higher.
<uses-sdk android:minSdkVersion="14" />
- Permissions: Add the following permissions in the file and replace YOUR_PACKAGE_NAME with your application's package name.
<permission android:name="YOUR_PACKAGE_NAME.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="YOUR_PACKAGE_NAME.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
Optional Permissions
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- Uninstall Service and Receivers: Add the following xml code inside "application" tag and replace YOUR_PACKAGE_NAME with your application’s package name
<receiver
android:name="com.notikum.notifypassive.receivers.NotiphiGCMBroadCastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="YOUR_PACKAGE_NAME" />
</intent-filter>
</receiver>
<receiver
android:name="com.notikum.notifypassive.receivers.InstallReferrerReceiver"
android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service android:name="com.notikum.notifypassive.services.GCMInformService" />
<service android:name="com.notikum.notifypassive.services.NotiphiGCMIntentService" />
<service android:name="com.notikum.notifypassive.services.UninstallInstanceIdService" />
- Google Play Services Library Configuration .
a) Add Google Play Services to Eclipse.
b) Add Google Play Services to Android Studio.
Note:: Google Play Services must be compiled against version 6.5 or above.
a) Add the below import statement in your Launcher Activity of your application
import com.notikum.notifypassive.UninstallSession;
b) Add the below code inside the onCreate method of your Launcher Activity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
UninstallSession.init(context, 1); // context is you activity context.
}
c) Capture email id : If you do not wish to fetch email id using the SDK, please add the below code snippet before the SDK is initialized -> i.e. before this line { UninstallSession.init(context, 1); }
UninstallSession.fetchEmailId(false);
Note : By default, this feature is enabled.
You could pass various types of information to our backend systems e.g. Email id, your backend system's Userid or In App Events through our SDK's efficient event-capturing ability.
Please pass the User ID assigned by your backend system for this user. Also pass the email (if available). This data will be used to synchronize the various ID’s between our and your backend systems and also to take relevant actions. This information has to be passed only once in the lifetime of the app and not everytime.
Please pass the UserID and Email using the sample code shown below:
SharedPreferences sharedPreferences = getSharedPreferences("Constants.NOTIPHI_SHARED_PREFERENCES", Context.MODE_PRIVATE);
boolean isFirstTimeInstall = sharedPreferences.getBoolean("isFirstTimeInstall", true);
if (isFirstTimeInstall) {
//Send email-id
UninstallAnalytics.with(context).identify(new Traits().putEmail("YOUR_EMAIL_ID"));
//send user-id
UninstallAnalytics.with(context).identify(new Traits().putUsername("YOUR_USER_ID"));
// NOTE: context is your activity context.
Editor editor = sharedPreferences.edit();
editor.putBoolean("isFirstTimeInstall", false);
editor.commit();
}
You could pass the In App events using the following code snippet.
UninstallAnalytics.with(context).track("Viewed Product", new Properties().putValue("Shirt", "Shirt_ID"));
// NOTE: context is your activity context.
Adding the following lines to the proguard settings file will avoid any error after adding the SDK:
-keep class com.notikum.notifypassive.** {*;}
-keep public class com.google.android.gms.** {*;}
NOTE : if you get the below warning message during your release build.
"Warning:com.notikum.notifypassive.utils.NotiphiUtility: can't find referenced class com.google.android.gcm.GCMRegistrar"
then please add also below line in your Proguard file.
-dontwarn com.notikum.notifypassive.utils.**
Our SDK requires the following permissions in order to function correctly. We have outlined the reasons why we need each of these permissions.
#####Must have permissions
<tr>
<td>"com.google.android.c2dm.permission.RECEIVE"
</td>
<td>App has permission to register for and receive GCM
tokens from GCM server.
</td>
</tr>
<tr>
<td>“android.permission.INTERNET"
</td>
<td>Internet permission is required to communicate
with the server.
</td>
</tr>
<tr>
<td>“android.permission.WAKE_LOCK”
</td>
<td>Required so the application can keep the processor
from sleeping when a message is received.
</td>
</tr>
"YOUR_PACKAGE_NAME.permission.C2D_MESSAGE” | This permission ensures that Our SDK can use GCM facility. |
#####Good to have permission (Optional)
"android.permission.ACCESS_COARSE_LOCATION" | Required to access your location. |
"android.permission.READ_PHONE_STATE" | Required to get details about phone and sim network. eg.IMEI, Phone type, sim operator, etc.. |
“android.permission.ACCESS_NETWORK_STATE” | Network state permission to detect network status. |
"android.permission.ACCESS_WIFI_STATE" | Required to access your basic wifi data. |
"android.permission.GET_ACCOUNTS" | GCM requires a Google account if the device is running a version lower than Android 4.0.4. |
Having trouble with integration? Please contact us with name & email to sdk_integration@uninstall.io and we’ll help you sort it out in a jiffy.