GithubHelp home page GithubHelp logo

isabella232 / android-emarsys-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from emarsys/android-emarsys-sdk

0.0 0.0 0.0 5.05 MB

License: Mozilla Public License 2.0

Kotlin 79.36% Java 20.58% Shell 0.06%

android-emarsys-sdk's Introduction

build

Contents

What is the Emarsys SDK?

The Emarsys SDK enables you to use Mobile Engage and Predict in a very straightforward way. By incorporating the SDK in your app, we, among other things, support you in handling credentials, API calls, tracking of opens and events as well as logins and logouts in the app. The Emarsys SDK is open-sourced to enhance transparency and to remove privacy concerns. This also means that you will always be up-to-date with what we are working on.

Using the SDK is also beneficial from the product aspect: it simply makes it much easier to send push messages through your app. Please always use the latest version of the SDK in your app.

1. Setup

1.1 Sample app

We created a sample application to help in the integration and give an example. Find instructions for the build process here.

1.2 Installation with Gradle

Gradle is a build system for Android, which automates and simplifies the process of using 3rd-party libraries.

1.3 Add Gradle dependency

To integrate EmarsysSDK into your Android project using Gradle, specify it in your application's build.gradle file:

dependencies {
	implementation 'com.emarsys:emarsys-sdk:‹latest_released_version_of_emarsys-sdk›'
}

2. Requirements

  • The minimum Android version should be at least API level 21.
  • Requires compileSdkVersion 28 or higher.
  • Emarsys SDK is using AndroidX.

2.1 Using AndroidX

See Migrating to AndroidX to learn how to migrate an existing project.

If you want to use Emarsys SDK in a new project, you need to set the compile SDK to Android 9.0 (API level 28) or higher and set both of the following Android Gradle plugin flags to true in your gradle.properties file.

android.useAndroidX: When set to true, the Android plugin uses the appropriate AndroidX library instead of a Support Library. The flag is false by default if it is not specified.

android.enableJetifier: When set to true, the Android plugin automatically migrates existing third-party libraries to use AndroidX by rewriting their binaries. The flag is false by default if it is not specified.

2.2 Firebase

When the pushToken arrives we need to set it using Emarsys.Push.setPushToken(). For more information about how to obtain your FCM token please consult the Firebase integration guides:

The recommended way of using the SDK is to enable the Emarsys SDK to automatically handle setPushToken and trackMessageOpen calls for you, please register this service in your manifest:

<service android:name="com.emarsys.service.EmarsysMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

Additionally, you can set a custom notification icon, by specifying it as a meta-data between your application tag:

<meta-data
android:name="com.emarsys.mobileengage.small_notification_icon"
android:resource="@drawable/notification_icon" />

If it is needed, you can add your custom implementation to handle setPushToken and trackMessageOpen.

Java
public class MyMessagingService extends FirebaseMessagingService {

    @Override
    public void onNewToken(String token) {
        super.onNewToken(token);

        Emarsys.Push.setPushToken(token);
    }

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
    super.onMessageReceived(remoteMessage);

        boolean handledByEmarsysSDK = EmarsysMessagingServiceUtils.handleMessage(this, remoteMessage);

        if (!handledByEmarsysSDK) {
            //handle your custom push message here
            ...
        }
    }
}
Kotlin
class MyMessagingService : FirebaseMessagingService() {

    override fun onNewToken(token: String?) {
        super.onNewToken(token)
        Emarsys.Push.setPushToken(token!!)
    }
    
    override fun onMessageReceived(remoteMessage: RemoteMessage?) {
        super.onMessageReceived(remoteMessage)
        val handledByEmarsysSDK =
        EmarsysMessagingServiceUtils.handleMessage(this, remoteMessage)
        if (!handledByEmarsysSDK) {
            //handle your custom push message here
            ...
        }
    }
}

For further informations about how to use our SDK please visit our Documentation

android-emarsys-sdk's People

Contributors

davidschuppa avatar jpersson avatar kovacszsoltizsolt avatar lasori avatar lobomotiv avatar megamegax avatar pjozsef avatar rpspace avatar stoto avatar szabist avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.