iosreplaykit

How to programatically stop a ReplayKit 2 system broadcast without RPSystemBroadcastPickerView


I am trying to implement a broadcast upload extension and I want the user to be able to click a button in my app to stop the broadcast.

As far as I can tell from the docs, the only ways to stop a system broadcast are:

However, I was trying the screen sharing feature on Facebook Messenger today and they are somehow bypassing the system UI (to stop the stream only). When I click the stop button, the screen sharing stops immediately and doesn't show either the system UI or the error popup

How are they doing this? My best guess is that they somehow get a valid RPBroadcastController object but I can't figure out how.


Solution

  • Ended up figuring it out.

    You basically just need to pass nil to finishBroadcastWithError. It'll throw a warning because the error is not nullable but you can quiet it with this:

    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wnonnull"
        [self finishBroadcastWithError:nil];
    #pragma clang diagnostic pop