forXifLess / LinkNavigator

🌊 Easy & Powerful navigation library in SwiftUI
Other
382 stars 27 forks source link

How can I navigate from push notification tap #17

Closed hankyungs closed 1 year ago

hankyungs commented 1 year ago
extension AppDelegate: UNUserNotificationCenterDelegate {
...   
    func userNotificationCenter(_ center: UNUserNotificationCenter,
                                    didReceive response: UNNotificationResponse,
                                    withCompletionHandler completionHandler: @escaping () -> Void) {

         navigator.next(["Detail"], [:], true)    // doesn't work

    }
...
}

푸쉬 알림을 탭하였을 때 진입하는 위 함수에서, 원하는 view 로 navigate 시 작동하지 않습니다. 브레이크포인트를 걸어 디버깅시, next 함수 안에서 currentActivityNavigationController.viewControllers 의 값 사이즈가 0 입니다.

In the function that is called when a push notification is tapped, the navigation to the desired view is not working. When debugging with a breakpoint, the size of currentActivityNavigationController.viewControllers is 0 inside the next function.

hankyungs commented 1 year ago

아. 문제 확인되었습니다. appDelegate 에서 navigator 를 get 할때 실수로 새로 생성해주고 있었네요. 이슈 닫겠습니다.

Ah, I see. The problem has been identified. It turns out that in the appDelegate, a new navigator was being created every time it was retrieved. I will close the issue.

interactord commented 1 year ago

궁금하시거나 어려운부분 있으시면 언제든 문의 주세요~