Notificaciones push iOS 10: ¿cómo funcionará la presentaciónNotificación y la respuestaReceptiva recibida?

Actualmente tengo mi aplicación configurada para recibir notifications push en ios 9 donde funciona perfectamente, pero con iOS 10 no las recibo. He revisado varias respuestas en stackoverflow y he encontrado esto:

Notificaciones push no recibidas en iOS 10, pero trabajando en iOS 9 y antes

que parece funcionar para el póster. No estoy completamente seguro de qué código debo agregar en las secciones willPresentNotification y didReceiveNotificationResponse. Si alguien tiene algún ejemplo de cómo funcionan estas secciones, será apreciado. Este es mi código relevante para manejar notifications push hasta el momento:

import UserNotifications import Whisper @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { registerForPushNotifications(application) } //MARK: Push Notification Settings func registerForPushNotifications(application: UIApplication) { //check to see if phone is updated to iOS 10 if #available(iOS 10.0, *){ UNUserNotificationCenter.currentNotificationCenter().delegate = self UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptions([.Badge, .Sound, .Alert], completionHandler: {(granted, error) in if (granted) { UIApplication.shanetworkingApplication().registerForRemoteNotifications() } else{ print("registering for push notifications unsuccessful") } }) } else{ //If user is not on iOS 10 use the old methods we've been using let notificationSettings = UIUserNotificationSettings( forTypes: [.Badge, .Sound, .Alert], categories: nil) application.registerUserNotificationSettings(notificationSettings) } } //Notification handling for iOS 10 @available(iOS 10.0, *) func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) { //Handle the notification - NOT SURE WHAT GOES HERE } @available(iOS 10.0, *) func userNotificationCenter(center: UNUserNotificationCenter, didReceiveNotificationResponse response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) { //Handle the notification -NOT SURE WHAT GOES HERE } //This is called if user selects to receive push notifications func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) { // if notificationSettings.types != .None { application.registerForRemoteNotifications() // } } func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { let tokenChars = UnsafePointer<CChar>(deviceToken.bytes) var tokenString = "" for i in 0..<deviceToken.length { tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]]) } //save device token to keychain self.deviceToken = tokenString userInfo.shanetworkingInstance.savePushNotDeviceToken(tokenString) NSUserDefaultsManager.shanetworkingManager.pushNotifications = true //register device token to api registerPushNotificationDevice(tokenString) print("Device Token:", tokenString) } func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) { print("Failed to register:", error) //save push notifications state NSUserDefaultsManager.shanetworkingManager.pushNotifications = false } //In- App push notifications func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) { if application.applicationState == .Active { let navigationController = self.window!.rootViewController as! UINavigationController let alert = [String: String]() let title = "" let body = "" // Default printout of userInfo print("All of userInfo:\n\( userInfo)\n") if let aps = userInfo["aps"] as? NSDictionary { if let alert = aps["alert"] as? NSDictionary { if let title = alert["title"] as? NSString { if let body = alert["body"] as? NSString { let announcement = Announcement(title: title as String, subtitle: body as String, image: UIImage(named: "Image")) show(shout: announcement, to: navigationController) } } } } } } } 

Para notifications remotas y locales en iOS 10, tenemos UserNotifications.framework . Para manejar la notificación hay dos methods delegates de UNUserNotificationCenterDelegate disponibles en UserNotifications.framework. Debe hacer el mismo código que está haciendo en el método didReceiveRemoteNotification para get userInfo.

Estos dos methods están disponibles para manejar userInfo de acuerdo con los requisitos de su aplicación.

 //UNUserNotificationCenterDelegate delegate methods to get userInfo @available(iOS 10.0, *) func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (_ options: UNNotificationPresentationOptions) -> Void) { //Called when a notification is delivenetworking to a foreground app. let userInfo = notification.request.content.userInfo as? NSDictionary print("\(userInfo)") } @available(iOS 10.0, *) func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { // Called to let your app know which action was selected by the user for a given notification. let userInfo = response.notification.request.content.userInfo as? NSDictionary print("\(userInfo)") }