iOS Swift 4-在应用关闭时接收Firebase静默推送通知

时间:2019-05-28 12:11:05

标签: ios firebase push-notification firebase-cloud-messaging swift4.2

我已经使用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)
}

0 个答案:

没有答案
相关问题