tencent cloud

Tencent Cloud Super App as a Service

Others

PDF
Focus Mode
Font Size
Last updated: 2025-07-04 17:33:32

Process special URLs in web-view component

If the webpage displayed in the web-view component contains special URLs, such as those starting with a custom scheme like tcmpp://host/path, the host app can intercept and customize the redirections of the URLs.
To intercept URL navigation, create a class that implements the IWebViewLinkProxy API and add the ProxyService annotation:
@ProxyService(proxy = IWebViewLinkProxy.class)
public class CustomWebViewLinkProxy implements IWebViewLinkProxy {

/**
* Handle custom url loading in web-view component.
* Custom url is url with any custom scheme (scheme not network protocol such as http/https)
* @param miniContext context of mini-program
* @param url the url which is loading
* @return return true if the url loading is handled, otherwise false the web-view will handle url loading
*/
@Override
public boolean webViewCustomUrlLoading(IMiniAppContext miniContext, String url) {
Uri uri = Uri.parse(url);
if ("tcmpp".equals(uri.getScheme())) {
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
miniContext.getAttachedActivity().startActivity(intent);
return true;
}
return false;
}
}
In the implementation, the mini program context and the loaded URL are provided. If the developer handles the URL redirections and returns true, the web-view component will no longer process the URL. If false is returned, the web-view component will process the URL according to normal logic.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback