in FriendlyPix/AppDelegate.swift [48:92]
func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Messaging.messaging().delegate = self
if let uid = Auth.auth().currentUser?.uid {
blockedRef = database.reference(withPath: "blocked/\(uid)")
blockingRef = database.reference(withPath: "blocking/\(uid)")
observeBlocks()
}
if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: { granted, _ in
if granted {
if let uid = Auth.auth().currentUser?.uid {
self.database.reference(withPath: "people/\(uid)/notificationEnabled").setValue(true)
} else {
self.notificationGranted = true
}
}
})
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
let authUI = FUIAuth.defaultAuthUI()
authUI?.delegate = self
authUI?.tosurl = kFirebaseTermsOfService
authUI?.shouldAutoUpgradeAnonymousUsers = true
let providers: [FUIAuthProvider] = AppDelegate.euroZone ? [FUIAnonymousAuth()] : [FUIGoogleAuth(), FUIAnonymousAuth()]
// ((Auth.auth().currentUser != nil) ? [FUIGoogleAuth()] as [FUIAuthProvider] : [FUIGoogleAuth(), FUIAnonymousAuth()//, FUIFacebookAuth
//] as [FUIAuthProvider])
authUI?.providers = providers
return true
}