Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Messages - Development vs Distribution

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

  1. Control "Badges" for Android
  2. Send "Push Notifications" via Distribution (production) vs Development.

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

Now for #2. I already have a GCM setup and can send notifications out to all registered devices. However, sometimes I want to be able to send notifications to all user's phones, and sometimes only to "development" devices. With iOS this is distinguished by devices that have been downloaded from the App Store / Ad-Hoc environment (Distribution) and devices that have been physically plugged into a computer which complies the source onto their device (Development). Is there anything similar to this for Android?

like image 484
Jacksonkr Avatar asked May 23 '13 15:05

Jacksonkr


1 Answers

There is no difference between development and distribution in Google Cloud Messaging. All the messages are sent from your server to the same GCM endpoint. If you want to distinguish between development devices and non-development devices, you'll have to manage it on your server's DB (for each registration ID you store in your server, add a flag that says if it's a development device or not).

EDIT :

Actually there's something else you can do, though I'm not sure it's such a good idea. When the app registers to GCM, it supplies a sender ID (which is a Google API project ID). You can use two different project IDs for development release and production 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 an API key that is tied to a project ID. If you use the API key that is tied to your development project ID, only registration IDs which are tied to that project ID (i.e. they originated from devices that have the development build) will work. Sending messages with "production" registration IDs will result in MismatchSenderId error (which is similar to APNS in the way that sandbox device tokens are invalid in the production environment and vice versa). I'm not sure that's a good idea, because you don't want to rely on errors from Google for your logic. If you want to send messages only to a subset of your clients, you should manage this subset in your DB.

like image 138
Eran Avatar answered Oct 03 '22 17:10

Eran