Android messaging - development and distribution

Forgive me for not knowing the correct Android terminology. I come from the iOS background, so I'm trying to learn how to do two things correctly in the Android world.

  • Android Controls
  • Send "Push Notifications" via Distribution (production) vs Development .

Fortunately, I found the answer to # 1, which should use Status Bar Notifications thanks to this question .

Now for # 2. I already have GCM setup and you can send notifications to all registered devices. However, sometimes I want to be able to send notifications to all user phones, and sometimes only to โ€œdevelopment devicesโ€. In iOS, this is different for devices that were downloaded from the App Store / Ad-Hoc ( Distribution ) environment and devices that were physically connected to a computer that matches the source on their device ( Development ). Is there something similar for Android?

+6
source share
1 answer

Google Cloud Messaging makes no difference between development and distribution. All messages are sent from your server to the same GCM endpoint. If you want to distinguish between development devices and non-development devices, you will need to manage it on your server database (for each registration identifier that you store on your server, add a flag that says if this is a development device or not).

EDIT:

There is actually something else you can do, although I'm not sure this is such a good idea. When an application registers with GCM, it provides a sender ID (which is the Google API project ID ). You can use two different project IDs for development release and release. The registration IDs returned by the registration process are tied to the project ID . Now, when you send a GCM message from your server, you send it using the API key attached to the project ID . If you use the API key associated with your project ID development, only those registration IDs that are associated with this project ID will work (i.e., they are created on devices that have a development design). Sending messages using "production" registration IDs will result in a MismatchSenderId error (which is similar to APNS in that isolated desktop tokens are invalid in the production environment and vice versa). I'm not sure if this is a good idea because you do not want to rely on Google bugs for your logic. If you want to send messages only to a subset of your clients, you must manage this subset in your database.

+7
source

Source: https://habr.com/ru/post/945692/


All Articles