In my case, I am using both the type of Notification Push as well as Local Notification. So, Push and Local Notification is Working Properly and I have implemented code for Tap/Click on Push Notifications to Launch specific ViewController it is also working Properly. But the problem is Coming when I Handle Local Notification Click/Tap App Goes Crash. So, please give me a Solution for Both click/tap Local and Push Notification.
My Code to handle Click on Push Notification when the app is in Inactive State in AppDelegate:- DidFinishLaunching
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {` // When the app launch after user tap on notification (originally was not running / not in background)
if launchOptions != nil{
let userInfo = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification]
if userInfo != nil {
// Perform action here
let dict = userInfo as! NSDictionary
if dict.value(forKey: "gcm.notification.subtitle1") != nil
{
let Status = Global.getStringValue(dict.value(forKey: "gcm.notification.subtitle1") as AnyObject)
JumpToDesiredViewController(status: Status)
}
else
{
// JumpToDesiredViewController(status: "ToDo")
}`
return true
}
}
}