Skip to content

Instantly share code, notes, and snippets.

@bossly
Last active July 24, 2020 10:53
Show Gist options
  • Save bossly/18da40edc6a3e746d0627cf3314adb69 to your computer and use it in GitHub Desktop.
Save bossly/18da40edc6a3e746d0627cf3314adb69 to your computer and use it in GitHub Desktop.
APN configure for Firebase Cloud Messangers
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// CONFIGURE PUSH NOTIFICATION
let authOptions : UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(
options: authOptions,
completionHandler: {_,_ in })
UNUserNotificationCenter.current().delegate = self
application.registerForRemoteNotifications() // here your alert with Permission will appear
// CONFIGURE FIREBASE PROJECT
FirebaseApp.configure()
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment