내 앱에는 2 가지 초기 상태가 있습니다.iOS 10에서 푸시 알림을 보는 데 문제가 있음 Swift 3
- 로그인 대시 보드 & 다른 물건을 포함 로그인 후
- . 내가 푸시 알림을 처리 할 때이 문제에 직면하고 그
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { let userDataExist = CommonUserFunction.isUserDataExist() as Bool if userDataExist == true { let homeViewController = self.window?.rootViewController?.storyboard?.instantiateViewController(withIdentifier: "HomeView") as? HomeViewController let navigationController = UINavigationController() navigationController.viewControllers = [homeViewController!] self.window!.rootViewController = navigationController } else{ let loginController = self.window?.rootViewController?.storyboard?.instantiateViewController(withIdentifier: "LoginView") as? LoginController let navigationController = UINavigationController() navigationController.viewControllers = [loginController!] self.window!.rootViewController = navigationController } self.window?.makeKeyAndVisible() return true }
처럼 AppDelegate에에서보기를 전환 할 때
내 응용 프로그램은 제대로 작동합니다. 내가 응용 프로그램 전경 또는 배경 반면 이러한 두 가지 방법이 해고 통지 트레이에서 알림을 탭하면 나는이 방법
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (_ options: UNNotificationPresentationOptions) -> Void) {
print("Handle push from foreground")
// custom code to handle push while app is in the foreground
print(notification.request.content.userInfo)
}
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping() -> Void) {
// custom code to handle push while app is in the foreground
print(response.notification.request.content.userInfo)
}
에 아이폰 OS (10)에 푸시 알림을 받았다. 알림을 탭하면 세부 정보 페이지가 표시되어야합니다. 난 내가 didFinishLaunchingWithOptions 방법
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping() -> Void) {
let pushResponse = response.notification.request.content.userInfo as NSDictionary
let rtype = pushResponse.object(forKey: "rtype") as? String
let rid = pushResponse.object(forKey: "rid") as? String
if rtype != nil {
if rtype == "5" {
if rid != nil {
let noticeDetailsViewController = self.storyboard?.instantiateViewController(withIdentifier: "NoticeDetailsView") as? NoticeDetailsController
noticeDetailsViewController!.id = rtype!
noticeDetailsViewController?.fromPush = true
let navigationController = UINavigationController()
navigationController.viewControllers = [noticeDetailsViewController!]
self.window!.rootViewController = navigationController
}
}
}
}
내가 그 응용 프로그램이 충돌 할 때마다에 이전 한 것을 같은 세부 정보 페이지를 설정했습니다. 이것을 극복하는 방법. 도와주세요. 미리 감사드립니다.
내 앱이 충돌하는 곳 –
userNotificationCenter 방법의 세부 정보보기를 rootviewController로 설정하면 –
크래시 로그 란 무엇인가요? 보여 주실 수 있어요 ? –