Looking into the source code for both iOS and Android, it looks there is no way to prevent a WebView from loading a specific URL.
Am I missing something?
If not, we need this functionality and most probably we'll implement it in a fork of {N} and create a PR if this is something anybody else would need.
Hi @surdu,
In your case, you could use loadStartedEvent to validate the url and if needed to stop page loading while using stopLoading() method. For example:
webview.on(WebView.loadStartedEvent, (args: LoadEventData)=>{
if(args.url === "url"){
(<WebView>args.object).stopLoading();
}
})
Let me know if this helps in your case.
@tsonevn Ha! Yes, it does the trick! I didn't think of that :)
Thanks!
The stopLoading seems sometimes not working for Android platform, sometimes it still loading and redirect to the specific url
Hi @LSmint,
Can you provide sample project, which could be used for debugging?
@tsonevn I can confirm the problem, the provided solution is not working (also on iOS)
Most helpful comment
Hi @surdu,
In your case, you could use
loadStartedEventto validate the url and if needed to stop page loading while using stopLoading() method. For example:Let me know if this helps in your case.