I have tried Broadcast Extension. I have added that extension via target. But, I don't know how to record when my app is in background.
Two ways I am trying to record:
Via Control center: I can see my app’s target name, after selecting that name, then I start to record by clicking Start Broadcast
, next by clicking Stop Record
, but my video not getting stored either in Camera Roll or in my app. Ref Link
: ReplayKit's RPSystemBroadcastPickerView not showing preferredExtension
Via my app: Once press Start button, recording get started, I am trying to record background from my app by clicking home button, obviously recording has been stopped. Ref Link
: https://medium.com/@giridharvc7/replaykit-screen-recording-8ee9a61dd762.
There is no "direct" way to store video in your app while it is in the background. ReplayKit version 2 allows you to get video sample buffer pieces in the app extensions that calls "Broadcast Upload Extension". When you say "Via Control center" it means that you start broadcast (not recording), and at the same time iOS finds your app-extension (not your application) and launch it, then begins send video sample buffers to the extension. On this step you need to decide what to do with these buffers.
I can propose two solutions for you:
But you need to know that broadcast extension has been designed for buffer transferring, not to store or re rendering or compress or recode buffers. Extension has a lot of limitations based on CPU time and Memory usage (±50 MB), you can try to do anything there but if it is "heavy" operation iOS will close the extension.