'm building a peer-to-peer mesh messaging app using MultipeerConnectivity. The app implements TTL-bounded flooding relay so messages can traverse multiple hops across devices that aren't directly connected to each other.
The core limitation I'm hitting: MPC stops browsing and advertising when the app is backgrounded, which means a node can no longer relay messages for the rest of the mesh. For the mesh to be useful in practice, nodes need to stay active as relays even when users switch to other apps.
I'm aware of the standard options:
. Background task extension (beginBackgroundTask) — only buys ~30 seconds, not a real solution
. Push notifications (APNs) — requires a server, defeats the goal of a fully offline/local mesh
. CoreBluetooth with state preservation/restoration — genuine background capability, but essentially a full rewrite of the transport layer, and BLE throughput (~100–250 kbps) would hurt larger payloads
Before committing to a CoreBluetooth rewrite, I want to make sure I'm not missing anything.
specifically questions are:
Is there any way to keep an MCNearbyServiceAdvertiser or MCNearbyServiceBrowser running in the background that I'm not aware of?
Does MCSession maintain existing connections long enough in the background to be useful for relay (i.e., does it survive past the background task expiry)?
Is Network.framework's local network discovery (NWBrowser with Bonjour) any more background-friendly than MPC's browser/advertiser?
• Has anyone successfully implemented a hybrid approach — CoreBluetooth for background discovery/signaling + a higher-bandwidth channel (WiFi Direct or Network.framework TCP) negotiated when foregrounded?
• Are there any entitlements or capabilities (e.g., AccessorySetupKit, NEAppProxyProvider, or anything in the networking extension family) that could help here that aren't commonly discussed?
The relay/routing layer, E2EE, and message dedup all sit above the transport and are transport-agnostic, so the rewrite scope is limited to the discovery and session management layer — but it's still significant.
Any experience with this pattern would be very helpful.
Topic:
App & System Services
SubTopic:
Networking
Tags:
Multipeer Connectivity
IOBluetooth
Background Tasks
0
0
32