Our documentation is changing, please click here to enjoy it!

Skip to end of metadata
Go to start of metadata

GCM is the old Google Cloud Messaging solution. It's strongly recommended to replace it by FCM (check out our Getting Started for FCM), in order to benefit from the new FCM features.

Add Accengage SDK and plugin-play-services-push

To integrate the SDK, add the dependency for A4SSDK to your app-level build.gradle file:

app-level build.gradle

Then, you should add Accengage plugin-play-services-push plugin to be able to receive GCM push notifications:

app-level build.gradle

The plugin depends on the play-services-gcm:11.0.4 library, so you don't need to add it by your self.


The Accengage SDK will take care of all the GCM events (including Registration, Retrieving Token, ...). You don't need to handle anything by yourself.

You need to include the following lines inside your <application> tag:

Do not forget to replace “your-package” used in this example with your own application package

Integrate the SDK into your code

Modify your activities

To work properly Accengage SDK needs information about activities states, intents starting activities and bundles of these intents. For this reason, all of your activities should be slightly modified. There are two ways to do it:

  • by adding a few lines of code into Activity methods defining the lifecycle of the activity

    Modifying Activity methods
  • by inheriting A4SActivity 

    Changing the parent class on A4SActivity

In case you want to use another Android standard activity, the Accengage SDK provides modified activities :

  • A4SExpandableListActivity
  • A4SListActivity
  • A4SPreferenceActivity
  • A4SNativeActivity
  • A4SAccountAuthenticatorActivity

Modify you application class

If you are using the Application class, we recommend you to extend A4SApplication instead of the standard Application.

Application class
Since our SDK is running on its own process, your methods may be executed twice (once in your app, once in the SDK process). By extending the A4SApplication, you prevent unwanted interactions between the SDK and your App (the SDK process will not execute the code of your Application class).

In case you can not extend A4SApplication, see Sub Classing any Application Type.

Add credentials to your app

A4SSDK must be authenticated and authorized by Accengage servers. That's why you need to add application credentials (Partner ID and Private key) into strings.xml resource file:


The last two parameters presented in the code snippet are used to activate logs and disable geolocation. If you want to use geolocated In-Apps and Pushs, please check out our Geolocation section.

If you need to use different credentials, for example one pair of Partner ID / Private key per country which you would like to target, you should use localized strings: How to localize strings? 

To be able to dynamically provide Partner ID and Private key with code, please check out Custom Credentials Integration section.

Add sender ID to your app

The last thing you need to do is to add your sender ID to strings.xml as shown on the code snippet presented below.

Note that your_sender_id must be replaced by the real sender ID of your project (for instance, gcm:993056754350).

More information about sender IDs you can find on this page.

Multiple push providers

If you have another push system integrated into your app that is using GCM too, here is how to proceed in order to get them working as well:

Create your own GCM receiver which extends com.ad4screen.sdk.GCMHandler and overrides the onPushReceive method


OnPushReceive will ONLY be called for push notifications that do not come from our Web Interface.

Finally, declare your receiver inside AndroidManifest.xml:


Do not forget to replace “your-package” used in this example with your own application package

  • No labels