sorry for my bad English.
i am developing an Android application which include chat functionality. i am planning to upload two versions on Google play. one is lite version and one is pro. i am using GCM to include chat functionality.
i want to ask is it better to upload two versions of app to market instead of one application with in-app purchase. and if i upload two apps then how to differentiate those applications to use different GCM Id's.
i know it not a programming question but i need help on it.
any suggestion.
I'm not sure how to answer the first part of your question (two apps vs. one app).
As for the second part, if you upload two applications, you can either use the same sender ID to register to GCM for the two apps, or use a different sender ID to register each app to GCM. Either way, if you install both apps on the same device, each would get a different Registration ID from GCM.
When sending a GCM message from your server to the apps, you would have to either use the same API key (if you used the same sender ID in the registration to GCM) or different API keys (if you used different sender IDs).
Related
My setup consists of two android apps, that use the same backend. I was sending push notifications based on the deviceID, meaning if you installed both apps on the same device, the listener of app 1 would listen also to notifications intended for app 2, and hell would break loose.
I would like to know if Firebase can support this type of project.
So, does one Firebase project generates one Token per device per app, or only one Token per device?
If the latest, any tips on how to get this working?
Thanks in advance.
A registration (FCM) token corresponds to an app instance. AFAIK, different apps (unique by package name) should produce different tokens when getToken() is called regardless if it's using the same Firebase Project.
However, the usual (best?) practice is to have a separate project for every different app, then handle the multiple senders for each app.
Is GCM the only way for push notifications in android? And is it advisable over other methods (if there are any)?
So let's say my app from a device registers on GCM. Is it the app itself which is assosciated with the device that registers itself, or the user and his email id that register? If my user switches devices in future, will the same 'registration token' work for him ? Or in a similar scenario if a user with another g-mail id registers to my app from the same device, do i push notifications to the same device with 2 different registration tokens?
Extending to what i asked in 2, suppose a single user has his g-mail id working on my app on different devices. Does GCM push the notification to all those devices, or only one of them? And if one, then how does it prioritize?
No, there are other push notification services in Android, like Parse. However, it is strongly recommended to use the default push notification service that is present in any Android device that has Google Play Store, because that reduces battery usage. If you are pushing your app somewhere else though, like Amazon Store, keep in mind that Kindle Fire does not comply with this and doesn't have Google Play Services -- at least as far as I know.
The registration token is very volatile and is not bound at all to an email. Actually, sometimes the same device may get a new GCM ID out of the blue. There are many tutorials on GCM's best practices, but Google's is the best way to start. What you should do to prevent problems is store the GCM id of your device in your database, so you can always know which ID is currently associated to your device. GCM may give you new IDs for no reason, so always parse its response properly and store the new ID it may provide, linking it to the device.
GCM doesn't really care which Google account is your app using. That means you can register as many devices as you want with the same account. You have to manage to which devices you push notifications, because the ID is managed by device.
Be careful: there's been some changes with the API lately, so a lot of unnoficial tutorials you find on the internet may point to deprecated methods.
There are other ways of sending notifications, Tokodu and RabbitMQ for example. I wont go over if X is better than Y, since it's not allowed on StackOverflow.
A unique device token is generated for the device, how you use this device token is totally up to you. You can make it unique for the user by, for example, implementing a login system, so that the device token is created and stored in a database (together with the user information). Let's say if two different users uses your application on a shared device, they can both receive notifications on the same device if you allow them to. It depends on your own implementation.
This again depends on how you chose to implement the GCM features on your client and server side. For example, you can choose to store device tokens for each and every device the user has installed the app on, or you can store the latest device token so that notifications are only sent to one of the user's devices.
I hope this helps clear some things up.
Besides good answers above, if you need a push notification solution for a working environment without Internet access, I suggest SignalR of Microsoft, which has already supported Android and Java (you can find out more at GitHub).
Hope this helps little!
I have a question concerning Google Cloud Messaging.
When I install the same app, on two different google android devices with same google account - then both will register themselves in gcm. i am storing their regId on server.
but what happens when I send to one of the regid a message - will the second get the message too? -will one of the regid be canonical? (because of same google account on device like the other - or are they treated completely different?)
What happens when I send to one of the regid a message - will the second get the message too?
Well, no. This is because GCM not only takes into account just the Google account that you use on your phone but also identifies the particular device and the particular app you are running on it. GCM id is unique for a any given app on any given device. That is how the cloud identifies which device to push notifications to. So even if you sign in to two different devices with the same account, both will register with different keys. You use this key to identify the individual device/app.
Go to the official documentation on this to get the full info.
Sounds like you want to use User Notifications. The docs are pretty straightforward. Basically you'll need to do some work on the server side to map multiple registration ids to one "notification_key" then you use this key when pushing to Google.
Google handles pushing to the multiple devices and will even do some nice syncing type things for you.
I am trying to use google cloud messaging service. I want to use it with a few different applications. I need to get a registration ID, but will i have to get a different registration ID for each of my different applications?
In GCM every application is one of the project. So on same device with different application you will get the different registration ID. for more info go to http://developer.android.com/guide/google/gcm/gcm.html
I have an Android application that uses C2DM. I am creating another application derived from it. Currently, Google don't support C2DM, they moved to GCM.
But I want to use the C2DM for the derived app still. Is it possible to add multiple packages that can be notified via C2DM in the manifest?
You're confused. A single server can notify multiple apps, the C2DM/GCM rules don't prohibit that.
The apps would have different package IDs, but the notification generating code on the server does not need to know them. All the server needs to know is a registration ID. Which the app obtains, and somehow transmits to the server.
The app needs to provide an API Key (GCM) or Google account (C2DM) at registration time to subscribe to notifications. But not vice versa, the server does not need to authenticate against packages.
If the notification protocol varies from one app to another, you need to communicate the supported protocol along with the reg ID to the server.