Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  2.  
  3. // Override point for customization after application launch.
  4.  
  5. let lagFreeField = UITextField()
  6. self.window?.addSubview(lagFreeField)
  7. lagFreeField.becomeFirstResponder()
  8. lagFreeField.resignFirstResponder()
  9. lagFreeField.removeFromSuperview()
  10.  
  11.  
  12. // [START register_for_notifications]
  13. if #available(iOS 10.0, *) {
  14. let authOptions : UNAuthorizationOptions = [.alert, .badge, .sound]
  15. UNUserNotificationCenter.current().requestAuthorization(
  16. options: authOptions, completionHandler: {_,_ in })
  17.  
  18. // For iOS 10 display notification (sent via APNS)
  19. UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
  20. // For iOS 10 data message (sent via FCM)
  21. FIRMessaging.messaging().remoteMessageDelegate = self as? FIRMessagingDelegate
  22.  
  23. } else {
  24. let settings = UIUserNotificationSettings(types: [.alert, .badge , .sound], categories: nil)
  25.  
  26. application.registerUserNotificationSettings(settings)
  27. application.registerForRemoteNotifications()
  28. }
  29.  
  30. application.registerForRemoteNotifications()
  31.  
  32. // [END register_for_notifications]
  33.  
  34. FIRApp.configure()
  35.  
  36. print("AppDelegate")
  37.  
  38. IQKeyboardManager.sharedManager().enable = true
  39. self.window = UIWindow(frame: UIScreen.main.bounds)
  40. let storyboard = UIStoryboard(name: "Main", bundle: nil)
  41. let tab = storyboard.instantiateViewController(withIdentifier: "TabBarController") as! UITabBarController
  42. self.window?.rootViewController = tab
  43. if Defaults.hasKey(.logged), let logged = Defaults[.logged], logged == true{
  44. APIRequest.username = Defaults[.username]!
  45. APIRequest.password = Defaults[.password]!
  46. let tab = storyboard.instantiateViewController(withIdentifier: "TabBarController") as! UITabBarController
  47. self.window?.rootViewController = tab
  48.  
  49. } else {
  50. let controller = storyboard.instantiateViewController(withIdentifier: "LoginViewController")
  51. self.window?.rootViewController = controller
  52. }
  53. self.window?.makeKeyAndVisible()
  54.  
  55. return true
  56. }
  57.  
  58. func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
  59. print("Userinfo (userInfo)")
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement