ios - 有没有办法阻止用户在从 Firebase 发送后接收推送通知?

标签 ios firebase push-notification apple-push-notifications firebase-cloud-messaging

我想知道我是否可以通过 Firebase 向用户发送多个推送通知,然后在用户在设备上看到它们之前拦截它们并允许我的应用有选择地允许通知。

这可能吗?

如果可以,我需要使用哪种方法? (来自 react-native-firebaseiOS)

最佳答案

您可以尝试使用 UNNotificationServiceExtension(iOS 10 可用)。您需要为您的项目添加一个扩展(example how to add)。

在您的扩展中实现方法 - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent *contentToDeliver))contentHandler; 之后。

它会在通知显示给用户之前调用,您可以尝试执行一些操作(例如:将一些数据保存到本地)。

请注意它仅适用于 iOS 10 rich notifications ( how to implement it with Firebase )。

附言希望对您有所帮助!

编辑:

Apple documentation写:

Override this method and use it to modify the UNNotificationContent object that was delivered with the notification.

更新:

您可以尝试从服务器发送静默推送通知,检查它并创建本地通知以在需要时显示给用户。

关于ios - 有没有办法阻止用户在从 Firebase 发送后接收推送通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44445715/

相关文章:

ios - Firebase Swift iOS - 从 child 身上获取值(value)

ios - 在没有网络连接的情况下处理 APNS 推送 token

ios - 如何拖动和关闭 View Controller ?

ios - 传输安全已阻止明文 HTTP

java - 如何从 Firebase 存储获取 URL getDownloadURL

flutter - 如何使用 Flutter (Web) 将用户名作为网站的 URL,例如 appname.com/username?

android - 是什么导致了这个堆栈跟踪? (gtalkservice & jivesoftware.smack)

android - 使用 Firebase 从网页(管理面板)向 Android 手机发送推送通知

ios - 相邻的 CAShapeLayer 抗锯齿问题

ios - ios无法从NSDictionary获取值