Skip to content

Instantly share code, notes, and snippets.

@MSavisko
Last active November 28, 2019 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MSavisko/85e39a0eb97fb2d783a4b8d2367936bd to your computer and use it in GitHub Desktop.
Save MSavisko/85e39a0eb97fb2d783a4b8d2367936bd to your computer and use it in GitHub Desktop.
AppDelegate
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if let configurationPath = Bundle.main
.path(forResource: "GoogleService-Info-Release.plist", ofType: nil),
let path = configurationPath,
let options = FirebaseOptions(contentsOfFile: path) {
FirebaseApp.configure(options: options)
}
Messaging.messaging().delegate = self
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_, _ in })
application.registerForRemoteNotifications()
return true
}
}
extension AppDelegate: MessagingDelegate {
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
print(fcmToken)
try? firebaseTokenService.save(fcmToken)
updateProvider?.updateUserTokens()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment