twilio / video-quickstart-ios

Twilio Video Quickstart for iOS
https://www.twilio.com/docs/api/video
MIT License
460 stars 178 forks source link

Broadcast extension - How to pass access tokens from the host app #476

Closed SubhajeetS closed 3 years ago

SubhajeetS commented 4 years ago

It's a question rather than an issue. I am using the replaykit example project to implement broadcasting(even in background). My host app has the twilio token (my server creates it using twilio rest apis) - now how can i pass the token and room name in extension context so that my broadcast extension can connect using that token? I am using RPSystemBroadcastPickerView as I am targeting ios >= 12

ceaglest commented 4 years ago

Hey @SubhajeetS,

This is a good question. It used to be possible to pass the information in the setup info for the broadcast. I am not sure how in iOS 12+ since a broadcast extension can be launched from outside of the app, or via RPSystemBroadcastPickerView.

I can investigate this further.

Best, Chris

SubhajeetS commented 4 years ago

Thank you for your prompt reply. I was wondering if there is a way to achieve screen sharing (even from background) without using RPSystemBroadcastPickerView. My container and host app are the same. I commented the code for using RPSystemBroadcastPickerView and fallback to the default startBroadcast method - but it lets me share just the app. Screen sharing pauses when it goes to background.

roupen commented 4 years ago

@SubhajeetS I ended up accomplishing this with App Groups and UserDefaults. So in my broadcast extension this is the code:

let userDefaults = UserDefaults(suiteName: "APP_GROUP.broadcast")
        self.twilioRoomId = userDefaults?.string(forKey: "twilioRoomId")!
        self.twilioScreenToken = userDefaults?.string(forKey: "twilioScreenToken")!
ceaglest commented 4 years ago

Hey @roupen,

Thanks for the suggestion! I think NSUserDefaults would be fine for exchanging Room names but I wouldn't advise storing access tokens there because it is isn't secure.

Apps in the same access group can share items in the keychain. This might be the best way to securely exchange data between an application and an extension if you are okay with managing the lifetime of this data yourself.

Best, Chris

piyushtank commented 3 years ago

Closing an old ticket but feel free to reopen or file another if you run into any issues.