Reputation: 2939
I have found tons of tutorials explaining Google Cloud Messaging but all seem deprecated with the new Google Cloud Messaging Api
In fact I cannot get a valid registration id using the deprecated GcmRegistrar class!
While using the new api I can get a valid registration id and use that to perform successful requests from my server to google.
I am lost as to how will I implement a Receiver in the Android App that will enable me to actually use the received messages.
I guess GCMBaseIntentService and all relevant code is now deprecated and implemented in another way
The google docs are referring to this:
<receiver android:name=".MyReceiver" 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="YOUR_PACKAGE_NAME" />
</intent-filter>
</receiver>
So how could I implement this MyReceiver?
Upvotes: 0
Views: 2154
Reputation: 2939
The answer was much simpler than I thought.
You no longer need gcm.jar nor gcm-server.jar.
No need for a special service like GCMIntentService
No need for the receiver to handle this action: com.google.android.c2dm.intent.REGISTRATION
Actually a developer now needs to implement his own BroadcastReceiver which is as simple as that:
in Scala
class MyReceiver extends BroadcastReceiver {
def onReceive(context: Context, intent: Intent) {
log log "we have received something!";
val extraString = Option(intent.getStringExtra("json label here"));
log log "the value of this json label is: " + extraString;
}
}
Upvotes: 3