如何在演示之前更改远程通知的显示方式? [英] How to change how a remote notification is presented before presentation?

查看:91
本文介绍了如何在演示之前更改远程通知的显示方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在系统显示远程通知之前,应如何更改其在iOS中的显示方式?实际上,保持沉默.有时,我的应用程序已在本地取消了Firebase主题订阅,但是该取消没有及时交付给服务器.因此,当我们的应用未运行时(在后台运行或根本不运行),服务器仍会向该Firebase主题发送消息,iOS会收到该消息.

How should I change how a remote notification is presented in iOS before the system presents it? In fact, silence it. There are times where my app has canceled a Firebase topic subscription locally, but that cancellation is not delivered to the server in time. So, when our app is not running(in the background OR NOT RUNNING AT ALL), the server would still send a message to that Firebase topic and iOS will receive it.

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

My question is, how can I intercept a notification, and check whether it should be presented and silent it if needed? I need to support iOS 9 as well so UNNotificationServiceExtension does not suit my needs.

谢谢.

推荐答案

remote notifications无法拦截.

但是您想要做的事情可能是这样的:

But the thing you want to do is possible like:

  • 您将通知有效负载修改为静默推送通知
  • 您在应用程序功能的后台模式下选择Remote Notifications
  • 然后使用本地通知.当您从服务器收到远程通知时,可以决定是否显示任何本地通知.
  • You modify the notification payload to be a silent push notification
  • You opt-in the Remote Notifications in background modes of your app's capabilities
  • Then use local notifications. When you receive a remote notification from your server, you will be able to decide to show or not any local notifications.

脚注:采用这种方法时,如果用户已通过在快速应用程序切换模式下向上滑动该应用程序杀死了该应用程序,则当您收到远程通知时,您将无法在后台为应用程序获取任何回调.

Footnote: In this approach, if the user has killed the app by swiping it up in the fast app switching mode, you won't be able to get any callbacks for your app in background when you receive a remote notification.

这篇关于如何在演示之前更改远程通知的显示方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆