Getting Started

Resources

Login Information

You'll need an Accengage Partner Id and a Private Key.

These id are available for registered customers at accengage.com

If you want to enable push notifications in your app, you need a SenderId (also called Google API Project Number) This SenderId must match the Google API Key you use in the Accengage Interface

Sample apps

If you want to see how our SDK is integrated and used in some demo apps, you can check our samples apps.

All our samples are available on Github.com

Add the SDK to your app

Add the dependency

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

app-level build.gradle

dependencies {
  // ...
  implementation 'com.ad4screen.sdk:A4SSDK:4.1.9'
}

Configure Accengage Credentials

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:

strings.xml

<resources>
    // ...

    <string name="acc_partner_id">YOUR_PARTNER_ID</string>
    <string name="acc_private_key">YOUR_PRIVATE_KEY</string>

    <string name="acc_logging">true</string>
    <string name="acc_no_geoloc">true</string>
</resource>

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 the Custom Credentials Integration section.

Modify your application class

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

Application class

public class MyApplication extends A4SApplication {

    @Override
    public void onApplicationCreate() {
        // ...
    }

    @Override
    public void onApplicationTerminate() {
        // ...
    }

    @Override
    public void onApplicationLowMemory() {
        // ...
    }

    @Override
    public void onApplicationConfigurationChanged(Configuration newConfig) {
        // ...
    }
}

In case you cannot extend A4SApplication, see Sub Classing Application class

Lock on the SplashScreen

If your application have a SplashScreen, you need to lock inapp and pushs to prevent any Accengage content display. To do so, call the following methods in your SplashScreen onCreate() method:

  • setPushNotificationLocked(true)
  • setInAppDisplayLocked(true)

Then, call the same methods with false parameter to unlock inapp and pushs in the next Activity onCreate() method.

For more information, see our section about SplashScreen

Push Providers

FCM (Firebase Cloud Messaging)

FCM is the new version of GCM. For this reason it's recommended to use plugin-firebase-messaging plugin instead of plugin-play-services-push.

FCM Setup

Before integrating the SDK and plugin-firebase-messaging plugin into your Android application to receive push notifications you need to create a Firebase project first or import your GCM project if you are migrating from GCM to FCM. You can do it either by using Firebase Assistant in Android Studio or by using Firebase console. Check this page for more details.

Once a new firebase project and an Android app of this project are created, you need to move the google-services.json file into your Android app module root directory and modify your build.gradle files to use google-services plugin. This plugin handles automatically the google-services.json file and adds necessary information about the Firebase project into your Android Studio project while building it.

 

Use Firebase Assistant in Android Studio to connect your project to Firebase and update the google-services.json file.

If you have already added FCM to your project please check that the version of firebase-messaging library is 19.0.0 to avoid conflicts with the version that Accengage plugin-firebase-messaging plugin uses.

app-level build.gradle

dependencies {
    // ...
    implementation 'com.google.firebase:firebase-messaging:19.0.0'
}

apply plugin: 'com.google.gms.google-services'

Also you may simply remove the line above with firebase-messaging because the FCM library is added automatically with the correct version number when Accengage plugin-firebase-messaging plugin is integrated in the project.

Add Accengage plugin-firebase-messaging

Add Accengage plugin-firebase-messaging plugin to be able to receive FCM/GCM push notifications:

app-level build.gradle

dependencies {
    // ...
    implementation 'com.ad4screen.sdk:A4SSDK:4.1.9'
    implementation 'com.ad4screen.sdk:plugin-firebase-messaging:4.1.9'
}

The plugin depends on the firebase-messaging:19.0.0 library, so you don't need to add it by yourself.

Add Firebase Server key and Sender ID to Accengage dashboard

Accengage servers need Server API key and Sender ID of your FCM/GCM project to send push notifications. Copy and paste them from Firebase console to Accengage dashboard.

Accengage FCM Sample

The sample application receiving push notifications from Accengage dashboard and Firebase console is available on github.

ADM (Amazon Device Messaging)

To implement ADM (Amazon Device Messaging) you need to use A4SSDK-Plugin-Amazon.

Get credentials from Amazon

To be able to receive notifications on Amazon products (like Kindle Fire), you need to retrieve the OAuth Credentials and API Key.

To do this, please follow these instructions Getting Your OAuth Credentials and API Key.

When this is done, go to Security Profiles and choose the Security Profile associated with your application. In the General tab, get the Client ID and Client Secret:

Go to the Android/Kindle Settings tab and store your key in a file named api_key.txt. This will be used later.

Configure ADM with Accengage User Interface

  1. Go to Accengage User Interface, and to Settings > Manage Application and find your application
  2. Edit your application's settings, and check Amazon checkbox. Then, fill Amazon Client ID with your own Client ID and Amazon Client Secret with your own Client Secret :

Add Amazon Plugin with Gradle

To be able to receive ADM Notifications, you need to integrate our Amazon Plugin with Gradle.

Add API Key

To be able to receive ADM Notifications, you need to add a valid API Key in your application. To do this, just add the api_key.txt file from Get credentials from Amazon part and place it in the assets folder.

More information here.

Send a basic push

Enable logging

To do so, simply add the following string:

strings.xml

<resources>
    // ...

    <string name="acc_logging">true</string>
</resource>

You can also disable the toast display when application is started (because of UI Automation for example):

strings.xml

<resources>
    // ...

    <string name="acc_logging">true,no-toast</string>
</resource>

Test your integration

To test your integration, enable the logging and start your application. You will see the following lines in the logcat, meaning the SDK is correctly launched:

Android Monitor

A4S|INFO|A4S SDK VERSION : Ax.y.z (Build : 123abc456def789hij)
A4S|ERROR|***********************************/!\***********************************
A4S|ERROR|/!\ Logging is Enabled and must be DISABLED in production environment /!\
A4S|ERROR|***********************************/!\***********************************
A4S|INFO|ManifestChecker|Manifest configuration seems to be OK

Send a test push

Send a test push and check it is well received on your device.