來這里辆沦,了解很多問題瓦戚,發(fā)掘更多紫谷。
?????? 傳送門->Have-a-problem??????
??????:以下內(nèi)容來自于傳送門鏈接??????
我目前的處理
- APP未啟動(dòng)
- APP已啟動(dòng)轿亮,在后臺(tái)
- iOS10點(diǎn)擊推送
需要注意
iOS10 應(yīng)用在前臺(tái)的時(shí)候刊驴,推送通知會(huì)顯示姿搜,所以可以直接點(diǎn)擊,iOS10 以下的系統(tǒng)捆憎,我們目前先忽略的呢舅柜,如果有需要實(shí)現(xiàn)的可以自己定制就可以了,或者有一個(gè)第三方的哦躲惰,下面給出傳送門
??????EBForeNotification??????
放大招(示例代碼)
先說下:我的這個(gè)方法比較簡(jiǎn)單致份,如果你有更好的,希望可以分享下哦础拨。
iOS10系統(tǒng)之前
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
// 極光
JPUSHService.handleRemoteNotification(userInfo)
completionHandler(.newData)
// 這邊判斷應(yīng)用是否在 前臺(tái) 注意是不等于 .active
if application.applicationState != .active {
// 跳轉(zhuǎn)到固定頁面
pushNoticeViewController()
}
}
iOS10系統(tǒng)
@available(iOS 10.0, *)
func jpushNotificationCenter(_ center: UNUserNotificationCenter!, didReceive response: UNNotificationResponse!, withCompletionHandler completionHandler: (() -> Void)!) {
if response.notification.request.trigger is UNPushNotificationTrigger {
JPUSHService.handleRemoteNotification(response.notification.request.content.userInfo)
}
// 跳轉(zhuǎn)到固定頁面
pushNoticeViewController()
completionHandler()
}
跳轉(zhuǎn)固定頁面
func pushNoticeViewController() {
let noticeVC = SXNoticeListViewController()
let tabBarController: UITabBarViewController? = (self.window?.rootViewController as? UITabBarViewController)
if tabBarController != nil {
if (tabBarController?.selectedViewController?.childViewControllers.last) is SXNoticeListViewController {
((tabBarController?.selectedViewController?.childViewControllers.last) as! SXNoticeListViewController).tableView.mj_header.beginRefreshing()
}else{
(tabBarController?.selectedViewController?.childViewControllers.last)?.pushVC(noticeVC)
}
}
}
注意
以上內(nèi)容為個(gè)人整理氮块,如果有問題有出入或者你有更好的解決方法,還請(qǐng)賜教哦诡宗,感謝雇锡。
我的郵箱 coderjianfeng@foxmail.com ?????? github傳送門