Alexander
Alexander

Reputation: 1288

How to prevent push notifications to app after reinstallation?

Since iOS 9 application changes apns token after reinstallation of an application. But iOS 8 and 7 doesn't do it.

How can I distinguish next situation using iOS 8 and iOS 7?

  1. User installed an app.
  2. User launched app and allowed push notifications in the app. (I getted some token)
  3. User logged in/registered. (I connected token with registered user).
  4. User deleted the app.
  5. User installed the app, launched it once and allowed push notifications. (getted the same token, )

After these actions, this unregisterd user will get notifications about some actions in his account without needs to log in. If it were a bank/finance app, it would influence the security of registered user.

How to prevent this?

Upvotes: 1

Views: 128

Answers (1)

arturdev
arturdev

Reputation: 11039

You can call
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
in
-application:didFinishLaunchingWithOptions: method. Then, when user logs in, register for remote notifications.

But anyway, if app is uninstalled and installed again, it will not receive push notifications until -registerForRemoteNotifications get called, and you must call this method ONLY after user authentication. Even if token is same as previous one, it will associated with this new user, and your server should handle that.

Upvotes: 2

Related Questions