Search code examples
iospushkit

Voip Push: Under what circumstances does didInvalidatePushTokenForType get called?


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?


Solution

  • 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