當你已經(jīng)收到離線推送什往,此時App已經(jīng)被殺软能。此時點擊通知欄迎捺,希望App啟動后跳轉(zhuǎn)到指定頁面,改如何處理呢
1查排、需要注意破加,上面的情況,是不會走以下方法的
收到遠程推送的方法
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void)
這邊只能處理App未被Kill雹嗦,點擊通知欄范舀,取值跳相關(guān)頁面
2、正確做法是在以下App啟動方法中了罪,根據(jù)remoteNotification取到相關(guān)信息(userInfo)
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
根據(jù)UIApplication.LaunchOptionsKey.remoteNotification取到內(nèi)容锭环,再進行相關(guān)處理
if let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [AnyHashable: Any] {
//根據(jù)userInfo里相關(guān)信息,做邏輯跳轉(zhuǎn)
//如果未完成跳轉(zhuǎn)泊藕,可嘗試延遲2秒執(zhí)行跳轉(zhuǎn)方法(待初始化完成后執(zhí)行)
if let content = userInfo["data"] as? String {
// router
}
}