0

I am developing an iOS application with notification by Google Cloud Messaging Service.(GCM).

I have been made android applications with GCM so am willing to make an iOS app of GCM notification(Not using APNS). Questions came out about APNS token and GCM Registration ID.

Question #1 every time iOS App launches it checks if APNS token changes or updates when it changed. when APNS changes, does iOS app request 'new GCM Registration ID'?

Question #2 If Question #1 is right, should I just send new GCM Registration ID to my push server?

Question #3 Does GCM Registration ID change even if APNS token has not been updated at all?

Jagat Dave
  • 1,643
  • 3
  • 23
  • 30
Jade Lee
  • 69
  • 2
  • 8

1 Answers1

1

Question #1 every time iOS App launches it checks if APNS token changes or updates when it changed. when APNS changes, does iOS app request 'new GCM Registration ID'?

Based from this documentation, when GCM registration token refresh is initiated from server side, the client app must handle a tokenRefreshed message with the GCM registration client/server handshake.

Question #2 If Question #1 is right, should I just send new GCM Registration ID to my push server?

Device tokens can change, so your app needs to reregister every time it is launched and pass the received token back to your server. Check this related SO question.

Question #3 Does GCM Registration ID change even if APNS token has not been updated at all?

According to this SO question, the registration ID will not change when token hs not been updated. "The only known cause for registration ID change is the old bug of apps getting unregistered automatically if they receive a message while getting upgraded. Until this bug is fixed apps still need to call register() after upgrade, and so far the registration ID may change in this case. Calling unregister() explicitly usually changes the registration ID too."

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
  • Thanks for answer. I put some code in registrationHandler to check if registration ID changed. I figured out that 'onTokenRefresh()' also calls registrationHandler. With your question I don't need to handle with APNS token any more if I use GCM on iOS. Am I right? @abielita – Jade Lee Mar 29 '16 at 15:23
  • @JadeLee: "With your question I don't need to handle with APNS token any more if I use GCM on iOS. Am I right?" Umm... no. You must get an APNS token in order to register with GCM, and you must handle changes to APNS token and use it to re-register with GCM. – user102008 Mar 30 '16 at 00:21
  • @user102008: Doesn't app do anything programatically when APNS token changes? In GCM example from Google, I think that app requests new GCM registration id if APNS token changes. Otherwise where should I implement that? – Jade Lee Mar 31 '16 at 07:09
  • @JadeLee: What do you mean "app"? *You* write the app. – user102008 Mar 31 '16 at 17:33
  • @user10028: There is an iOS example from Google. In example, "func application( application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData )" might be a code which does something when APNS token changes and get new Registration ID for GCM. – Jade Lee Apr 01 '16 at 12:44