I'm implementing GCM in Android P.
But I cannot receive the broadcasting from GCM.
What's wrong in Android P?
By the way, working well in Android O.
Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.setPackage("com.google.android.gsf");
registrationIntent.putExtra("sender", sender_id);
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
public class GCMBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
String messageType = gcm.getMessageType(intent);
Log.e("GCM", "action=" + intent.getAction() + " registration_id="+intent.getStringExtra("registration_id"));
}
}
You must be using an older version of GCM.
Upgrade to GCM 11 or higher. (The latest is 15.0.1: com.google.android.gms:play-services-gcm:15.0.1), or even better, migrate to FCM. (GCM is now deprecated)
the documentation states ...
As of April 10, 2018, Google has deprecated GCM. The GCM server and client APIs are deprecated and will be removed as soon as April 11, 2019. Migrate GCM apps to Firebase Cloud Messaging (FCM), which inherits the reliable and scalable GCM infrastructure, plus many new features. See the migration guide to learn more.
therefore, you might (sooner or later) have to migrate to FCM
.
since recently, there's also Firebase In-App Messaging.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With