Post

Replies

Boosts

Views

Activity

Reply to Intercept WebView requests and add Auth token in all subsequent resource request [GET .js, .png, .css].
Usually in such cases you want to add tokens as a cookie attached to request, in that case you need to save that cookie to WKWebView first and then load page. At this point question is what your server expects? In which way that token must be passed? p.s. Those delegate methods that you mentioned are designed to be invoked only for main resources like HTML pages and iframes so they are useless for sub-requests interception.
Feb ’24
Reply to Services Worker in WKWebView
Hi! Service Workers are not available for WKWebView, except if your app has web browser entitlement. You may try to use regular Workers instead and store data in IndexedDB, LocalStorage or Cookies. Read here about Service Workers in WKWebView: https://forums.developer.apple.com/forums/thread/722160
Feb ’24
Reply to Enabling WKWebView ServiceWorker on real device
As far as I know there are no way to enable Service Worker inside WKWebView unless you enable Web Browser entitlement for your application, at least this is the situation at current moment. See here for more details about Web Browser entitlement: https://developer.apple.com/documentation/xcode/preparing-your-app-to-be-the-default-browser-or-email-client
Dec ’22
Reply to how to prevernt "webViewWebContentProcessDidTerminate:"happen?
Hello, "webViewWebContentProcessDidTerminate:" call is not always related to memory usage and I'd first try to detect more or less reliable steps to reproduce the issue and then implement "- (void)_webView:(WKWebView *)webView webContentProcessDidTerminateWithReason:(int)reason" instead of "webViewWebContentProcessDidTerminate:". This is a private method and you shoundn't be using it in release apps since it wasn't designed for any WKWebView app. It is documented in WebKit's Github repo, look for WKNavigationDelegatePrivate.h file. The reason why you may want to use is that it specifies reason of the WebKit termination, and once you confirm that this is memory crash, you will have zero in reason variable, then you should proceed with attempts to reduce memory usage, but if it is just regular crash, reason will be 3, then you need to find WebKit's crash log, and from that point continue your investigation, depending on call stack.
Dec ’22
Reply to How to detect if browser is set as default on iOS
Per my understanding, this is not possible or at least shouldn't be possible because it would violate Apple's user privacy since you as a developer would know that certain application is installed on the device. Think about it in such a way: if Google is not doing it in their applications to detect whether Chrome is set as default browser why would I do that? You may look into Firefox for iOS source code for more details if you need to display any message to user asking him/her to set your browser as default to get some inspiration but I am pretty sure that they and other browser-implementing guys haven't found any meaningful answer to your question. FireFox iOS sources: https://github.com/mozilla-mobile/firefox-ios Chromium sources: https://chromium.googlesource.com/chromium/src.git/+/master/ios/
Sep ’22
Reply to Remote web inspector requirements for browsers on iOS 16
@huangzhikai, What do you mean by "third-party browsers"? I have tried on the most popular "third-party browsers" for iOS: Chrome for iOS and Firefox for iOS. The result is the same as in our browser: they are not displayed in the Desktop Safari Developer menu. Looks like something missing either in WebKit or in iOS browsers code. p.s. This time I tested on iOS 16.0 developer beta 3(20A5312g) with both Desktop Safari 15.5 (17613.2.7.1.8) and Desktop Safari Technology Preview Release 148 (Safari 16.0, WebKit 17614.1.17.1)
Jul ’22
Reply to iOS12 use WKURLSchemeHandler the "#5 0x00000001135602fa in -[WKURLSchemeTaskImpl dealloc] ()" raise exception
WKURLSchemeHandler is not designed to handle "http" and "https" schemes and you are doing this at your own risk. WebKit's documentation clearly says that all the methods of WebKit have to be called from main thread, that is not a case for you, as I see from screenshot. Always call WebKit functions and methods from your app’s main thread or main dispatch queue. Moving dealloc call to main thread may resolve your issue.
Jun ’22