2

The documentation for didInvalidatePushTokenForType says its optional to implement and also says this

This method is invoked if a previously provided push token is no longer valid for use. No action is necessary to request registration. This feedback can be used to update an app's server to no longer send push notifications of the specified type to this device.

Why on earth therefore would somebody not want to implement this? If the token is no longer valid then a server will never be able to send Voip pushes to that device again, so doesn't the app on the handset want to know as soon as possible if its invalided so it can send a new token to the server?

I've been trying to search for info and use of didInvalidatePushTokenForType() but it seems everybody just copy and pastes this method into their source code because everybody else has copy and pasted it. But nobody seems to ever do anything with it. But seems to like it should be a vitally important method to make use of, so why does nobody apparently? When would the token become invalid?

Gruntcakes
  • 37,738
  • 44
  • 184
  • 378
  • Did you checked https://github.com/twilio/voice-quickstart-objc/issues/49 and https://stackoverflow.com/questions/45323827/method-didinvalidatepushtokenfortype-is-not-calling-on-token-expired-using-twili – Hasya Oct 30 '17 at 10:24
  • @hasay. Thanks for the links. But the person asking those questions seems to have confused the Twillo access token and the iOS's push kit token. didInvalidatePushTokenForType() is associated with the push kit token. They created a Twillo access token with an expiration time then wondered why didInvalidatePushTokenForType() wasn't called. But didInvalidatePushTokenForType() is nothing to do with the Twillo access token. Or am I not understanding something? – Gruntcakes Oct 30 '17 at 15:06
  • @hasay. Hi. I have a couple of more Voip questions with a bounty if you know the answer: https://stackoverflow.com/questions/46983246/possible-to-use-voip-push-functionality-only-without-voip-messaging-calls https://stackoverflow.com/questions/46981293/how-can-an-app-determine-if-its-being-launched-from-a-terminated-state-due-to-vo – Gruntcakes Oct 30 '17 at 16:01

1 Answers1

1

Thanks for the asking great question.

1) When would the token become invalid?

  • If we are update app from the App Store then APNS token doesn't change.

  • reinstalling the OS or Update OS or Reset iOS device then APNS token does change(Upgrade or downgrade OS).

  • Device token Invalidated or expired after 2 Years.

  • iOS9 and later device token changes if I reinstall an app.(As per my experience and Knowledge).

  • Download app from App Store then run your code using X-Code in this case device token will change.

2) Important of didInvalidatePushTokenForType() or Why? didInvalidatePushTokenForType() is optional

Let's clarify about didInvalidatePushTokenForType() method.

Once token got changed then called didInvalidatePushTokenForType() and didUpdatePushCredentials() method, So all code is placed in didUpdatePushCredentials() instead of didInvalidatePushTokenForType().

That's why Developer doesn't give important to didUpdatePushCredentials() method.

Find Reference from Here

Hitesh Surani
  • 12,733
  • 6
  • 54
  • 65
  • If the APNS token gets invalidated when the OS is updated, then what happens if the server sends a voip push to the app before the app has yet run after the OS was updated? If the token is now invalid the server will not know that, and the app hasn't yet run so it cannot detect it is invalid and send the new one to the server. – Gruntcakes Oct 30 '17 at 21:32
  • Obviously app doesn't get any notification with old APNS Token. App is start receiving notification after APNS token got update to server. – Hitesh Surani Oct 31 '17 at 05:37
  • That's my point. If for all the situations when the token can change, the app can't be running, then how can this method ever get called? – Gruntcakes Oct 31 '17 at 14:44
  • @Gruntcakes There is no alternative to overcome above issue. Also there is rare case(Device token Invalidated or expired after 2 Years) to reproduce this issue. Apple team also tried to overcome this issue after iOS 9 – Hitesh Surani Nov 01 '17 at 05:42