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. Give the SDK’s GCM broadcast receiver the highest priority and add a GCM broadcast receiver for non-MCE notifications that will receive the non-MCE notifications.

    When a GCM message arrives, the SDK GCM broadcast receiver checks whether it has originated from the MCE server. If it was, it handles it and blocks broadcasting it to other receivers. If it did not originate from the MCE server, it does nothing and leaves it to other receivers.

    Note: If necessary, it is also possible to use multiple GCM sender IDs. When you register multiple sender IDs, separate them by commas (,).

    The following example shows the Manifest file section:

    <!-- SDK gcm broadcast receiver here with priority 999 -->
    <receiver android:name="com.ibm.mce.sdk.gcm.GcmBroadcastReceiver" android:priority="999">
    <intent-filter android:permission="com.google.android.c2dm.permission.SEND" >
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        <category android:name="com.ibm.mce.samples.gcm" />
    </intent-filter>
    <intent-filter android:permission="com.google.android.c2dm.permission.SEND" android:priority="999">
        <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
        <category android:name="com.ibm.mce.samples.gcm" />
    </intent-filter>
    </receiver>
    
    <!-- Other gcm broadcast receiver here with priority 1 which is lower that 999 -->
    <receiver android:name=".SampleGcmBroadcastReceiver" android:priority="1">
        <intent-filter android:permission="com.google.android.c2dm.permission.SEND" >
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="com.ibm.mce.samples.gcm" />
        </intent-filter>
        <intent-filter android:permission="com.google.android.c2dm.permission.SEND" android:priority="1">
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="com.ibm.mce.samples.gcm" />
        </intent-filter>
    </receiver>
    

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 *