APNS:如果应用程序被强制退出,则接收静默远程通知
APNS: Receive silent Remote Notification if app was force quit
我正在拼命寻找一种方法来在用户强制退出他的应用程序时接收静默远程通知。
我刚才已经试验过了。
唯一的方法是删除 content-available
标志。但后来它不再是一个无声的通知。主要用例是将附加内容下载到远程通知,然后才依次安排本地通知。
随着新的 UNNotification
框架的推出,他们还引入了新的 Notification Service Extension
,它提供了一种优雅的方式来下载与远程通知相对应的内容。
但是当应用程序被强制关闭时,仍然没有办法对静默通知做同样的事情。还是我错过了什么?
PS:可能是重复的,但其他线程不尊重Notification Service Extension
。
应用强制关闭时。 AppDelegate 方法:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
}
不会叫。但是,如果您的 json 有效负载包含 aps
您将看到即时消息,在您滑动(或单击通知)后将调用方法。
您可以查看 google
并找到 table 不同的静音和正常状态以及它们在其他 Application State
中的工作
终于找到了本地化的答案,也在这里讨论:
Change language of alert in banner of Push Notification
我还结合使用了新的 Notification Service Extension,以便在发送通知之前更改内容。
我正在拼命寻找一种方法来在用户强制退出他的应用程序时接收静默远程通知。
我刚才已经试验过了。
唯一的方法是删除 content-available
标志。但后来它不再是一个无声的通知。主要用例是将附加内容下载到远程通知,然后才依次安排本地通知。
随着新的 UNNotification
框架的推出,他们还引入了新的 Notification Service Extension
,它提供了一种优雅的方式来下载与远程通知相对应的内容。
但是当应用程序被强制关闭时,仍然没有办法对静默通知做同样的事情。还是我错过了什么?
PS:可能是重复的,但其他线程不尊重Notification Service Extension
。
应用强制关闭时。 AppDelegate 方法:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
}
不会叫。但是,如果您的 json 有效负载包含 aps
您将看到即时消息,在您滑动(或单击通知)后将调用方法。
您可以查看 google
并找到 table 不同的静音和正常状态以及它们在其他 Application State
终于找到了本地化的答案,也在这里讨论: Change language of alert in banner of Push Notification
我还结合使用了新的 Notification Service Extension,以便在发送通知之前更改内容。