Last active
November 28, 2019 10:38
-
-
Save MSavisko/85e39a0eb97fb2d783a4b8d2367936bd to your computer and use it in GitHub Desktop.
AppDelegate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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