如何在演示前更改远程通知的呈现方式?

时间:2018-04-03 03:51:13

标签: ios swift firebase unusernotificationcenter remote-notifications

在系统呈现之前,我应该如何更改iOS中远程通知的显示方式?事实上,沉默它。有时我的应用已在本地取消了Firebase主题订阅,但该取消未及时传递到服务器。因此,当我们的应用程序未运行时(在后台运行或不运行),服务器仍会向Firebase主题发送消息,iOS将收到该消息。

我的问题是,如何拦截通知,并检查是否应该显示通知并在需要时将其静音?我需要支持iOS 9,因此UNNotificationServiceExtension不能满足我的需求。

感谢。

2 个答案:

答案 0 :(得分:0)

这是一个很好的问题,目前iOS没有这个问题的解决方案。

您可以在Apple指南中阅读本地和推送通知。

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/

PS:如果通过沉默意味着改变通知发出的声音,你就可以做到。 https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ModifyingNotifications.html#//apple_ref/doc/uid/TP40008194-CH16-SW1

答案 1 :(得分:-1)

remote notifications无法拦截。

但你想做的事情可能是:

  • 您将通知有效内容修改为silent push notification
  • 您选择使用应用功能的后台模式Remote Notifications
  • 然后使用local notifications。当您从服务器收到远程通知时,您将能够决定是否显示任何本地通知。

脚注:在此方法中,如果用户通过在快速应用切换模式下向上滑动来杀死应用,则在收到远程通知时,您将无法在后台获取应用的任何回调。