How does Facebook Messenger clear push notifications from the lock screen if you’ve read them on desktop?

后端 未结 4 1117
面向向阳花
面向向阳花 2020-12-07 15:36

When I receive a message on Facebook I get a push notification on a lock screen (iOS). Then I read this message on desktop. Right after that this push notification disappear

4条回答
  •  我在风中等你
    2020-12-07 16:36

    Warning: I have not tried this, it's just an idea!

    In iOS 7 you could try sending a silent 'content-available' notification to the user. This would wake the app up in the background and allow you to run some code. In the background you could then do

    [[UIApplication sharedApplication] setApplicationBadgeNumber:0];
    [[UIApplication sharedApplication] setApplicationBadgeNumber:newBadgeNumber];
    

    this should clear any notifications that are in the notification centre. You could then post a local notification with the data that came through in your userInfo dictionary, and it would appear as if the old ones were replaced by the new one!

    Again, just an idea...

提交回复
热议问题