iosswiftxcodereplaykit

Display UI (storyboard possibly) with Broadcast UI Extension


I'm a bit new to IOS programming, I'm trying to start a live broadcast using Replaykit, I've made some progress in calling the broadcast service picker view from the App and also in creating 2 extensions (Broadcast Upload Extension and Broadcast UI extension). Apparently the Broadcast UI extension should be loaded once the extension is selected from the picker view and the other receives data once broadcast begins, I've tried in the first to create a view by creating a storyboard and giving it a custom class that's the same with that of the Broadcast UI extension however when I then click on the extension from the picker view I get the immediate error The user declined application recording (not sure if I'm missing any step here), get this same error without the storyboard too, I tried print() in override func viewDidLoad() of the Broadcast UI extension view controller and got no logs in the debug area so I don't even know if it gets loaded at all.

What I need is to display simple UI that'll then call a Broadcast UI extension view controller function (func userDidFinishSetup()) that'll then begin the broadcast. I'll also accept if the broadcast can be started directly within the App without the UI, in the Replaykit docs I saw a startBroadcast function I thought could achieve this, got a broadcastInvalidSession = -5808 error which means I "attempted to start a broadcast without a prior session". Help greatly appreciated, thanks.

Broadcast UI view controller

import ReplayKit

class BroadcastSetupViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        print("WASSUP?");
    }

    // Call this method when the user has finished interacting with the view controller and a broadcast stream can start
    func userDidFinishSetup() {
        print("GET IN!!!");
        // URL of the resource where broadcast can be viewed that will be returned to the application
        let broadcastURL = URL(string:"http://apple.com/broadcast/streamID")

        // Dictionary with setup information that will be provided to broadcast extension when broadcast is started
        let setupInfo: [String : NSCoding & NSObjectProtocol] = ["broadcastName": "example" as NSCoding & NSObjectProtocol]

        // Tell ReplayKit that the extension is finished setting up and can begin broadcasting
        self.extensionContext?.completeRequest(withBroadcast: broadcastURL!, setupInfo: setupInfo)
    }

    func userDidCancelSetup() {
        let error = NSError(domain: "YouAppDomain", code: -1, userInfo: nil)
        // Tell ReplayKit that the extension was cancelled by the user
        self.extensionContext?.cancelRequest(withError: error)
    }
}


Solution

  • So I reached out to Apple technical support incident(regrettably), they suggested I add "NSExtensionMainStoryboard" to the info.plist of the broadcast UI extension similar to Greg's answer, when that didn't work I sent over my code and we found out that I also had to delete "NSExtensionPrincipalClass" key from the same place as that was preventing it from loading, after that it worked fine.