title: How to handle push notification in swift?
body: <p>I have an ios app where i send push using apns. I need to handle push message and if it is correct show the message. How can i realize it in swift?
  This is my code:</p>
  
  <pre><code>func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions:
      [NSObject: AnyObject]?) -&gt; Bool {
      registerForPushNotifications(application)
      return true
  }
  
  func registerForPushNotifications(application: UIApplication) {
      let notificationSettings = UIUserNotificationSettings(
          forTypes: [.Badge, .Sound, .Alert], categories: nil)
      application.registerUserNotificationSettings(notificationSettings)
  }
  
  func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
      if notificationSettings.types != .None {
          application.registerForRemoteNotifications()
      }
  }
  
  func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
      let tokenChars = UnsafePointer&lt;CChar&gt;(deviceToken.bytes)
      var tokenString = ""
  
      for i in 0..&lt;deviceToken.length {
          tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
      }
  
      print("Device Token:", tokenString)
  }
  
  func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
      print("Failed to register:", error)
  }
  
  func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
  
  
  
  }
  
  func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
  
  }
  
  func applicationDidBecomeActive(application: UIApplication) {
      UIApplication.sharedApplication().applicationIconBadgeNumber = 0
  }
  </code></pre>
  
  <p>In what function i can handle push notification there?</p>