twilio / twilio-video-app-ios

A collaboration application built with the Twilio Video iOS SDK
Apache License 2.0
248 stars 54 forks source link

Can you guide how can I enter into the Lobby with this code? I have the token generated by my own API? How can I pass that token here and start the video ? Not clear with this code.Please help it's urgent ASAP #136

Closed abhishekthanvi8 closed 3 years ago

timrozum commented 3 years ago

Hi @abhishekthanvi8, thanks for checking out the app!

This is where the app actually fetches the Twilio access token so that the app can connect to a room.

For the community build accessTokenStore is set to an instance of CommunityTwilioAccessTokenStore. It might be easiest to replace the internals of this with something that makes a request to your API. You can also look at InternalTwilioAccessTokenStore which we use for internal testing.

You may want to make some UI changes to replace the sign in screens at launch with whatever you use for auth.

Let me know if that helps!

abhishekthanvi8 commented 3 years ago

actually I already have the token from my rest api I just want to now which particular particular method is that which I need to call and how to just enter the room I want to skip the Auth part here...so please guide which method to call. may be can you explain in some more detail I will be really grateful to you..

timrozum commented 3 years ago

You could modify this line to always use the lobbySeque to skip auth. This should get you to the lobby screen.

To set the access token you can modify this line. Or you can provide your own implementation of the access token store as described above.

abhishekthanvi8 commented 3 years ago

I have integrated this code in my app..and I have token an room type available with me what is the straight forward method where I can pass this token and room type and I am ready to go....

Also I am facing a crash on this below code when I call the launchFlow

var appInfo: AppInfo {
        AppInfo(
            appCenterAppSecret: bundle.object(forInfoDictionaryKey: "AppCenterAppSecret") as! String,
            version: bundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String,
            build: bundle.object(forInfoDictionaryKey: "CFBundleVersion") as! String,
            target: AppInfo.Target(rawValue: bundle.object(forInfoDictionaryKey: "TargetName") as! String)!
        )
    }
abhishekthanvi8 commented 3 years ago

@timrozum Can you please help me with this..It's a urgent for me

timrozum commented 3 years ago

Hi @abhishekthanvi8,

The crash may be caused by the AppCenterAppSecret key not being defined in your app's info.plist. You could either add the key as an empty string to info.plist or edit this code to just remove the appCenterAppSecret parameter.

Room type is handled by the backend and not the app. See this doc for how to configure room type with your API or the Twilio Console.

Regarding the Twilio access token, this is where it is set when we connect to a room. It sounds like you will need to modify this area of code to meet the needs of your app. Replacing the internals of CommunityTwilioAccessTokenStore may work well.

I hope this helps.

abhishekthanvi8 commented 3 years ago

I removed appCenterAppSecret from paramters now it is not crashing

Now when i run below code nothing happens LobbyViewController is not opened with below code. Please help

 var launchFlow: LaunchFlow?
            var launchFlowFactory: LaunchFlowFactory = LaunchFlowFactoryImpl()
            var launchStoresFactory: LaunchStoresFactory = LaunchStoresFactoryImpl()
            var urlOpenerFactory: URLOpenerFactory = URLOpenerFactoryImpl()
            var userActivityStoreFactory: UserActivityStoreFactory = UserActivityStoreFactoryImpl()
            var window: UIWindow?

        window = UIWindow(frame: UIScreen.main.bounds)
                   launchFlow = launchFlowFactory.makeLaunchFlow(window: window!)
                   launchFlow?.start()
timrozum commented 3 years ago

It's difficult for me to determine how this modified code is executed. Did you remove SceneDelegate support completely (the code that was further below in AppDelegate and Application Scene Manifest in info.plist)? Either way there might be an an easier way about this.

The launch sequence in this app may be more complicated than you need for a variety of reasons. This app has to support both public and internal build variants and also has some special paths to exercise specific video SDK features.

It might be easiest to start with the default AppDelegate that Xcode provides and just insert and rework the code below directly inside of AppDelegate. It should only require a little rework like skipping the sign in screen. In fact you could probably also just change what screen is the root view controller on the storyboard to avoid having to perform any segue at all.

        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        window.rootViewController = storyboard.instantiateInitialViewController()
        window.makeKeyAndVisible()

        let navigationController = window.rootViewController as! UINavigationController
        navigationController.barHideOnSwipeGestureRecognizer.isEnabled = false
        navigationController.hidesBarsOnSwipe = false

        let segueIdentifier = authStore.isSignedIn ? "lobbySegue" : signInSegueIdentifierFactory.makeSignInSegueIdentifier()
        navigationController.topViewController?.performSegue(withIdentifier: segueIdentifier, sender: self)

Sorry there is not a cleaner interface between the somewhat complex launch sequence of this app and the display of the lobby screen. That is something we can consider improving.

However, I'm hoping the above idea may help you make progress.

abhishekthanvi8 commented 3 years ago

Thanks @timrozum I was able to integrate it successfully by myself..but thanks for your precious time. :)

timrozum commented 3 years ago

That is great to hear and you're welcome!