Integrate your Android App with the Platform

Create an App on the Platform

1. Add your App on the platform by clicking "+ NEW APP" on your xtremepush Dashboard at



2. Enter the App Name, upload the App icon, and give a short description of the app. An App key and token have been automatically generated. The App key is used in your Android project to connect the app and platform. The app token will only be used if you use the external API. Save your settings and copy the app key. Your saved settings should be similar to the following.



*If you are not using Xtremepush Geofencing or Beacons, and are not using location data in your app, please Modify the AndroidManifest.xml as follows

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"
tools:node="remove" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
tools:node="remove" />

This will remove the Locations permission from the Xtremepush SDK.

Google Cloud Messaging is the transport method that xtremepush supports for Android notifications. It is now known as Firebase Cloud Messaging (FCM) if you are enabling notifications then you will need to upload your FCM API Key. Go to your app home and navigate to Settings > Application Keys. On the right hand side select the Android App radio button and upload your app's FCM Application Key. If you have not set up an FCM API Key before this is covered in our article on FCM API Keys (if you have an existing Google Project from pre Sept 2016 you may know this as the GCM API Key and already have one generated).

Initialise the SDK in your Application

To enable xtremepush Notifications you will use your app key from the Settings > General Settings section of your app home on and your project number from the google developer console to connect your app to the platform. If you can't remember where to get this value it is described in the section on generating an FCM API Key (if you have existing Google Projects from pre Sept 2016 you may know this as the GCM API Key) for your project

Xtremepush can be integrated into your app one of two ways. In your Application class, or in each of your Activities.
We recommend integrating in your Application class, the reason being, that it only has to be initialised once and is much less error prone. Steps to both are outlined below. 

Application Level Integration

The following steps should be taken in your file. 

1. In your file import the library:

import ie.imobile.extremepush.PushConnector;

2. In the onCreate method of your file you must add the following:

public class YOUR_APPLICATION extends Application {
public void onCreate() {


The command to initialise the PushConnector takes the XTREME_PUSH_APP_KEY and the GOOGLE_PROJECT_NUMBER as inputs in String format.

3. Finally, in each of your Activities, include a reference to our PushConnector object

import static ie.imobile.extremepush.PushConnector.mPushConnector;


Per Activity Integration (Not needed if Application Level Integration was followed above)

The following 4 steps should be taken in any Activity that can be active in your application. In an application with a single base activity that updates via fragments you can just add the integration code in your base activity. In applications with multiple independent activities the integration code should be placed in all activities.

1. In your Activity import the library:

import ie.imobile.extremepush.*;

2. Declare a new member variable of type PushConnector in your main activity:

public class MainActivity extends Activity {

private PushConnector mPushConnector;

3. In the onCreate method you must add the following:

protected void onCreate(Bundle savedInstanceState) {

mPushConnector = new PushConnector.Builder("XTREME_PUSH_APP_KEY", "GOOGLE_PROJECT_NUMBER")

mPushConnector = new PushConnector.Builder("XTREME_PUSH_APP_KEY", "GOOGLE_PROJECT_NUMBER")

The command to initialise the PushConnector takes the XTREME_PUSH_APP_KEY and the GOOGLE_PROJECT_NUMBER as inputs in String format.

4. Finally add call backs to the xtremepush connector in the onActivityResult, onNewIntent, onStart, onResume, onPause, onStop and onDestroy methods as shown:


protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//xtremepush onActivityResult Callback
mPushConnector.onActivityResult(requestCode, resultCode, data);

protected void onNewIntent(Intent intent) {
//xtremepush onNewIntent Callback

protected void onStart() {
//xtremepush onStart Callback

protected void onResume() {
//xtremepush onResume Callback

protected void onPause() {
//xtremepush onPause Callback

protected void onStop() {
//xtremepush onStop Callback

protected void onDestroy() {
//xtremepush onDestroy Callback


Note: Should you manually be handling orientation changes, and you are overriding the OnConfigurationChanged method, you will also need to add another PushConnector callback to each activity that overrides the OnConfigurationChanged method.

public void onConfigurationChanged(Configuration newConfig) {


Configuring  Proguard

If you are using proguard on your app to minify, optimise, obfuscate etc. then you can add the following settings to your config file to ensure that xtremepush continues to operate as expected:

# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Application classes that will be serialized/deserialized over Gson
#-keep class** { *; }
-keep class ie.imobile.extremepush.api.model.** { *; }

# Recommended settings for other dependencies
-keep class** { *; }
-keep interface** { *; }
-keepclassmembers class ** {
@com.squareup.otto.Subscribe public *;
@com.squareup.otto.Produce public *;

# Required for inbox functionality
-keepclassmembers class * {
 @android.webkit.JavascriptInterface <methods>;

# Required for inbox functionality
-keepattributes JavascriptInterface
-keep public class ie.imobile.extremepush.ui.InboxActivity$InboxInterface
-keep public class * implements ie.imobile.extremepush.ui.InboxActivity$InboxInterface
-keepclassmembers class ie.imobile.extremepush.ui.InboxActivity$InboxInterface {

# Required if building your app with Android 23 or lower
-dontwarn ie.imobile.extremepush.ui.PopupDialog
-dontwarn ie.imobile.extremepush.ui.WebViewActivity


Retrieving your xtremepush ID

If your device is successfully registering with the platform you should be able to retrieve your XtremePush ID. This can be accomplished by calling the getDeviceInfo() method on your PushConnector as follows:


This method returns a map that contains your devices Cloud Messaging registration id and it's device id obtained from XtremePush server. If your device has not received an id then it has not successfully registered and there is an issue with your integration.

If you successfully retrieve the ID it can be used to identify your device on the platform and to send a push notification to just that device.


Excluding Certain Activities from Connecting with XtremePush

If you are integrating Xtremepush at an application level, but would prefer if certain Activities didn't create a PushConnector object (for example, you do not want your splash screen to send the onSessionStartEvent, you want it to be sent on the Activity following) you can use the following method.

Have more questions? Submit a request


Article is closed for comments.