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

前端 未结 2 689
执念已碎
执念已碎 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.

    0 讨论(0)
  • 2021-01-13 19:52

    Since you have api key and sender id, then it will work. You need to use API key given by google in your server(or servers) to send message to Devices.

    0 讨论(0)
提交回复
热议问题