Advertisement
johnsonejezie

Appdelegate methods

Jul 21st, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 3.12 KB | None | 0 0
  1.  
  2. // Respond to URI scheme links
  3.     func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
  4.         // pass the url to the handle deep link call
  5.    
  6.         if PushIOManager.sharedInstance().open(url, sourceApplication: sourceApplication, annotation: annotation) {
  7.             return true
  8.         }
  9.         if Branch.getInstance().handleDeepLink(url) {
  10.             return true
  11.         }
  12.         // do other deep link routing for the Facebook SDK, Pinterest SDK, etc
  13.         return true
  14.     }
  15.  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  16.         PushIOManager.sharedInstance().didRegisterForRemoteNotifications(withDeviceToken: deviceToken)
  17.         if Helpers.isLoggedIn() {
  18.             guard let userInfo = GTDBClient.getLoggedInUserInfo() else { return }
  19.             PushIOManager.sharedInstance().registerUserID(userInfo.email)
  20.         }
  21.         GTMAnalytics.pushNotificationEvent(Constants.Prepermission.GTMEventCategory.OptInEventCategory, eventAction: Constants.Prepermission.GTMEventAction.TappedYes, eventLabel: GTMOptinLabel)
  22.         GTMOptinLabel = ""        
  23.     }
  24.    
  25.     func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
  26.         PushIOManager.sharedInstance().didFailToRegisterForRemoteNotificationsWithError(error)
  27.     }
  28.    
  29.     func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
  30.         PushIOManager.sharedInstance().didReceiveRemoteNotification(userInfo)
  31.         //iOS 9
  32.         guard let urlString = userInfo["p_dl"] as? String else {
  33.             return
  34.         }
  35.         var userInfoObject = userInfo
  36.         userInfoObject["branch"] = urlString
  37.         Branch.getInstance().handlePushNotification(userInfoObject)
  38.        
  39.     }
  40.    
  41.     @available(iOS 10.0, *)
  42.     func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
  43.         var userInfo = response.notification.request.content.userInfo
  44.         guard let urlString = userInfo["p_dl"] as? String else {
  45.             return
  46.         }
  47.         userInfo["branch"] = urlString
  48.         Branch.getInstance().handlePushNotification(userInfo)
  49.     }
  50.    
  51.     @available(iOS 10.0, *)
  52.     func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
  53. //        PushIOManager.sharedInstance().userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
  54.     }
  55.    
  56.     func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
  57.         PushIOManager.sharedInstance().didReceiveRemoteNotification(userInfo, fetchCompletionResult: .newData, fetchCompletionHandler: completionHandler)
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement