I'm trying to create application for Android and iOS and I want to use push notification on both the application. I'm going to have a server app that will be sending the notification.
What I'm trying to figure out is how we can store the device of the user so I'll know which service need to be used APNS or GCM.
One of the directions is to get the phone type to be set by the app and store this information on the server side, but what happens if the user changes his phone from iOS to Android, need to involve data storage of the user and collect information for every user, not covers scenario when user has Android tablet and iOS phone.
Make it more generic and dispatch the notification to both services APNS and GCM at the same time, one of them will return error?
Would love to hear what is the best practice for such scenarios?
Both Android and iOS requires the device to contact their respective push message provider (GCM or APNs) to receive a special string (which I will call the identifier), that uniquely identifies a specific app on a specific device. In GCM this is called the device ID, while APNs calls it a device token.
Google Cloud Messaging is a free service introduced by Google to send push notifications to users' device and to send message from users' device to server (GCM). GCM enables developers to transfer data from servers to both Android and iOS apps.
Google Cloud Messaging (GCM) was a mobile notification service developed by Google that enables third-party application developers to send notification data or information from developer-run servers to applications that target the Google Android Operating System, as well as applications or extensions developed for the ...
FCM is the new version of GCM under the Firebase brand. It inherits GCM's core infrastructure to make sure we continue to deliver messages reliably on Android, iOS and Chrome. Show activity on this post. FCM is the new version of GCM under the Firebase brand.
It is very simple to implement APNS and GCM:
Like and iOS device is sending this information on your server (backend) you can use this JSON format-
{"token":"abcdedfgehik2bd3d3ff3sffssdff","os":"iOS","userid":34}
For android device it will be -
{"token":"erydnfbdbdjskd76ndjs7nnshdjs","os":"Android","userid":35}
By this you can identify the OS of device, as well as user information and unique token which will be used for sending push notification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With