如何在iPhone上处理iPad上的iOS推送通知?

时间:2021-09-15 01:35:45

Let's say a user has a messages app on their iPhone and iPad. They get a new message from the server, so a push notification is sent to both their devices. Now the user picks up their iPhone and reads the message waiting in notification center. How do I now remove the message from notification center (and the app badge number) on their iPad, since it's already been read?

假设用户在iPhone和iPad上有一个消息应用程序。它们从服务器获得一个新消息,因此一个推送通知被发送到它们的两个设备。现在,用户拿起他们的iPhone,在通知中心读取等待的消息。既然已经读过了,我现在如何从他们的iPad上的通知中心(以及应用程序的章号)删除消息?

2 个解决方案

#1


6  

When the user reads the message on the iPhone (presumably after tapping on the notification or the launch icon of the app), you can execute some API call on your server to notify it that the user read the message.

当用户在iPhone上读取消息时(可能是在点击了通知或app的启动图标之后),您可以在服务器上执行一些API调用,通知它用户正在读取消息。

If you maintain in your server for each user a list of device tokens of all the devices belonging to that user, you can send a push notification to all those devices with badge count 0. This will clear the badge number on the iPad (and any other devices belonging to that user). I'm not sure whether it would remove the message from the notification center of the iPad, though.

如果您在服务器中为每个用户维护属于该用户的所有设备的设备令牌的列表,那么您可以向所有这些设备发送一个push通知,其中的badge count为0。这将清除iPad上的徽章号码(以及属于该用户的任何其他设备)。我不确定它是否会从iPad的通知中心删除消息。

#2


0  

As of iOS7, we do not have any API to control the notification center. So clearing the notification is not possible.

在iOS7中,我们没有任何API来控制通知中心。因此,不可能清除通知。

#1


6  

When the user reads the message on the iPhone (presumably after tapping on the notification or the launch icon of the app), you can execute some API call on your server to notify it that the user read the message.

当用户在iPhone上读取消息时(可能是在点击了通知或app的启动图标之后),您可以在服务器上执行一些API调用,通知它用户正在读取消息。

If you maintain in your server for each user a list of device tokens of all the devices belonging to that user, you can send a push notification to all those devices with badge count 0. This will clear the badge number on the iPad (and any other devices belonging to that user). I'm not sure whether it would remove the message from the notification center of the iPad, though.

如果您在服务器中为每个用户维护属于该用户的所有设备的设备令牌的列表,那么您可以向所有这些设备发送一个push通知,其中的badge count为0。这将清除iPad上的徽章号码(以及属于该用户的任何其他设备)。我不确定它是否会从iPad的通知中心删除消息。

#2


0  

As of iOS7, we do not have any API to control the notification center. So clearing the notification is not possible.

在iOS7中,我们没有任何API来控制通知中心。因此,不可能清除通知。