Yesterday evening, I was experimenting with Push Notifications from Firebase on my iOS application and everything was functioning correctly.
I successfully sent a notification from a Cloud Function to a specific FCM token. However, this morning, notifications are not being received using the same process.
Cloud Function
Below is the function I am using to send the notification:
function sendNotification(title: string, body: string, token: string): Promise<void> {
const message: admin.messaging.Message = {
apns: {
headers: {
'apns-priority': '10'
},
payload: {
aps: {
alert: {
title: title,
body: body,
},
sound: "default"
}
}
},
token: token
}
return admin.messaging().send(message).then(response => { console.log(`Notification response ${response}`) }).then(justVoid)
}
The `token` mentioned above is the token obtained from the InstanceId in the iOS app. After triggering this function, the Cloud Function log in the Firebase web console shows the following message:
Notification response projects/project-name/messages/0:1571998931167276%0f7d46fcf9fd7ecd
This appears to be a success message. However, despite this, the notification does not appear on the device.
iOS App
I have followed this troubleshooting guide and confirmed that the setup is correct: https://firebase.google.com/docs/cloud-messaging/ios/first-message?authuser=0
In an attempt to resolve the issue, I re-installed the app on the testing device and ensured that the following steps were completed after re-installation:
Call:
UNUserNotificationCenter.current().requestAuthorization(options:, completionHandler:)
Call:
UIApplication.shared.registerForRemoteNotifications()
Listen for updated FCM token by implementing:
func messaging(_ messaging:, didReceiveRegistrationToken fcmToken:)
Call:
InstanceID.instanceID().instanceID(handler:)
Double check that notifications are allowed for my application in the iOS settings app.
Test Notification from Console
I attempted to send a Test Notification from the Notification Composer, using the most recent FCM token for the test device. Unfortunately, this notification also failed to appear, and there was no visible feedback indicating whether it was successfully sent or not.
What could be causing this issue?
Any recommendations on how to troubleshoot and debug this problem?