복붙노트

[SWIFT] 특정보기를 열고 응용 프로그램은 사용자가 아이폰 OS 스위프트 푸시 알림을 탭하면

SWIFT

특정보기를 열고 응용 프로그램은 사용자가 아이폰 OS 스위프트 푸시 알림을 탭하면

해결법


  1. 1.didFinishLaunchingWithOptions : AppDelegate에 여기에이 일을하는 단계입니다 앱을 열 수 수 있음을 각각의 ViewController에 대한 식별자를 설정 한 다음 응용 프로그램의 launchOptions 인수에 페이로드를 확인해야이 작업을 수행하려면 :

    didFinishLaunchingWithOptions : AppDelegate에 여기에이 일을하는 단계입니다 앱을 열 수 수 있음을 각각의 ViewController에 대한 식별자를 설정 한 다음 응용 프로그램의 launchOptions 인수에 페이로드를 확인해야이 작업을 수행하려면 :

    if let payload = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary, identifier = payload["identifier"] as? String {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewControllerWithIdentifier(identifier)
        window?.rootViewController = vc
    }
    

  2. 2.AppDelegate에, 당신은 (당신의 응용 프로그램에 따라 배경이나 전경에) 대리인 콜백 "didFinishLoading"또는 "didReceivePushNotification"방법을 얻을 것이다. 그 방법은 다음 보여 최상위 뷰 컨트롤러에서 현재 / 푸시하려는 특정 뷰 컨트롤러를 만듭니다 최상위 뷰 컨트롤러의 인스턴스를 얻을.

    AppDelegate에, 당신은 (당신의 응용 프로그램에 따라 배경이나 전경에) 대리인 콜백 "didFinishLoading"또는 "didReceivePushNotification"방법을 얻을 것이다. 그 방법은 다음 보여 최상위 뷰 컨트롤러에서 현재 / 푸시하려는 특정 뷰 컨트롤러를 만듭니다 최상위 뷰 컨트롤러의 인스턴스를 얻을.


  3. 3.

     UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
        if (notification)
        {
            [self application:application didReceiveRemoteNotification:(NSDictionary*)notification];
        }
    
  4. from https://stackoverflow.com/questions/33706455/open-app-in-specific-view-when-user-taps-on-push-notification-with-ios-swift by cc-by-sa and MIT license