Every time when users logout the app must be don't receiving push notifications for that user (revoke token), and every time when users login it must be new APNs token generated, so user will not receive notifications for previous logged in users. For example now, when user logged out the app still receiving notifications even if nobody logged in back. I can't handle logout event, because user can be offline when he presses Logout button. Is it possible?
3
-
1duplicate stackoverflow.com/questions/42851474/… Messaging.messaging().deleteToken { error in if let error = error { print("❌ Error deleting FCM token: (error.localizedDescription)") } else { print("✅ FCM token deleted successfully") } }Chandaboy– Chandaboy2025-07-11 11:33:52 +00:00Commented Jul 11 at 11:33
-
You should keep a mapping of userid->token on your server. When the user logs out you remove this mapping so that there is no user mapped to the token (even though the token itself is still valid). When a user logs in, update the mapping.Paulw11– Paulw112025-07-11 20:34:11 +00:00Commented Jul 11 at 20:34
-
yes, but as I said user can logout in time when there is no internet on device, so backend will not get request. so I believe it is better to refresh token somehow when users logout alsoArtem– Artem2025-07-12 13:34:31 +00:00Commented Jul 12 at 13:34
Add a comment
|