就我而言,我同时使用了通知推送和本地通知两种类型。因此,“推送和本地通知”工作正常,并且我已经实现了“在推送通知中点击/单击以启动特定ViewController的代码”,它也可以正常工作。但是,当我处理本地通知单击/点击应用程序崩溃时,问题就来了。因此,请给我同时单击/点击本地通知和推送通知的解决方案。
我的代码来处理,当应用程序处于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
}
}
}