Reputation: 1437
I'm trying to simulate GCM push notifications on my Android app using the ADB:
adb shell am broadcast -c com.MYAPPNAME -a com.google.android.c2dm.intent.RECEIVE -e data "SomeData"
And I'm getting, as far as I know, positive result:
Broadcasting: Intent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.MYAPPNAME] (has extras) }
Broadcast completed: result=-1
But unfortunately, my application doesn't get the notification on my GCMListener.
Relevant manifest:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission
android:name="com.sears.devicelab.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.sears.devicelab.permission.C2D_MESSAGE" />
.... some more xml ....
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true" >
<!-- android:permission="com.google.android.c2dm.permission.SEND" > -->
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.MYAPP" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
</intent-filter>
</receiver>
<service
android:name=".common.gcm.AppGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name=".common.gcm.GcmInstanceIDListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:name=".common.gcm.GcmRegistrationIntentService"
android:exported="false" >
</service>
GCM Listener:
public class AppGcmListenerService extends GcmListenerService {
private static final String TAG = AppGcmListenerService.class.toString();
public AppGcmListenerService() {
}
@Override
public void onMessageReceived(String from, Bundle data) {
Log.i(TAG, "Push notification has been received: " + data);
}
}
Upvotes: 5
Views: 3526