-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Description
Issue Description
We are using WebView to open an authentication process via a third-party provider. During this process they will redirect to a custom URL scheme. This URL scheme contains a parameter that we need to intercept in the javascript code.
This would normally throw an error on iOS, but we are able to handle that by implementing onShouldStartLoadWithRequest on the WebView, retrieving the parameter and return false.
But on Android, I get the following error:
W/System.err: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=myscheme://id/615563 flg=0x10000000 }
W/System.err: at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1798)
W/System.err: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
W/System.err: at android.app.Activity.startActivityForResult(Activity.java:3917)
W/System.err: at android.app.Activity.startActivityForResult(Activity.java:3877)
W/System.err: at android.app.Activity.startActivity(Activity.java:4200)
W/System.err: at android.app.Activity.startActivity(Activity.java:4168)
W/System.err: at android.content.ContextWrapper.startActivity(ContextWrapper.java:331)
W/System.err: at com.facebook.react.views.webview.ReactWebViewManager$ReactWebViewClient.shouldOverrideUrlLoading(ReactWebViewManager.java:123)
W/System.err: at com.android.webview.chromium.WebViewContentsClientAdapter.shouldOverrideUrlLoading(WebViewContentsClientAdapter.java:331)
W/System.err: at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(AwContentsClientBridge.java:265)
W/System.err: at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err: at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err: at android.os.Looper.loop(Looper.java:148)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
As far as I understand, this should not normally throw an error on Android. But in RN 0.31 this commit for shouldOverrideUrlLoading was introduced.
Steps to Reproduce / Code Snippets
I've tested this with RN 0.33.
Load a HTML page in the WebView with the following javascript-snippet included:
<script language="javascript">
window.location = 'myscheme://id/123';
</script>Expected Results
It would be nice if we could get something similar to onShouldStartLoadWithRequest on Android. But that seems unlikely to happen following the discussion in #6478
I'd prefer it not crashing, and being able to intercept the navigation (with url/parameter).
Additional Information
- React Native version: 0.33
- Platform(s) (iOS, Android, or both?): Android
- Operating System (macOS, Linux, or Windows?): macOS