currently I am using below-mentioned code
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void){
completionHandler(.alert)
let aps = notification.request.content.userInfo[AnyHashable("aps")] as! NSDictionary
let alert = aps["alert"] as! String
if alert == "Welcome to XYZ. To place order please click here"{
let stryBrd = UIStoryboard(name: "Main", bundle: nil)
let vc = stryBrd.instantiateViewController(withIdentifier: "viewController") as! viewController
self.window?.rootViewController = vc
}else{
print("false")
}
}
But in this code app is running automatically to desired view controller whereas I want it to happen only if a user taps on the notification.
Whereas it is working fine when an app is in the background. It's only happening if we are clicking on the notification
It should be the same as WhatsApp. When you are chatting with Mr ABC and miss PQR sends you a text then it will show push but won't do anything unless you tap on the push to open Miss PQR chat