Firebase FCM push notifications are not being displayed on my iPhone X. I have tried using firebase messaging 2.0.7 with FirebaseInstanceID 2.0.0, 2.0.6, and 2.0.7 none have worked. I get the fcmtoken on the first app install and thats it. I am running ios 11.2.1 using swift 4 xcode 9.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
UINavigationBar.appearance().barTintColor = .white
UINavigationBar.appearance().tintColor = UIColor(red:0.93, green:0.22, blue:0.29, alpha:1.0)
attemptNotificationRegistration(application: application) }
override init() {
super.init()
FirebaseApp.configure()
Database.database().isPersistenceEnabled = true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("Registered for notif: ", deviceToken)
}
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
print("Registered with FCM with token:", fcmToken)
}
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert)
}
private func attemptNotificationRegistration(application: UIApplication) {
print("Attempting to register APNS...")
Messaging.messaging().delegate = self
UNUserNotificationCenter.current().delegate = self
let options: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(options: options) { (granted, error) in
if let error = error {
alerts().errorAlert(title: "Error", message: error.localizedDescription, duration: 0)
return
}
if granted {
print("Auth granted.")
} else {
print("Auth denied")
}
}
application.registerForRemoteNotifications()
}