tencent cloud

All product documents
Tencent Cloud Super App as a Service
Last updated: 2024-11-21 17:34:28
Others
Last updated: 2024-11-21 17:34:28

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.

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon