Swift3 如何在前台iOS Swift 3.0中接收推送通知?

Swift3 如何在前台iOS Swift 3.0中接收推送通知?,swift3,ios8,apple-push-notifications,Swift3,Ios8,Apple Push Notifications,我想在前台状态下显示iOS 8.0的推送通知。我正在接收后台状态的通知,但不在前台状态。可能重复@Hexfire我想在iOS 8.0的前台状态下显示推送通知,我正在接收后台状态的通知可能重复@Hexfire的+iOS10。这个问题是针对iOS8的。你问错问题了。这是另一个问题的重复你有什么解决办法吗?我面临这个问题,因为CompletionHandler(UNNotificationPresentationOptions.alert)是您所需要的。这是针对iOS10的。问题是关于iOS 8。亲爱

我想在前台状态下显示iOS 8.0的推送通知。我正在接收后台状态的通知,但不在前台状态。

可能重复@Hexfire我想在iOS 8.0的前台状态下显示推送通知,我正在接收后台状态的通知可能重复@Hexfire的+iOS10。这个问题是针对iOS8的。你问错问题了。这是另一个问题的重复你有什么解决办法吗?我面临这个问题,因为CompletionHandler(UNNotificationPresentationOptions.alert)是您所需要的。这是针对iOS10的。问题是关于iOS 8。亲爱的,你能告诉我按照我的计划我会怎么做吗code@CtanLials,因为我已经在iOS 10前台收到了我希望在iOS 8中收到的通知
extension AppDelegate: UNUserNotificationCenterDelegate {

    // Receive displayed notifications for iOS 10 devices.
    func userNotificationCenter(_ center: UNUserNotificationCenter,
                                willPresent notification: UNNotification,
                                withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {

        completionHandler(UNNotificationPresentationOptions.alert)

        //completionHandler([.alert,.badge])
        let userInfo = notification.request.content.userInfo
        if let messageID = userInfo[gcmMessageIDKey] {

        }

        // Print full message.
        print(userInfo)
        completionHandler([])
    }

    func userNotificationCenter(_ center: UNUserNotificationCenter,
                            didReceive response:UNNotificationResponse,
                            withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content.userInfo

        // Print message ID.
        if let messageID = userInfo[gcmMessageIDKey] {
            print("Message ID: \(messageID)")
        }

        // Print full message.
        print(userInfo)
        completionHandler()
    }
}