Can I receive GCM messages from two or more GCM SENDER_ID in my app?

前端 未结 2 703
执念已碎
执念已碎 2021-01-13 19:29

I need to receive push notifications from different senders in my app. Will it work?

2条回答
  •  难免孤独
    2021-01-13 19:37

    The answer to your question is YES!

    According to GCM's official documentation your app can receive messages from multiple senders (limited to 100 different senders) and your intent code should look like the above one to work correctly.

    Intent intent = new Intent(GCMConstants.INTENT_TO_GCM_REGISTRATION);
    intent.setPackage(GSF_PACKAGE);
    intent.putExtra(GCMConstants.EXTRA_APPLICATION_PENDING_INTENT,
            PendingIntent.getBroadcast(context, 0, new Intent(), 0));
    String senderIds = "968350041068,652183961211";
    intent.putExtra(GCMConstants.EXTRA_SENDER, senderIds);
    ontext.startService(intent);
    

    Feel free to check official topic at GCM page about multiple senders.

提交回复
热议问题