novalagung
novalagung

Reputation: 11532

React Native - Web Socket in Background Mode

I'm developing an application using react native, I use WebSocket to communicate with the back end.

I want the socket to be active even in the background mode. I found related article here: How to handle socket connection's events when app is in background? It basically says that it's not possible.

But, I tried it locally on my simulator, by making the application goes into background mode, the socket keep receiving the data (proven by log still happening in the remote debug).

So my question is, is the socket keep active even the app goes into background mode? or it's just active because it's only on simulator (haven't tried on real device, my iphone iOS version is too old). If this happen because it's only just simulator, is there any solution except push notification?

Screenshot attached. Thanks in advance

enter image description here

Upvotes: 2

Views: 3546

Answers (1)

rckoenes
rckoenes

Reputation: 69499

iOS allows some time for connection to finish before they are killed by the OS. Max 3 minutes on iOS9 and higher using the 'Executing Finite-Length Tasks'.

Also the simulator allows more that the actual device.

You can a socket in the background if you app is VOIP app, Audio Streamer or need the connect for an accessory. If you plan to mis use on of the modes be aware that Apple will probably reject your app.

Upvotes: 5

Related Questions