Overview

Skill Level: Any

Prerequisites

Not what you’re looking for? Check out all our available tutorials for mobile app messaging here.

Step-by-step

  1. Table 1 provides a list of the permissions in the AndroidManifest.xml file, descriptions, and information about whether permissions are optional or required.

    Table 1 Permissions in AndroidManifest.xml file

    Permission Description Optional or required
    C2D_MESSAGE
    example:
    <permission android:name="com.ibm.mce.samples.gcm.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    C2D_MESSAGE is required for receiving GCM messages. Required
    c2dm.permission.RECEIVE
    example:
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    The c2dm.permission.RECEIVE permission is required for receiving GCM messages. Required
    INTERNET
    example:
    <uses-permission android:name="android.permission.INTERNET" />
    INTERNET is required for calling the MCE server. Required
    WAKE_LOCK
    example:
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    WAKE_LOCK is required for running scheduled tasks.
    For additional information about the WAKE_LOCK permission, see WAKE_LOCK following this table.
    Required
    RECEIVE_BOOT_COMPLETED
    example:
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    RECEIVE_BOOT_COMPLETED is required for performing SDK tasks on device startup. For additional information about the RECEIVE_BOOT_COMPLETED permission, see RECEIVE_BOOT_COMPLETED following this table. Required
    VIBRATE
    example:
    <uses-permission android:name="android.permission.VIBRATE" />
    VIBRATE is required for notification configuration. Required
    CALL_PHONE
    example:
    <uses-permission android:name="android.permission.CALL_PHONE" />
    CALL_PHONE is optional. It is only required when the dial action is used. Optional
    ACCESS_FINE_LOCATION
    example:
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    ACCESS_FINE_LOCATION is optional. It is only required when location services need to use GPS location. Optional
    ACCESS_COARSE_LOCATION
    example:
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    ACCESS_COARSE_LOCATION is optional. It is only required when location services need to use network location. Optional
    BLUETOOTH
    example:
    <uses-permission android:name="android.permission.BLUETOOTH" />
    BLUETOOTH is optional. It is only required when iBeacons are supported. Optional
    BLUETOOTH_ADMIN
    example:
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    BLUETOOTH_ADMIN is optional. It is only required when iBeacons are supported. Optional
    BIND_JOB_SERVICE
    example:
    <uses-permission android:name="android.permission.BIND_JOB_SERVICE" />
    BIND_JOB_SERVICE is optional. It is only required for Android 0 (and later). Optional. Required for Android 0 (and later).

    Additional information about the following permissions:

    WAKE_LOCK

    The Mobile App Messaging SDK implements a task scheduling system that conserves battery usage on users’ mobile devices. The main component of the task scheduling system is a task. Tasks are lightweight units of work that are backed by the Android IntentService. Tasks perform actions and then shutdown immediately when the work is done. Therefore, unlike some SDKs, tasks eliminate the need to keep long-running services always running in the background. Customers do not complain about apps that run all the time.

    Because tasks are background services (for example, the MCE registration task, GCM registration task, metrics task), they must function properly and complete all work. For this reason, services require a partial wake lock (CPU only). These tasks are managed automatically by the Task Framework. Tasks acquire the wake lock when the task is started and release the wake lock immediately upon finishing the task.

    Google uses a similar pattern in its Android code (for example, GcmTaskService). Google’s Android documentation describes the use case for background tasks that acquire CPU-only WakeLock in the following statement:

    One legitimate case for using a wake lock might be a background service that needs to grab a wake lock to keep the CPU running to do work while the screen is off.

    RECEIVE_BOOT_COMPLETED

    When users first open an app, the Mobile App Messaging SDK attempts to register with the Campaign Automation servers. In some cases, users might be in an area with a poor Internet connection. When this scenario occurs, the SDK must retry the registration with exponential back off (to conserve battery usage). In this case, a task is scheduled that uses the Android Alarm service to run after a time (depending on the backoff) to retry the registration. Unfortunately, if the user reboots the phone, the Alarm service removes all scheduled tasks. The SDK must know when the device starts again to reschedule the task and ensure that the registration completes successfully. Users do not receive notifications before a successful registration occurs.

    In addition to registration, Campaign Automation also send metrics to Campaign Automation servers when metrics are collected. Rescheduling the metrics tasks on boot complete ensures that Campaign Automation servers receive your app metrics in a timely manner. Metrics tasks do no work unless metrics exist that can be sent.

    For more information about ‘Start an Alarm When the Device Boots’ and the pattern that is used, see https://developer.android.com/training/scheduling/alarms.html#boot.

    By default, all alarms are canceled when a device shuts down. To prevent cancellation of alarms, you can design your application to automatically restart a repeating alarm if the user reboots the device. This step ensures that the AlarmManager continues its task without requiring the user to manually restart the alarm.

    In Mobile App Messaging SDK, the alarm task takes action only when metrics are sent and a network connection exists.

  2. Table 2 provides a list of the services in the AndroidManifest.xml file, descriptions, and information about whether services are optional or required.

    Table 2 Services in AndroidManifest.xml file

    Service or receiver Description Optional or required
    AttributesQueueConsumer
    example:
    <service android:name="com.ibm.mce.sdk.attributes.AttributesQueueConsumer" />
    AttributesQueueConsumer is required for attributes handling. Required
    EventsAlarmListener
    example:
    <service android:name="com.ibm.mce.sdk.events.EventsAlarmListener" />
    EventsAlarmListener is required for event handling. Required
    PhoneHomeIntentService
    example:
    <service android:name="com.ibm.mce.sdk.registration.PhoneHomeIntentService" />
    PhoneHomeIntentService is required to allow the client to contact the server to update state. Required
    RegistrationIntentService
    example:
    <service android:name="com.ibm.mce.sdk.registration.RegistrationIntentService" />
    RegistrationIntentService is required for SDK registration. Required
    FcmInstanceIdService
    example:
    <service android:name="com.ibm.mce.sdk.fcm.FcmInstanceIdService" />
    FcmInstanceIDService is required for FCM registration. Optional. Required if you are using FCM.
    FcmMessagingService
    example:
    <service android:name="com.ibm.mce.sdk.fcm.FcmMessagingService" />
    FcmMessagingService is required for FCM messaging. Optional. Required if you are using FCM.
    GcmReceiver
    example:
    <receiver android:name="com.google.android.gms.gcm.GcmReceiver" />
    GcmReceiver is required for GCM. Optional. Required if you are using GCM.
    GeofenceIntentService
    example:
    <service android:name="com.ibm.mce.sdk.location.GeofenceIntentService" />
    GeofenceIntentService is optional. It is used to receive geofence events. It is required only when locations are enabled and geofences are used. Optional
    InboxUpdateService
    example:
    <service android:name="com.ibm.mce.sdk.plugin.inbox.InboxUpdateService" />
    InboxUpdateService is optional. It is used for retrieving ibox updates from the MCE server. It is required only when inbox is used. Optional
    LocationEventsIntentService
    example:
    <service android:name="com.ibm.mce.sdk.location.LocationEventsIntentService" />
    LocationRetrieveService is optional. It is used to handle location events backoff. It is required only when locations are enabled. Optional
    LocationRetrieveService
    example:
    <service android:name="com.ibm.mce.sdk.location.LocationRetrieveService" />
    LocationRetrieveService is optional. It is used for retrieving the device location. It is required only when locations are enabled Optional
    LocationSyncAlarmListener
    example:
    <service android:name="com.ibm.mce.sdk.location.LocationSyncAlarmListener" />
    LocationSyncAlarmListener is optional. It is used to schedule location sync. It is required only when inbox is used. Optional
    LocationUpdateCaller
    example:
    <receiver android:name="com.ibm.mce.sdk.location.LocationUpdateCaller" />
    LocationUpdateCaller is optional. It is used to schedule location updates. It is required only when locations are enabled. Optional
    MceBluetoothScanner
    example:
    <service android:name="com.ibm.mce.sdk.beacons.MceBluetoothScanner" />
    MceBluetoothScanner is optional. It is used to run the bluetooth scan. It is required only when iBeacons is used. Optional
    MceGcmListenerService
    example:
    <service android:name="com.ibm.mce.sdk.gcm.MceGcmListenerService" android:exported="false" >
    <intent-filter>
    <action android:name="com.google.android.c2dm.intent.RECEIVE" />
    </intent-filter>
    </service>
    MceGcmListenerService is required for GCM handling. Optional. Required if you are using GCM.
    MceJobService
    example:
    <service android:name="com.ibm.mce.sdk.job.MceJobService" />
    MceJobService is used for launching a job while the app is in the foreground. It is required only for Android O (and later). Optional. Required for Android 0 (and later).
    SnoozeIntentService
    example:
    <service android:name="com.ibm.mce.sdk.plugin.snooze.SnoozeIntentService" />
    SnoozeIntentService is optional. It is required only when snooze action is used. Optional

Expected outcome

Need more help? Check out all of our available tutorials for mobile app messaging here.

Join The Discussion

Your email address will not be published. Required fields are marked *