0

I am trying to set up a Google App engine server endpoint that sends Google Cloud Messages to android devices. So far, the device registers using GoogleCloudMessaging.register() and sends the generated regID to the server. The server then can send a message to the regIDs it has saved. Through the log messages I can see that the regIDs are all arriving correctly, and the server is sending messages correctly. The devices though aren't getting any messages.

This is the receiver in the manifest:

<receiver
        android:name="---.app.MessageReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.permission.RECEIVE" />

            <category android:name="---.app" />
        </intent-filter>
    </receiver>

This is the code for the receiver:

public class MessageReceiver extends WakefulBroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
    Log.d("---", "RECIVED A MESSAGE!!!!!!");
    // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(),
            GCMReceiverService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);
}

}

The service never gets started, and the log message here is never shown.

Is there something I'm missing?

EDIT - these are the permissions:

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="---.app.permission.C2D_MESSAGE" />

<permission
    android:name="---.app.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
yedidyak
  • 1,964
  • 13
  • 26

2 Answers2

0

There is a working solution on SO Android GCM basic implementation

The author edited his post, so you should just take it as an example. Basically, without correct permissions set AND correct Broadcast's constructor used, android won't give a damn about messages sent to an application.

Please set your permissions and other things accordingly and try again.

There is really nice post later down the comments, way under accepted one.

Community
  • 1
  • 1
  • I've set the permissions like he has, but no luck. That example uses the deprecated GCMRegistrar, not the new GoogleCloudMessaging. – yedidyak May 10 '14 at 20:17
0

Really stupid mistake. Instead of .intent.RECIEVE in the intent filter it was .permission.RECEIVE.

yedidyak
  • 1,964
  • 13
  • 26