ios - 接入点 : Receive non silent notifications if app is not running?

标签 ios xamarin xamarin.ios apple-push-notifications apns-sharp

正如我在 APNS 文档中看到的那样,如果应用程序未运行,静默通知将在 didreceiveremotenotification 中处理,但它们的优先级较低。所以有时我的 iOS 应用程序收不到静默通知。

如果应用程序未运行(不在前台,不在后台),iOS 是否显示非静默通知?非静默通知是否会触发 didreceiveremotenotification

最佳答案

对于非静音通知,

如果应用程序处于activeinactive 状态,将触发

didreceiveremototification。不是在 terminatedsuspended 状态。 在 terminatedsuspended 状态下,用户点击通知应用程序将通过调用 didFinishLaunchingWithOptionslaunchingOptions 启动将负载作为 Dictionary

如果您提供UNNotificationServiceExtension,iOS 将在收到通知时调用didReceive(_:withContentHandler:),您可以使用它来自定义远程通知的内容在交付给用户之前。 阅读:https://developer.apple.com/documentation/usernotifications/unnotificationserviceextension

如果您提供UNNotificationContentExtension,iOS 将在收到通知时调用didReceive,您可以使用它自定义加载通知内容。

阅读:https://developer.apple.com/documentation/usernotificationsui/unnotificationcontentextension

附言:

普通通知不能用作静默通知的替代/变通方法,因为您不能在应用程序终止状态下使用静默通知。

静默通知旨在将客户端应用程序与服务器上可用的更新内容同步。由于这可以在没有明确的用户交互的情况下完成,因此可以使用静默通知。

静默通知必须包含 content-available 键,并且不得包含警报、声音或角标(Badge)键。 阅读:https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html

在正常通知的情况下,除非手机上的用户设置如此,否则无法隐藏通知横幅/警报/声音。

关于ios - 接入点 : Receive non silent notifications if app is not running?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46581913/

相关文章:

c# - 如何使用 AVCaptureVideoDataOutput 避免 AVCaptureSession 中的丢帧

ios - TableView 高度无法在 IOS 中调整大小

php - 移动应用程序 - 与外部服务器通信

ios - iOS 中使用 URL 方案的应用程序间通信

c# - 错误: [feature] requires a Business (or higher) license

ios - 当链接器 "Link All"在 iOS 的 MvvmCross 中启用时,方法 ViewModel.Init 接收 null 作为参数

xamarin.ios - IBOutlets 在 Xamarin.iOS 中私有(private)的原因是什么

c# - 为 TableView 数据源添加列表而不是替换列表

ios - 查询 Parse 中可能为 nil 的值

ios - 如何在一起滚动的 UITableView 顶部添加一个 View ,但在滚动后坚持到顶部