如果用户未授予通知权限,则当应用程序位于前台时收到远程通知时,不会调用 didreceiveremotenotification
。我不想使用无声通知,因为当应用程序在后台并且用户允许通知时,我希望出现警报通知。但是当在前台时,我想自己处理通知数据,即使用户已选择退出通知。
如何实现这一目标?
编辑:我发现当用户禁用通知时不会创 build 备注册 token 。但是静默通知如何运作呢?
最佳答案
我找到了以下答案:What is difference between remote notification and silent notification in iOS?
简而言之,为了实现我想要的,我需要在 plist 的 Bacground 模式中启用远程通知。然后,即使用户选择不接收通知,我也能够注册 token 。
关于ios - 禁用通知时,未在前台调用 didreceiveremotenotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45970750/