小编Jun*_*Nam的帖子

GCM 2.0在Android P中不起作用

我正在Android P中实现GCM。
但是我无法从GCM接收广播。
Android P有什么问题?
顺便说一句,在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"));
    }
}
Run Code Online (Sandbox Code Playgroud)

android push google-cloud-messaging

5
推荐指数
1
解决办法
1885
查看次数

标签 统计

android ×1

google-cloud-messaging ×1

push ×1