Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have a multipeer connectivity session run in the background?

I have two apps which are successfully utilising multipeer connectivity to send messages.
Currently, when the "server" app moves to the background, I tear down the session and re-establish when returning to the foreground. Now, I need to make the server app responsive (to received messages) while in the background.

By being responsive, I mean can accept an incoming message, do the processing and return an acknowledgment to the peer - no UI required. When the App returns to the foreground, the messages received while in the background will be displayed.

I've disabled the MPC teartown on background notification and found that MPC automagically disconnects the "server" from the session - so my "client" peers see the server go offline.

  • Is a background multipeer session possible? I assume it is, but can't seem to find anything definitive on how I would enable it.
  • I've not developed an app that supports background processing, so I'm looking for guidance whether an app that supports background processing will solve the problem
  • The supported background modes I've seen don't really align to multipeer - the closest I can find is "background fetch" - does it really matter?
like image 828
300baud Avatar asked Oct 21 '22 13:10

300baud


1 Answers

Well, based on responses from the Apple Dev Forums, the answer is NO. Multipeer Communications is not supported while operating in the background. For those with access, link here: Apple Dev Forum

As per apple documentation "If the app moves into the background, the framework stops advertising and browsing and disconnects any open sessions. Upon returning to the foreground, the framework automatically resumes advertising and browsing, but the developer must reestablish any closed sessions" Refer: Apple doc

like image 122
300baud Avatar answered Nov 15 '22 05:11

300baud