Links
Comment on page

Share & Video Deeplinking

Customize base Shared URL

You can customize the shared URL. The feature can be used if you want the share URL to be a universal link so that when a user clicks on it, it can be opened in your application. To customize a shared URL, just provide a base URL.
Kotlin
Java
/**
* The function allows you to set the base URL and query parameters to construct
* the URL that is shared when users use the share feature.
* The custom URL should only be used, if you want to support universal link and
* handle opening of the URL in the app first before opening it in the web browser.
* @param baseUrl e.g https://example.com
*
*/
FwSDK.setBasePlayerUrl(baseUrl)
/**
* The function allows you to set the base URL and query parameters to construct
* the URL that is shared when users use the share feature.
* The custom URL should only be used, if you want to support universal link and
* handle opening of the URL in the app first before opening it in the web browser.
* @param baseUrl e.g https://example.com
*
*/
FwSDK.INSTANCE.setBasePlayerUrl(baseUrl);

Deeplinking

To handle the universal link ( shared url ) in your app, you need to add Intent-filter to the activity ( that you think should handle the intent/universal link)
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="example.com" />
</intent-filter>
When a user clicks on the shared URL, this activity will be launched. You can use the following code in the onCreate method of the activity to check if the activity is launched due to anyone clicking on the shared URL.
Kotlin
Java
val uri : Uri? = intent.data
uri?.let {
playSharedUrl = uri.scheme ?: "" in listOf(
"http",
"https"
) && uri.host == "example.com"
}
Uri uri = getIntent().getData();
if(uri != null) {
if((uri.getScheme().equals("http") || uri.getScheme().equals("https")) && (uri.getHost().equals("example.com")))
playSharedUrl = true;
}
If activity is launched due to the user clicking on the shared URL, you should initialize SDK and when initialization is complete, use 'play' method available in FwSDK to launch the player and play the shared video. Please refer to the code below.
Kotlin
Java
FwSDK.initialize(this.application, client_id, null, object : FwSDK.SdkStatusListener {
override fun currentStatus(status: SdkStatus, extra: String) {
when(status) {
SdkStatus.Initialized -> {
if(playSharedUrl) {
// parse the uri , fwplayer="xxxx" include the information
// that Firework SDK needs to play the video.
val parts = uri.toString().split("fwplayer=")
if(parts.size > 1) {
// play the video
FwSDK.play(parts[1])
}
}
}
}
}
})
FwSDK.initialize(this, clientId, userId, new FwSDK.SdkStatusListener() {
@Override
public void currentStatus(@NonNull SdkStatus sdkStatus, @NonNull String s) {
switch (sdkStatus){
case Initialized :
if(playSharedUrl){
// parse the uri , fwplayer="xxxx" include the information
// that Firework SDK needs to play the video.
String[] parts = uri.toString().split("fwplayer=");
if(parts.length >1)
FwSDK.INSTANCE.play(parts[1]);
}
break;
}
}
});