I already imported
import UserNotifications
and connected delegate:
UNUserNotificationCenterDelegate
and set delegates as self:
UNUserNotificationCenter.currentNotificationCenter().delegate = self
FIRMessaging.messaging().remoteMessageDelegate = self
and finally I have these functions:
@available(iOS 10.0, *)
func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) {
//Handle the notification
print("User Info = ",notification.request.content.userInfo)
completionHandler([.Alert, .Badge, .Sound])
}
@available(iOS 10.0, *)
func userNotificationCenter(center: UNUserNotificationCenter, didReceiveNotificationResponse response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) {
//Handle the notification
print("User Info = ",response.notification.request.content.userInfo)
completionHandler()
}
but I do not get on my log any prints when I'm testing on a real device and in the background mode.
What is the problem?
internal func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
print(userInfo)
// Print message ID.
print("Message ID: \(userInfo["gcm.message_id"]!)")
}
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject],
fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
// Print message ID.
print("Message ID: \(userInfo["gcm.message_id"]!)")
// Print full message.
print(userInfo)
}