APNS device toners combined with I / O

I have an iOS app where users can log in and out with different accounts. (These accounts are related to our Service).

I also use APNs for push notifications from my server server to the application when something in-process has happened.

The following script describes my problem:

  • User A launches the application and logs in. A device token is generated and sent to the server.
  • User A quits the application
  • User B Login to the application
  • The Backend server sends a notification to the device that "belongs" to user A. However, now user B is registered on this device. (They have the same device token).
  • User B is notified. (I. A notification is displayed on the phone, although it does not apply to the current account).

Has anyone solved a similar problem? I can think of several solutions, such as:

  • Manually updating a device token. (I do not know if this is possible)
  • Receive notification - Show it if it is logged in. However, I do not think that this is possible, since the system is responsible for showing the notification, and not for my application.
  • Change the backend so that the user can say this when he is online and offline, and does not send notifications when he is disconnected. (This solution will cause a lot of problems, and I do not think that it will work fully, so I want to avoid this).

, . , , , Facebook, , , , .

- .

FYI. Android, .

+4
2

- . .

+2

? :

  • A ( ).
  • A , .
  • APNS , . ( )
  • B , , ( ), , .

, , push- .

UIApplication.shared.unregisterForRemoteNotifications()

P.S.: Android , , .

+1

Source: https://habr.com/ru/post/1620365/


All Articles