Keep network connection from interrupting on iOS multitasking switch

Hi,

I’m using RPC calls to update game objects between client and server. I want this to continue to happen even though the user used iOS multitasking to switch to another app.

I found this thread for starting pointers.

By default, in AppController.mm applicationWillResignActive is called which in turn invokes UnityPause(true) which ultimately causes the network connection to drop. I have to reestablish the connection to the server when the app regains focus.

I commented out the pausing and this will keep the networking from dropping but it ceases to transmit networking data. I guess this is because of the RPC calls being hooked to the run loop. I’m using Update() for the RPC calls which is called once per rendered frame. Is there a method in MonoBehaviour that is called even though nothing is rendered, which I could use for RPC instead?

In short: What you want to do is not possible, when you switch to another app on iOS the old running app gets put into a some sort of sleep mode. You can’t maintain a network connection when this happens. You need to re-establish the network connection when the app starts again.