在app的hybrid页面需要下载一个文件, 想通过外部的浏览器下载。那么怎么通过url scheme分别打开android和ios原生的浏览器呢,并且加载目标Url地址。
url scheme
android
ios
不是原生页面,是H5页面。与app交互没问题,打开其他app也能做到,就是不知道原生浏览器的url scheme怎么写,同时也要加载url
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // 跳外部浏览器打开 if (xxx) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); Uri uri = Uri.parse(url); intent.setData(uri); mContext.startActivity(intent); return true; } return super.shouldOverrideUrlLoading(view, url); } - (BOOL)webView:(UIWebView *)_webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { if (didShowURL) { //Do not jump to URL when returning to app didShowURL = 0; return NO; } if (didLoad) { //Do not jump to URL when view first loads return YES; } didShowURL = 1; [[UIApplication sharedApplication] openURL:[request URL]]; return YES; }