Reputation: 61880
All notifications are handled in AppDelegate
, but usually they are needed in top controller to perform some actions on current view. How can I do this?
Upvotes: 0
Views: 640
Reputation: 61880
Make your UIVIewController
conformed to protocol UIApplicationDelegate
. And then get access to the top view controller using code answered here: Get the current displaying UIViewController on the screen in AppDelegate.m.
Let's say you need to get remote notification in your top UIViewController
, then in AppDelegate
you just write:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
(UIStoryboard.topViewController() as? UIApplicationDelegate)?.application?(application, didReceiveRemoteNotification: userInfo)
}
Upvotes: 1