Hybrid integration

    Hybrid integration


    Article summary

    Add Library

    Add the code below to build.gradle. Add combined or split packaging library to app/build.gradle.

    Combined Packaging Library

    dependencies {
        def shoplive_sdk_version = "1.5.11"
        
        // Shoplive combined packaging
        implementation "cloud.shoplive:shoplive-sdk-all:$shoplive_sdk_version" // live + shortform
    }

    Split Packaging Library

    dependencies {
        def shoplive_sdk_version = "1.5.11"
        def your_exoplayer_version = "2.19.1"
        def your_media3_version = "1.3.1"
        def shoplive_exoplayer_version = your_exoplayer_version + "." + "8"
        def shoplive_media3_version = your_media3_version + "." + "8"
        
        // Shoplive split packaging
        implementation "cloud.shoplive:shoplive-common:$shoplive_sdk_version" // must required
        implementation "cloud.shoplive:shoplive-exoplayer:$shoplive_exoplayer_version" // must required
        // When using media3. Exoplayer will be deprecated soon.
        // https://developer.android.com/guide/topics/media/media3/getting-started/migration-guide
        // implementation "cloud.shoplive:shoplive-media3:$shoplive_media3_version" 
        implementation "cloud.shoplive:shoplive-network:$shoplive_sdk_version" // must required
      
        implementation "cloud.shoplive:shoplive-short-form:$shoplive_sdk_version" // for shortform player
      
        implementation "cloud.shoplive:shoplive-sdk-core:$shoplive_sdk_version" // for live player
    }

    Web integration

    To enable Shortform service, web integration needs to be prioritized. Please refer to the following link for Shortform web integration


    Add a shortform instance to Web Activity

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        webView.settings.domStorageEnabled = true // Required
        webView.settings.javaScriptEnabled = true // Required
    
        ShopLiveShortform.connectBridgeInterface(this, webView) // Required
        ShopLiveShortform.receiveBridgeInterface(webView) // Required
        
        webView.webViewClient = object : WebViewClient() {
            ...
            // Required
            override fun doUpdateVisitedHistory(view: WebView?, url: String?, isReload: Boolean) {
                super.doUpdateVisitedHistory(view, url, isReload)
                ShopLiveShortform.updateVisitedHistory(view, url, isReload)
            }
            ...
        }
        
        // Optional
        ShopLiveShortform.setHandler(object : ShopLiveShortformFullTypeHandler() {
            override fun onEvent(command: String, payload: String?) {
                // Do something
            }
            
            override fun onError(error: ShopLiveCommonError) {
                // Do something
            }
            
            override fun onShare(activity: Activity, data: ShopLiveShortformData?, url: String?) {
                // Do something
            }
        })
    }


    What's Next