응용 프로그램이 종료 된 후 응용 프로그램이 알림 본문에서 시작되면 팝업을 열려고합니다. 나는 AppDelegate
에서 그것을하고 싶어한다. LocalNotifications
을 사용하고 있습니다. 작업 버튼을 사용하면 특정보기를 여는 방법을 알고 있지만 알림 본문을 클릭하면 내용을 여는 방법을 알지 못합니다.응용 프로그램이 종료 된 후 알림 본문에서 응용 프로그램이 시작되면 팝업을 엽니 다.
편집 : 내 솔루션은 앱이 종료되지 않은 경우에만 작동합니다.
Edit2가 :는 그것이 내가 코드에서 viewController
을 열하려고 편의상
? : 할 수있는 올바른 방법인가 실제로 나는 그것을 위해 내가 JSSAlertView
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
if let TappedNotification = launchOptions?[UIApplicationLaunchOptionsLocalNotificationKey] as? NSDictionary {
print("The notification is \(TappedNotification)")
let mainStoryboardIpad : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewControlleripad : UIViewController = mainStoryboardIpad.instantiateViewControllerWithIdentifier("Main") as UIViewController
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.rootViewController = initialViewControlleripad
self.window?.makeKeyAndVisible()
}
}
return true
를 사용하고, 경고 메시지가 필요합니다
}
어떤 상태의 앱인지 감지하려고했지만 앱이 종료되고 알림에서 열면 테스트 할 수 없습니다.
if application.applicationState == UIApplicationState.Active {
print("App already open")
} else {
print("App opened from Notification")
}
나는 else{
이 점을 추가하려고하지만 특정보기를 열 수 없습니다 :
하자 mainStoryboardIpad : UIStoryboard = UIStoryboard (이름 : "메인", 번들 : 전무)
let mainStoryboardIpad : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewControlleripad : UIViewController = mainStoryboardIpad.instantiateViewControllerWithIdentifier("Main") as UIViewController
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.rootViewController = initialViewControlleripad
self.window?.makeKeyAndVisible()
I을 알림 본문을 클릭하면 Twitter 또는 Instagram과 같은 효과를 원합니다. 하지만 제 경우에는 popover (모달)을 원합니다.
@So 난 당신이 내 코드는 지금 작동해야 올바른 이해합니다. 하지만 작동하지 않습니다. 내 편집을 확인하십시오. 맞습니까? –
application.applicationState == UIApplicationState.Active {if UIApplicationLaunchOptionsRemoteNotificationKey –
} 내가 없으면 시도했지만 여전히 작동하지 않는지 확인할 필요가 없습니다. 오 기다려. 내 초기 viewcotroller를 "Main"으로 설정해야합니까? 실제로는 초기 ATM이 아니기 때문입니다. –