iOS you do not open a view directly (as can be done in Android ), the screen you want. This is all done in your AppDelegate , something like this:
No% of%, which is where the life cycle of your app starts as soon as it opens when you press the notification, you will have this:
if let options: NSDictionary = launchOptions {
var localNotification = options.objectForKey(UIApplicationLaunchOptionsLocalNotificationKey) as? NSDictionary
if localNotification != nil {
handleLocalNotification(application, userInfo: localNotification!)
}
}
This indicates that your application is being opened through notification and has been terminated before, so you will receive this key that exists in application:didFinishLaunchingWithOptions:
.
The launchOptions
method will perform the functions you want with the notification information:
func handleLocalNotification(application: UIApplication, userInfo: NSDictionary?) {
window?.rootViewController = viewController
}
Here you have the variable handleLocalNotification
with your notification information (if there is something) and userInfo
is your view , that initializing it will depend on how you are doing it your project, is something similar to what you have already implemented.
And the implementation of delegate viewController
, if it has not been terminated and submits to the same method we created above:
func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
handleLocalNotification(application, userInfo: notification.userInfo)
}