Getting started

Requirements


Installation

Please continue with the below in order to implement our SDK within your Application.

  1. Set maven path in your root/build.gradle file:

    ...
    allprojects {
        repositories {
            google()
            jcenter()
            maven { url "https://synerise.bintray.com/Android" }
        }
    }
    
  2. Import dependency in your project/build.gradle file:

    buildscript {
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.3'
    
            classpath 'com.synerise.sdk:synerise-gradle-plugin:3.0.4'
            classpath 'org.aspectj:aspectjtools:1.9.2'
        }
    }
    
Note: We guarantee stability only on Android Gradle plugin 3.1.3 or lower.
  1. Import dependency in your app/build.gradle file and apply plugin:

    apply plugin: 'com.android.application'
    apply plugin: 'android-aspectjx'
    apply plugin: 'synerise-plugin'
    
    ...
    dependencies {
    ...
    // Synerise Android SDK
    implementation 'com.synerise.sdk:synerise-mobile-sdk:3.3.17'
    }
    
  2. Finally, please make sure your Instant Run is disabled.

Tip: Android Studio: File -> Settings -> Build, Execution, Deployment -> Instant Run

Configuration

First of all, you need to initialize Synerise Android SDK via with method and provide:
- API Key,
-Application name
-Application instance.

To get Client Api Key, please sign in to your Synerise account and visit https://app.synerise.com/api/.

Then, generate new Api Key for Client audience.

In your Application sub-class:

public class App extends MultiDexApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        initSynerise();
    }
    private void initSynerise() {
        String syneriseClientApiKey = getString(R.string.synerise_clientool/api_key);
        String appId = getString(R.string.app_name);
        
        Synerise.settings.tracker.autoTracking.trackMode = FINE;
        Synerise.settings.tracker.setMinimumBatchSize(10);
        Synerise.settings.tracker.setMaximumBatchSize(100);
        Synerise.settings.tracker.setAutoFlushTimeout(5000);
        Synerise.settings.injector.automatic = false;
        Synerise.settings.tracker.locationAutomatic = true;
        
        Synerise.Builder.with(this, syneriseClientApiKey, appId)
                        .notificationIcon(R.drawable.notification_icon)
                        .notificationIconColor(ContextCompat.getColor(this, R.color.amaranth))
                        .syneriseDebugMode(true)
                        .pushRegistrationRequired(this)
                        .locationUpdateRequired(this)
                        .notificationDefaultChannelId("your-channel-id")
                        .notificationDefaultChannelName("your-channel-name")
                        .notificationHighPriorityChannelId("your-high-channel-id")
                        .notificationHighPriorityChannelName("your-high-channel-name")
                        .baseUrl("http://your-base-url.com/")
                        .customClientConfig(new CustomClientAuthConfig("http://your-base-url.com/"))
                        .build();
    }
}

and in your /values strings file (e.g. strings.xml):

<resources>

    <string name="app_name" translatable="false">Your GREAT application name</string>
    <string name="synerise_client_api_key" translatable="false">EF1AD0E0-532B-6AEE-6010-DEDC78F6E155</string> <!-- replace with valid client api key -->

    ...

</resources>

All the initialization options:

For your convenience, Synerise.Builder makes it possible to configure SDK behavior depending on your needs!

Let’s dive into some configurable functionalities:

  1. .notificationIcon(@DrawableRes int) - if you’re using campaign banners or push messages, it is recommended to pass your custom notification icon. This icon is presented as a small notification icon. Note, that required icon must be a drawable resource (not mipmap) due to Android O adaptive icons restrictions.
    When you send campaign banners/walkthrough and your phone is off, Firebase will use firebase default icon. You should set it in your android manifest.
  2. .syneriseDebugMode(boolean) - simple flag may be provided in order to enable full network traffic logs. It is not recommended to use debug mode in release version of your app. Debug mode is disabled by default.
  3. .trackerTrackMode(TrackMode) - sets proper mode for view tracking. See Tracker section below.
  4. Synerise.settings.tracker.setMinimumBatchSize(int); - sets minimum number of events in queue required to send them. Default value: 10
  5. Synerise.settings.tracker.setMaximumBatchSize(int); - sets maximum number of events, which may be sent in a single batch. Default value: 100
  6. Synerise.settings.tracker.setAutoFlushTimeout(int); - sets time required to elapse before event’s queue will attempt to be sent. Default value: 5000 ms
  7. Synerise.settings.injector.automatic = boolean; - simple flag may be provided to enable automatic mode in injector. See Injector section for more information.
  8. .pushRegistrationRequired(OnRegisterForPushListener) - Synerise SDK may request you to register client for push notifications. This callback is called at after client signs in, signs up or deletes account.
  9. .locationUpdateRequired(OnLocationUpdateListener) - this callback is called on demand via push notification, so it may be called at any point of time.
  10. Synerise.settings.tracker.locationAutomatic = boolean; - to obtain user location and send location event automatically.
  11. .notificationDefaultChannelId(String) - sets id of Push Notification Channel. For more info please check Injector section below.
  12. .notificationDefaultChannelName(String) - sets name of Push Notification Channel. For more info please check Injector section below.
  13. .notificationHighPriorityChannelId(String) - sets id of High Priority Push Notification Channel. For more info please check Injector section below.
  14. .notificationHighPriorityChannelName(String) - sets name of High Priority Push Notification Channel. For more info please check Injector section below.
  15. .baseUrl(String) - you can provide your custom base URL to use your own API.
  16. .customClientConfig(CustomClientAuthConfig) - you can also provide your custom Client Authorization Configuration. At this moment, configuration handles Base URL changes.
  17. .build() - builds Synerise SDK with provided data. Please note, that Synerise.Builder.with(..) method is mandatory and Synerise.Builder.build() method can be called only once during whole application lifecycle, so it is recommended to call this method in your Application class.

Errors

MultiDex

Sometimes MultiDex errors may occur. In that case enable MultiDex as follows (API >= 21):

defaultConfig {
    applicationId "com.your.app"
    minSdkVersion 21
    ...
    multiDexEnabled true
}

or for API < 21:

defaultConfig {
    applicationId "com.your.app"
    minSdkVersion 19
    ...
    multiDexEnabled true
}
dependencies {
    ...
    // MultiDex
    implementation 'com.android.support:multidex:1.0.3'
    ...
}
public class YourApp extends MultiDexApplication {

    @Override
    public void onCreate() {
        super.onCreate();
        ...
    }

You can find more information about MultiDex under this link: https://developer.android.com/studio/build/multidex.html

AndroidManifest Merger

Sometimes AndroidManifest Merger errors may occur. In that case paste following code in your AndroidManifest application tag.

<application
    
    tools:replace="android:theme">

Also, if your app did not ask for location permission, remove it from your app with:

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

Google Play-Services-auth

In cases you receive following error org.gradle.api.GradleException: ABORT

Please make sure you use google play services auth version 15.0.0, as newer versions cause problems with tracking features of our SDK. This is caused by conflict between libraries used by Synerise and Google and for today it’s still unsolved.

😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.