Darwin notification is not receiving when the app is in background

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<NotificationManager>.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!

Answered by DTS Engineer in 816240022

iOS will not resume your app to receive a Darwin notification. If your app is suspended in the background when someone posts a notification, one of two things should happen:

  • If your app is resumed, it should receive the notification then.

  • If your app is terminated while suspended, it will never receive the notification.

When you investigate problems like this, make sure to do your testing outside of Xcode. That is, run your app from the Home screen and use logging to see what actually happened [1]. The Xcode debugger prevents your app from being suspended, which can be very confusing when you’re working on issues like this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] See Your Friend the System Log.

Facing the same issue but with iOS 18.1

I also noticed that if app is opened (after notification sent while app is in background) the notification is processed.

D o you also have the same behaviour ?

iOS will not resume your app to receive a Darwin notification. If your app is suspended in the background when someone posts a notification, one of two things should happen:

  • If your app is resumed, it should receive the notification then.

  • If your app is terminated while suspended, it will never receive the notification.

When you investigate problems like this, make sure to do your testing outside of Xcode. That is, run your app from the Home screen and use logging to see what actually happened [1]. The Xcode debugger prevents your app from being suspended, which can be very confusing when you’re working on issues like this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] See Your Friend the System Log.

Would it make sense to replace this darwin notification by a remote push notification (and trigger a background update/process) ?

Darwin notification is not receiving when the app is in background
 
 
Q