Meine App verfügt über zwei Arten von Anfangszustand.Probleme mit der Anzeige von Push-Benachrichtigungen in iOS 10 Swift 3
- Anmeldung
- nach dem Login die Dashboard-& andere Sachen enthält.
Meine app funktioniert gut, wenn Ansicht von AppDelegate, dass ich Problem bin vor
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
}
Schalt, wenn ich Push-Benachrichtigung zu behandeln haben. I empfangenen Push-Benachrichtigung in IOS 10 in diesem Verfahren
@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)
}
Wenn i Benachrichtigung von Benachrichtigungsfach angezapft diese beiden Verfahren ausgelöst werden, während app Vordergrund oder im Hintergrund ist. Nachdem ich auf die Benachrichtigung getippt habe, muss ich eine Detailseite anzeigen. Ich habe versucht, die Detailseite so zu setzen, die ich vor
@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
}
}
}
}
Jedes Mal, wenn ich, dass die App abstürzt tun in didFinishLaunchingWithOptions Methode tat. Wie man das überwindet. Bitte helfen Sie. Danke im Voraus.
auf welcher Zeile stürzt Ihre App –
, wenn ich Details anzeigen als rootviewController in userNotificationCenter-Methode –
was ist Ihr Crash-Protokoll kannst du mir zeigen ? –