apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 986 forks source link

The CDVURLProtocol no longer exists, so how should we modify the interception? #1420

Closed GymotgM closed 3 weeks ago

GymotgM commented 3 weeks ago

Apache Cordova uses GitHub Issues as a feature request and bug tracker only. For usage and support questions, please check out the resources below. Thanks!


You can get answers to your usage and support questions about Apache Cordova on:

If you are using a tool that uses Cordova internally, like e.g. Ionic, check their support channels:

jcesarmobile commented 3 weeks ago

CDVURLProtocol only worked with the UIWebView which Apple doesn't allow to use since the end of 2020.

Cordova uses the WKWebView and custom scheme handlers, plugins can have an overrideSchemeTask method what Cordova's scheme handler check and let the plugin intercept the request instead of doing the default behavior.

Note that this only work for internal requests, for external requests you'll first need to replace the urls to point to the local scheme so they can intercepted, something like what proxy plugin does https://github.com/GEDYSIntraWare/cordova-plugin-webview-proxy/blob/master/src/ios/WebviewProxy.m#L22

https://github.com/GEDYSIntraWare/cordova-plugin-webview-proxy?tab=readme-ov-file#cordova-plugin-to-proxy-https-requests-on-ios-without-cors-and-cookie-restrictions

GymotgM commented 2 weeks ago

How to use WebviewProxy? Pod install cannot find this plugin, so I can only manually put the file into the project. After putting it into the project, how can I proceed to the - (BOOL) overrideSchemeTask: (id) urlSchemeTask method

GymotgM commented 2 weeks ago

@jcesarmobile