Block url requests with regex prop and notify javascript about the ev…#12179
Block url requests with regex prop and notify javascript about the ev…#12179younthu wants to merge 4 commits intofacebook:masterfrom
Conversation
…ent with callback.
|
I'm not sure if adding this to the core component is the best approach. I would be OK with this functionality existing as part of a third party WebView component. With that said, I'll close this PR. |
|
@hramos Have you read the whole thread at #6478 where a feature parity proposed solution was declined by @astreet in favor of an approach similar to this PR? Thousands of developers are running into the issue of RN Android not supporting url overriding for Webviews properly and they are all led through a long maze with a disappointing ending, here. Should we not consider getting either of these two PR's or some third option that just works into the RN core a top priority? I know it is a hard problem, but consider the implementer; On a native Android app, this is a trivial issue, by simply implementing the shouldOverrideUrlLoading interface method. When adding React Native to the native app, it becomes an extremely complex issue. Not only do you have to implement the Considering the average implementer will not have a lot of native experience, asking them to do things that are harder than it would be for a native Android developer, does not seem right. The framework should do the hard work to make requirements like this trivial to implement. To make that work, I think we should do the hard work to help contributors get their valuable fixes and improvements landed. |
|
On closer inspection, the extension is easier than it used to be, using #14261 and https://github.com/cbrevik/overrideWebview/blob/master/android/app/src/main/java/com/overridewebview/CustomWebViewManager.java , but still.. |
|
In my situation, block list can't help, white list is needed, then this feature will be complicated 😅 |
motivation
An alternative solution for onShouldStartLoadWithRequest callback
It is common case to block some urls and get called back to do something else, we did it in our project with regex prop to satisfy our requirement, may others has the same requirement, so extracted the code out for all others use.
Usage