Search code examples
iphonepush-notificationgmailapple-push-notifications

How Google's Gmail app on iPhone disable notifications?


My question can seems weird, but I just realize that when I receive a push for a new mail from Gmail app and I open Gmail on a web page, the notification disappear.

Can someone explain me how this is working ?


Solution

  • This is related to this question, though it's not an exact duplicate.

    This can be implemented with Apple Push Notifications.

    Your server has to maintain for each user a list of device tokens of all the devices belonging to that user (iPhones, iPads, etc...).

    When the user reads the message on one platform (whether via a web browser or via a mobile application), you can execute some API call on your server to notify it that the user read the message.

    Then your server can send a follow-up push notification to all the devices belonging to that user with "badge"=0 (and without the "alert" and "sound" fields), and the notification will be cleared from the lock screen and app icon.