Need some solutions regarding the PUSH Notifications . I tried different solutions from the stack but couldn't worked for me !
My issue is that when I triggered the notfication from my PHP script the notification itself get triggerred . The thingon clicking the notification i want to navigate to a New View from my app .
When the app is in the Background mode and clicking on notification does nothing with a completion handler warning , but when the app is in the active state and triggering notification does the work and it navigates to the other view Please revert for this Issue i have attached the code below.
ERROR when notifications are clicked on background mode Warning: UNUserNotificationCenter delegate received call to -userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: but the completion handler was never called.
Any help is Appreciated
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// If you are receiving a notification message while your app is in the background,
let application = UIApplication.shared
self.window = UIWindow(frame: UIScreen.main.bounds)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: "LaunchScreenViewController")
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
}
// Print full message.
print(userInfo)
print("Hello u have entered through Push notification ")
completionHandler(UIBackgroundFetchResult.newData)
}