lucasferreira / react-native-webview-android

Simple React Native Android module to use Android's WebView inside your app
355 stars 158 forks source link

Open tel href #51

Open jernejrus opened 7 years ago

jernejrus commented 7 years ago

Inside the html that I am passing as source {html}, I have an badge. Clicking on it on Android, gives me a ERR_UNKNOWN_URL_SCHEME error (opens a new screen with this message). Using react native WebView I was able to catch it with onError function, which is missing here. Also it opens new call normally on iOS.

lucasferreira commented 7 years ago

Hi @jernejrus,

Did you fix this?

jernejrus commented 7 years ago

I use onNavigationStateChange and catch it there.

lucasferreira commented 7 years ago

Hi @jernejrus

Did you test this with the native RN webview component? They had the same problem with tel: and mailto: href problems?

jernejrus commented 7 years ago

Hello,

Using native RN webview works OK.

vincenthub commented 5 years ago

@lucasferreira Hi Sir,

For tel: can you add this block of code under RNWebview Class -> shouldOverrideWithResult.

I have to modify native android code to achieve it and to directly go to Dial intent and not let the (tel:) loaded in webview, that causes the ERR_UNKNOWN_URL_SCHEME. I know there is a clean solution for this but for the meantime this is my solution.

   public void shouldOverrideWithResult(RNWebView view, ReadableArray args) {
        if (!args.getBoolean(0)) {`
            if(shouldOverrideUrlLoadingUrl.startsWith("tel:")){
                Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(shouldOverrideUrlLoadingUrl));
                getModule().getActivity().startActivity(intent);
            }else{
                view.loadUrl(shouldOverrideUrlLoadingUrl);
            }

        }
    }