Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. var window: UIWindow?
  2.  
  3. override init() {
  4. FIRApp.configure()
  5. FIRDatabase.database().persistenceEnabled = true
  6. }
  7.  
  8. func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
  9. // Override point for customization after application launch.
  10. let notificationTypes : UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
  11. let notificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
  12. application.registerForRemoteNotifications()
  13. application.registerUserNotificationSettings(notificationSettings)
  14.  
  15. return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
  16. }
  17.  
  18. func application(application: UIApplication,
  19. openURL url: NSURL,
  20. sourceApplication: String?,
  21. annotation: AnyObject) -> Bool {
  22. return FBSDKApplicationDelegate.sharedInstance().application(
  23. application,
  24. openURL: url,
  25. sourceApplication: sourceApplication,
  26. annotation: annotation)
  27. }
  28.  
  29. func applicationWillResignActive(application: UIApplication) {
  30. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
  31. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
  32. }
  33.  
  34. func applicationDidEnterBackground(application: UIApplication) {
  35. // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
  36. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  37. }
  38.  
  39. func applicationWillEnterForeground(application: UIApplication) {
  40. // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
  41. }
  42.  
  43. func applicationDidBecomeActive(application: UIApplication) {
  44. // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
  45. FBSDKAppEvents.activateApp()
  46. }
  47.  
  48. func applicationWillTerminate(application: UIApplication) {
  49. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  50. }
  51.  
  52. func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject],
  53. fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
  54. // If you are receiving a notification message while your app is in the background,
  55. // this callback will not be fired till the user taps on the notification launching the application.
  56. // TODO: Handle data of notification
  57.  
  58. // Print message ID.
  59. print("Message ID: (userInfo["gcm.message_id"]!)")
  60.  
  61. // Print full message.
  62. print("%@", userInfo)
  63.  
  64. completionHandler(.NoData)
  65. }
  66.  
  67.  
  68. func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
  69. print(error)
  70. print(error.description)
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement