Permalink
102 lines (75 sloc) 4.88 KB

Mobile Messaging SDK for Android

Download License

Mobile Messaging SDK is designed and developed to easily enable push notification channel in your mobile application. In almost no time of implementation you get push notification in your application and access to the features of Infobip IP Messaging Platform. The document describes library integration steps.

Requirements

  • Android Studio
  • API Level: 14 (Android 4.0 - Ice Cream Sandwich)

Quick start guide

This guide is designed to get you up and running with Mobile Messaging SDK integrated into your Android application.

  1. Prepare your Cloud Messaging credentials to get Sender ID and Server API Key.
  2. Prepare your Infobip account (https://portal.infobip.com/push/) to get your Application Code:

    1. Create new application on Infobip Push portal.
    2. Navigate to your Application where you will get the Application Code.
    3. Mark the "Available on Android" checkbox.
    4. Insert previously obtained GCM Server Key (Server API Key).

    CUP Settings

  3. Create new application in Android Studio

  4. Add dependencies to app/build.gradle

    dependencies {
        ...
        compile ('org.infobip.mobile.messaging.api:infobip-mobile-messaging-android-sdk:1.3.25@aar') {
            transitive = true;
        }
    }
  5. Add GCM Sender ID, obtained in step 1, and Infobip Application Code, obtained in step 2, to values/strings.xml resource file

    <resources>
        <string name="google_app_id">YOUR GCM SENDER</string>
        <string name="infobip_application_code">YOUR APPLICATION CODE</string>
        ...
    </resources>
  6. Add code to MainActivity#onCreate

    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import org.infobip.mobile.messaging.MobileMessaging;
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            ...
    
            new MobileMessaging.Builder(getApplication())
                            .build();
        }
    
        ...
    }

    Notice

    All required manifest components are merged to application manifest automatically by manifest merger. Please include push-related components to manifest manually if manifest merger was disabled.

    Notice

    MobileMessaging library has geofencing service disabled by default. In order to opt-in the service, follow this guide.

Mobile Messaging APIs

Events

Library generates intents on the following events as described in Event:

  • Message received - is triggered when message is received.
  • Messages sent - is triggered when messages are sent.
  • Registration acquired - is triggered when GCM registration token is received.
  • Registration created - is triggered when GCM registration token successfully stored on the registration server.
  • API communication error - is triggered on every error returned by API.
  • API validation error - is triggerred when there is an error during validation of input parameters (e.g.: invalid MSISDN).
  • Delivery reports sent - is triggered when message delivery is reported.
  • User data synced - is triggered when user data is successfully saved on the registration server.

Linking MSISDN

It is recommended that you link the Telephone number (in MSISDN format). It will give an additional opportunity to target your application users and orchestrate your campaigns with OMNI Messaging service including SMS fallback feature.

UserData userData = new UserData();
userData.setMsisdn("385911234567");
MobileMessaging.getInstance(context).syncUserData(userData);