I am using Firebase FCM to send push notifications from an iOS device. The push notifications did work, until yesterday.
When I now send a push notification, everything shows successful, but nothing is received on the device.
If I send directly via a curl request, this is the response:
{"multicast_id":7815294000653973158,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1510474219556035%ca9ff0f8ca9ff0f8"}]}
If I send from the Notification dashboard on the firebase console, it shows successfully completed.
I have done the following with no success:
- Locked in pod for 'FirebaseInstanceID', "2.0.0", as per FCM Push notifications do not work on iOS 11
- Generated a new APN key on developer console and replaced the existing key on FCM setup in Firebase
- Downloaded a fresh GoogleService-Info.plist and replaced existing
- Checked that bundle id's etc all match
- Updated firebase pods to latest:
Using Firebase (4.5.0) Using FirebaseAnalytics (4.0.4) Using FirebaseAuth (4.3.1) Using FirebaseCore (4.0.10) Using FirebaseFirestore (0.9.1) Using FirebaseInstanceID (2.0.5) Using FirebaseMessaging (2.0.6)
- Turned message swizzling on and off
- Setting
Messaging.messaging().shouldEstablishDirectChannel = true
as per Firebase notifications not working in iOS 11 - Deleted this iOS app from firebase console and redone notification setup from the start
- Made sure remote notification in Capabilities are still turned on
- Restarted my devices
My setup: I call FirebaseApp.configure() in the AppDelegate file in the override init() method:
override init() {
super.init()
FirebaseApp.configure()
}
In the AppDelegate didFinishLaunchingWithOptions:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// get push notification token id for user
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()
return true
}
And then I save my token in userdefaults and persist to database later:
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
if let refreshedToken = InstanceID.instanceID().token() {
defaults.set(refreshedToken, forKey: Constant.UserDefaults.token)
print("Token generated: ", refreshedToken)
} else {
print("Could not save token becuase error with instance id token")
}
}
The token generated here I also test with curl as mentioned above and all shows successful.
Please let me know if any other info is required.
My Android application is still working as before. I am struggling to understand what could change for the iOS app in one day to cause this, or what I perhaps broke in one day:)
Any help would be greatly appreciated.