StackOverflow, i need your help! I've read gcm documentation here http://developer.android.com/google/gcm/adv.html and don't understand fully what means "GCM only allows a maximum of 4 different collapse keys to be used by the GCM server per device at any given time". I want to explain for myself it. I can assume that if on my phone N applications are installed (facebook, twitter, instagramm, myMail, facebook and other), there is no guarantee that when my device for example will return to online, GCM will choose collapse_key of my app. Am i right or no?? If I am right in what sense of this collapse key if there is no guarantee that it will work and that my app will receive at the right time the necessary notification? I need to point that pattern "Sync-to-load" is very preferrable for me and i want to use it, but I am afraid that problems will begin when user will be write in comments "My device come back online, but i missed all messages:(("
The limit on GCM collapse_keys is on a per app level and is not affected by what other apps the user has installed on their phone.
Related
I've been through the other threads on this issue and haven't found a solution. My case may be unusual.
I have just inherited a production mobile app (Ionic/Angular) that is available on Google Play Store and Apple App Store. I didn't have to create a new google-services.json or a new GoogleService-Info.plist file. I have access to the Firebase Console. I did have to replace the .p8 key for iOS in order to get APNs to play nicely.
I can send a single notification to a single FCM token for Android and iOS with no problem. But when our production system sends notifications they are often multiple duplicates. Additionally, we routinely send (for those subscribed) multiple but different notifications to the same device(s). For example, a user who is subscribed to topics A and B will normally get a single notification for each subscription. But right now, they'll get 3 of the same notification from A but only 1 from B (B, in this example, seems to behave normally). NOTE: the particular topic is irrlevant. The only thing that seems to matter in this case is that the first one will multiply and second is received only once.
Our server logs show only a single instance of sending any given notification despite multiples being received by devices.
I first suspected, and still do, that somehow during the "transition" of the project, somewhere in FB and Apple, there is a dangling reference to the original certs/keys/projects. I don't see how I can confirm/reject that idea. I also doubt it's the case. I need any and all suggestions because I'm out of ideas! Thanks in advance.
Just been doing a bit of research on the different ways to send/receive remote notifications and many answers suggested GCM (now FCM). From what I can understand, this seems feasible for a small scale app that can support 100 online users (free) or 10k users (paid). But I fail to see how it is feasible for a background type notification system which, to be frank, are expected of most apps these days.
Hypothetically, if an app has 1mil users, then there will need to be 1mil simultaneous connections sitting in the background for the notification to reach its user in a timely fashion.
Or am I misinterpreting the "simultaneous" part? When does it apply?
Their FAQ doesn't go into too much details here.
The limit on "simultaneous database connection" refers the usage of the database API.
To receive notifications (whether the app is in background, open, or closed doesn't matter) through FCM (or GCM is the same) your app doesn't need to keep any connection open.
The firebase SDK together with the each platform operative system will take care of that.
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 am new to android and would like to seek for advice regarding to GCM as questions below:
For the third party server, is it free to use any programming language as long as follow exactly the request format to GCM server? Is there any example to refer for using asp.net?
For the non collapsed message, GCM discard all msg if exceed 100. The maximum number 100 is for total message of the only one device OR total of pending message in the third party server?
For collapsed message so called send-to-sync, If exceed this number GCM will only keep 4 collapse keys, with no guarantees about which ones they will be. I don't really got it, can anyone further explain to me with some examples?
For the time to live, it takes advantage of concept "now" or "never", the "never" is it alerting to trigger another attempt to send the same message again?
Currently I am testing the GCM with the demo sample from here, I experienced unstable of message receiving on emulator with 2.3.3v. In other words, the message could be never reached, or delay up to 15 minutes/more, or received immediately sometimes as well. Even I tried out on jumpnote and chrome to phone apps, that is same case. Can anyone share the experiences or solutions?
Is there anyway third party to get know the results when the message arrived targeted device?
To complete the registration, the Android application sends the registration ID to the application server. This process is via GCM or our personal components like web service or POST?
For the canonical ID, how does third party server get the ID of the last registration requested by application.
Much appreciate for any reply. Thanks.
I'm implementing C2DM on my android push application, this is what google said about collapse_key:
"An arbitrary string that is used to collapse a group of like messages when the device is offline, so that only the last message gets sent to the client. This is intended to avoid sending too many messages to the phone when it comes back online. Note that since there is no guarantee of the order in which messages get sent, the "last" message may not actually be the last message sent by the application server. Required."
I was wondering what if i want to get all the push sent during the device offline, what should i have in the collapse_key and how can i do that?
I think you should then make a new/different collaps-key for every message. You could just have an integer that keeps getting bigger over time or you could just use the system time...
While CD2M was deprecreated in favor for GCM, take into account that at least GCM allows to have only 4 collapse keys
GCM allows a maximum of 4 different collapse keys to be used by the
GCM server at any given time. In other words, the GCM server can
simultaneously store 4 different send-to-sync messages, each with a
different collapse key. If you exceed this number GCM will only keep 4
collapse keys, with no guarantees about which ones they will be.