Firebase currently has:
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: {_, _ in })
} else {
let settings: UIUserNotificationSettings =
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
Yours is:
print("Attempting to register APNS...")
Messaging.messaging().delegate = self
UNUserNotificationCenter.current().delegate = self
let options: UNAuthorizationOptions = [.alert, .badge, .sound]
// ask user for authorization via a popup alert
UNUserNotificationCenter.current().requestAuthorization(options: options) { (granted, err) in
if let err = err {
print("Failed to request auth:",err)
return
}
if granted{
print("Auth granted")
} else {
print("Auth denied")
}
}
application.registerForRemoteNotifications()
May I ask what the differences are between these two?