I’m having an issue with Firebase Cloud Messaging (FCM) where direct messages sent via the FCM token work perfectly, but notifications from Firebase Messaging Campaigns don’t reach my iOS app. Here’s what I’ve tried and confirmed so far:
Setup & What’s Working:
Direct Messages via FCM Token: These are received by the app without any issues.
Notification Permissions: All necessary permissions are granted on the device.
APNs Authentication Key: This is configured in Firebase, and the Firebase Console shows the campaign status as “Completed,” but messages don’t appear on the target device.
My Steps:
Uploaded the APNs Authentication Key in Firebase:
Opened Apple Developer Console > Certificates, Identifiers & Profiles > Keys > Registered a New Key > Checked APNs service.
Downloaded the APNs Key and uploaded it to Firebase under Project Settings > Cloud Messaging.
Firebase Console Campaign Setup:
Notification title and body are configured.
Target set to “All Users” (for testing purposes).
Message settings: sound enabled, Apple badge enabled, badge count set to 1, expiration set to 4 weeks.
Code Setup (relevant parts):
Using Firebase for authentication and data storage with Firestore.
Configured AppDelegate for Firebase, FCM, and APNs token registration.
Implemented UNUserNotificationCenterDelegate methods to show notifications when the app is in the foreground.
Observed Behavior:
The Firebase Console indicates the campaign is “Completed,” but the messages are not received on the device.
There are no errors in the Firebase Console or my Xcode logs when sending the campaign.
My AppDelegate is correctly handling the APNs token and FCM token registration.
Here’s My Code Setup in AppDelegate:
class AppDelegate: NSObject, UIApplicationDelegate, MessagingDelegate, UNUserNotificationCenterDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Messaging.messaging().delegate = self
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
if granted { print("Notification permission granted") }
}
application.registerForRemoteNotifications()
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
}
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
print("FCM Token received: \\(String(describing: fcmToken))")
}
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .badge, .sound])
}
}
Developer Forums
RSS for tagAsk questions about how to use the Apple Developer Forums. Discuss forums bugs and enhancements requests that you’ve filed via Feedback Assistant.
Post
Replies
Boosts
Views
Activity
Hi,
I'm facing an issue with Darwin notifications between two applications that share the same App Group.
Issue Description:
When the app is in the foreground (active state), the notifications are received and handled correctly.
However, when the app is in the background, notifications are not received.
What I've Tried:
Verified the App Group is correctly configured and accessible between the two applications.
Confirmed Darwin notifications are triggered and received successfully in the foreground.
Checked notification permissions and ensured all required capabilities are enabled.
Setup Details:
iOS version: iOS 11
Xcode version: 16.0
Notifications: Darwin notifications sent between apps using App Groups.
**Code Snippet : **
func startListening(name: String, callback: @escaping () -> Void) {
CFNotificationCenterAddObserver(notificationCenter,
Unmanaged.passUnretained(self).toOpaque(),
NotificationManager.notificationCallback,
name as CFString,
nil,
.deliverImmediately)
}
func sendNotification(name: String) {
CFNotificationCenterPostNotification(notificationCenter, CFNotificationName(name as CFString), nil, nil, true)
}
private static let notificationCallback: CFNotificationCallback = { center, observer, name, _, _ in
guard let observer = observer else { return }
let manager = Unmanaged.fromOpaque(observer).takeUnretainedValue()
if let name = name?.rawValue as String {
// Code added
}
}
Is there any additional configuration or specific behavior of Darwin notifications in the background that could be causing this issue?
I would greatly appreciate any insights, guidance, or references to relevant documentation.
Thank you!
Has Apple announced a specific deadline for implementing the updates on the latest app icon changes for dark, light, and tinted themes in iOS 18?