iOS推送通知基于密钥禁用/启用

问题描述:

  1. 只是想知道在收到推送通知时是否有任何方法可以禁用/启用它.

  1. Just wondering whether there is any way to disable/enable a push notification when it is received.

例如:-当我收到推送通知时,我首先在应用程序中检查是否已在通知设置中启用或禁用了通知.

For e.g :- When i receive a push notification then i first check in my app whether in notification setting i have enabled or disabled the notification.

还可以有多个通知设置,例如

There can also be multiple notification settings like

  • 禁用朋友请求通知
  • 禁用消息通知

因此,在发送通知时,可以通过任何方式附加notificationType,例如用于好友请求或消息传递.

So while sending a notification is there any way to append notificationType like if its for friend request or messaging.

然后在应用程序中检查通知类型及其相应设置后,显示或丢弃该通知.

Then after checking the notification type and its corresponding setting in the app, showing or discarding the notification.

您不能仅在客户端本身实现此目的.因为一旦通知到达,它将由iOS处理并显示在通知中心(或根据用户设置的任何其他类型).应用程序将无法获取通知信息,除非它正在运行.

You can't achieve this just in client side itself. Because once notification arrives it is handled by iOS and displayed in notification centre (or any other type as per user setting). App will not get the notification info, unless it is running.

您可以在客户端中将此设置作为设置,并与服务器同步以在推送通知之前在服务器上进行检查.

You can have this as settings in Client and sync it with server to have a check there before pushing the notifications.