我已经使用content_available = true
实现了Firebase静默推送通知。
当应用程序被杀死或未在后台运行时,我没有得到静默推送。 当应用程序在后台或前台时,我会收到推送消息。
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Messaging.messaging().appDidReceiveMessage(userInfo)
let state : UIApplication.State = application.applicationState
switch state {
case UIApplicationState.active:
handleForgroundPush(userInfo: userInfo)
default:
handleNotification(userInfo: userInfo)
}
completionHandler(UIBackgroundFetchResult.newData)
}