macOS: Notification tap routing behavior when multiple instances of the same app are running (via open -n)

We're investigating an edge case around push/local notification handling on macOS when multiple instances of the same app are running simultaneously, launched via open -n /path/to/App.app. We're aware this isn't the standard/expected usage pattern for macOS apps, which are singleton by default, but we need to understand and correctly handle this case, so any clarity here would help.

Setup: macOS app, AppKit, using NSApplicationDelegate and UNUserNotificationCenterDelegate. Two separate processes of the same app launched via open -n, each independently calling UNUserNotificationCenter.current().delegate = self and registerForRemoteNotifications() on launch.

Questions:

  • Device token : is the device token unique per device and app installation, or could two separately-running processes of the same installed app each be issued a different token? Our understanding from Apple's documentation is that the token identifies the app and device combination, not a specific process. Can you confirm this holds even in a multi-instance scenario?

  • Notification tap routing : when a notification, local or remote, is tapped and both process instances have independently registered a UNUserNotificationCenterDelegate, which instance's delegate receives userNotificationCenter didReceive withCompletionHandler? Is this deterministic, for example the most recently registered instance, or the one most recently connected to usernoted? Is it arbitrary or undefined? Or does the system only allow one instance's delegate connection to be active at a time, silently disconnecting the other?

  • Is there any documented or recommended way for an app to detect it's running as a secondary instance launched via open -n, and adjust its notification handling behavior accordingly, if relevant?

We understand this falls outside the normal supported usage pattern for macOS apps, but since the behavior isn't documented for this scenario, any insight, even confirming this is undefined behavior, would be genuinely useful for us to plan around.

Following up with a related second scenario that's part of the same investigation.

Scenario 2: Multiple installations of the same app on disk

Setup: the same bundle identifier installed at more than one path on the same Mac, for example one copy installed via a DMG at /Applications/App.app, and a separate copy installed via the Mac App Store, or a locally built development version at a different path. We understand Launch Services treats these as the same app for identification purposes, and that duplicate registrations are a known, accepted characteristic of Launch Services rather than something the system actively prevents.

Questions:

  • When a push or local notification arrives for that shared bundle identifier and the user taps it, which installation actually gets launched or brought to the foreground? Is the resolution based on something like most recently registered path, highest CFBundleVersion, most recently launched, or something else in Launch Services?

  • Is this resolution behavior documented anywhere, or should developers actively avoid this situation entirely, for example by using distinct bundle identifiers per distribution channel, the way some developers already do for App Store versus development builds?

macOS: Notification tap routing behavior when multiple instances of the same app are running (via open -n)
 
 
Q