• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    미해결

알림후 클릭시 이동 문제

19.05.24 00:03 작성 조회수 158

0

AppDelegate.swift

 

 

    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response : UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {

        print("userNotificationCenter 2")

        if response.notification.request.identifier == "testIdentifier" {

            print("handling notification with the identifier 'testIdentifer'")

        }

        

        if let notification = response.notification.request.content.userInfo as? [String:AnyObject]{

            print (notification as Any)

            

            let message = parseRemoteNotification(notification: notification)

            print(message!)

            

            let seq = parseOrderSeq(notification: notification)

            print(seq!)

          

            var loginVC : UIViewController?

            loginVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "LoginViewController") as! LoginViewController

            

            let appDelegate = UIApplication.shared.delegate as! AppDelegate

            appDelegate.window?.rootViewController = loginVC

        }

        completionHandler()

    }


 

console log

2019-05-23 15:14:41.282374+0900 bossapp[38816:10485392] Warning: Attempt to present <UIAlertController: 0x105007200> on <bossapp.LoginViewController: 0x103526eb0> whose view is not in the window hierarchy!

하면서 구현이 안되고 그냥 바로 원래 되던 메인으로 가네요. 어떻게 구현 하면 좋을까요?!

답변 1

답변을 작성해보세요.

0

안녕하세요

AppDelegate.swift

에서 직접 화면전환은 안될겁니다.

처음으로 진입하는 VC에서 화면전환할 수 있도록 코드를 구성하면 해결될걸로 보입니다.