【发布时间】:2021-07-23 12:19:56
【问题描述】:
我已经在应用程序中实现了推送通知。每当推送到来时,我都会收到以下委托方法的回调。
func application(_: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
我已经实现了以下委托方法来在应用程序处于前台时显示推送通知。
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
{
completionHandler([.alert, .badge, .sound])
}
不幸的是,它并非每次都有效。无论应用程序状态如何,我都会收到 didReceiveRemoteNotification 方法的回调。这种行为有什么特别的原因吗?我错过了什么吗?
提前致谢
【问题讨论】:
标签: ios swift apple-push-notifications