openwebrtc-examples icon indicating copy to clipboard operation
openwebrtc-examples copied to clipboard

How to run openwebrtc on iOS in the background

Open oney opened this issue 10 years ago • 10 comments

I have already run ios/NativeDemo app in my iPhone, it works perfectly. However, when I press home button and the app enters the background mode, the connection is closed. How to continue running openwebrtc in the background? Thanks.

oney avatar Apr 18 '15 10:04 oney

I think @stefanalund and @Rugvip can probably figure this out. It's platform specific and we need to document how on Android and iOS.

superdump avatar Apr 18 '15 10:04 superdump

iOS stops the camera when an app is put in to the background, but audio should be possible to keep alive. There's a specific background mode that needs to be enabled in the App Settings.

stefanalund avatar Apr 18 '15 10:04 stefanalund

Yes, I expect that the app keeps audio talking in the background. I add key Required background modes that has App plays audio and App provides Voice over IP services item to Info.plist. Unfortunately, it's not working. image

oney avatar Apr 18 '15 11:04 oney

It's interesting. I modify the code like this to use audio only, and when entering background mode, the app will keep audio connection. I can listen and send voice with each other.

[nativeHandler startGetCaptureSourcesForAudio:YES video:NO];

However, when entering background, iPhone won't show using audio view on the top. When I test Talky.io app, it will show like this. image

oney avatar Apr 18 '15 12:04 oney

So audio is running when in the background now?

stefanalund avatar Apr 18 '15 20:04 stefanalund

Yes, it is.

oney avatar Apr 19 '15 06:04 oney

We use OpenGL for video rendering in hybrid and native applications in case that gives any clues.

It could possibly be as simple as deregistering the nsview against the tag. And then reregistering again when coming back into focus. I think @rugvip has done something like that on Android but I'm not sure.

superdump avatar Apr 19 '15 07:04 superdump

Perhaps I should ask if display of video resumes when you resume the app.

superdump avatar Apr 19 '15 07:04 superdump

Sorry for all the questions and few answers, but did audio start working in the background when you went audio-only?

stefanalund avatar Apr 19 '15 07:04 stefanalund

Yes, it did. Audio worked in the background when the app went audio-only.

oney avatar Apr 20 '15 03:04 oney