Skip to content

Instantly share code, notes, and snippets.

@burhanaksendir
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burhanaksendir/2e84877396670533a5ba to your computer and use it in GitHub Desktop.
Save burhanaksendir/2e84877396670533a5ba to your computer and use it in GitHub Desktop.
Main View Controller
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "remoteNotificationReceiveAction:", name: "remoteNotificationReceived", object: nil)
}
func remoteNotificationReceiveAction(data: NSNotification) {
if let apsPayloadContent: AnyObject = data.userInfo as? AnyObject {
if let url: String = apsPayloadContent["imageURL"] as? String {
let notifyVC = self.storyboard?.instantiateViewControllerWithIdentifier("notify") as! NotifyViewController
notifyVC.imageURL = url
let presentingVC = UIApplication.sharedApplication().keyWindow?.rootViewController
if (presentingVC?.presentedViewController != nil) {
presentingVC?.presentedViewController?.presentViewController(notifyVC, animated: true, completion: nil)
} else {
presentingVC?.presentViewController(notifyVC, animated: true, completion: nil)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment