I am aware that offline application cache is not supported in iOS WKWebView.
This is enabled in Safari, so I searched webkit project for the responsible code & found this
WKPreferences
- (void)_setOfflineApplicationCacheIsEnabled:(BOOL)offlineApplicationCacheIsEnabled;
Anyone familiar with this method? is it possible to enable app cache in iOS by accessing this private methods? (I am not going to ship the app to Appstore)
Update 2022
According to one of the comments below, this hack doesn't work anymore.
Yes, we can enable App cache by accessing private API
Create a category for WKPreferences and add to following method signature.
#interface WKPreferences (MyPreferences)
- (void)_setOfflineApplicationCacheIsEnabled:(BOOL)offlineApplicationCacheIsEnabled;
#end
(I tried performSelector:withObject: but it didn't work. No idea why)
After initializing the WKWebView, enable the appcache by calling the above method in the following object
[_wkWebView.configuration.preferences _setOfflineApplicationCacheIsEnabled:YES];
It will create the ApplicationCache.db file in the Cache directory and allow the web app to work offline.
Warning :
2.5. Apps that use non-public APIs will be rejected
According to this tweet from at Apple, as of iOS 10, App Cache is now supported in WKWebView:
https://twitter.com/andersca/status/743259582252879872
...as does this WebKit bug report:
https://bugs.webkit.org/show_bug.cgi?id=152490
I've tested this in WKWebView using this site:
http://webdbg.com/test/appcache/
and can confirm it works as expected both in the iOS Simulator and on devices running iOS 10.
Related
After upgrading to BlackBerry Dynamics for iOS (v10.1.0.36) cookies that previously were being set via the "Set-Cookie" header in the responses are no longer being set.
On performing some analysis we have found out that the WebView receives the cookies in the response. However its not being set in the WebView and the javascript cannot read the set cookies in the WebView.
Even if we manually read the cookies from the Response and set them in the WebView the javascript is still unable to read the cookies.
We have also noticed that in the below mentioned Blog Post the very same issue we are facing is declared as fixed (in 10.1) so it has been a bit confusing how it is working in 10.0 but not in 10.1
https://devblog.blackberry.com/en/2022/01/blackberry-dynamics-sdk-v10-1-is-now-generally-available
Setting Cookies in the WKHTTPCookieStore was not supported in 10.0 as described below and its support was added in 10.1.
https://docs.blackberry.com/en/development-tools/blackberry-dynamics-sdk-ios/10_0/blackberry-dynamics-sdk-ios-devguide/gwj1489687014271/Requirements-and-prerequisites-for-iOS-platform-features/owv1529436593184/WKWebView-unsupported-methods-and-properties
Could you confirm if your app is using a native WKWebView directly or else? You can post some code snippets around the issue here or reach out to BlackBerry Support in case this is a defect in 10.1.
Thanks,
With iOS 15, Apple had made it possible to create Safari extension for iOS as well.
I'm currently in the process of bringing an existing macOS Safari extension to iOS.
My problem is that there doesn't seem to be the option to send a message from the host app to the extension. It is possible to answer a request from the extension through the
beginRequest(with:) function. However, I actively need to send a message to the extension after an user action. In macOS, this can be done through the dispatchMessage(withName:toExtensionWithIdentifier:userInfo:completionHandler:) function as described here: https://developer.apple.com/documentation/safariservices/safari_web_extensions/messaging_between_the_app_and_javascript_in_a_safari_web_extension. This function is unfortunately not available for iOS.
Would greatly appreciate any ideas for solving this problem.
You can enable permission ["nativeMessaging"] in manifest file of the safari extension
Use appGroup to store data between the extension and your application.
In SafariWebExtensionHandler, you can response appGroup Data to the message called from any extension javascript file.
I have an app live on Appstore since 3-4 years, for feature enhancement I have done some changes & trying to upload on Appstore. I receive email of UIWebView deprication.
After that I have commented code which contains UIWebView. Then after I tried to upload but got same error email. Invalid binary and same reason.
Then again I have removed all code which contains UIWebView also I have removed all references from Storyboard as well. But this time I am getting same error email from Apple.
I have also tried by removing derived data. but facing same issue.
What's wrong with Apple???
Can't they specify class or module where they find it??
Looking for quick help.
NOTE: App language is Objective-C
XCode version - 11.3.1
Min iOS Support - iOS 9
They can find UIWebView in Dependencies.
Try to check in libraries and update their if possible.
It's one of your dependencies. There's a few options here to find out which one ITMS-90809: Deprecated API Usage -- Apple will stop accepting submissions of apps that use UIWebView APIs
I use Cordova 4, Angular 1.4 and Ionic 1.3 to make a tablet app for Android and iOS.
When user synchronised datas, app opened another window (cordova-plugin-inappbrowser) and displayed our SSO webpage. When user ended to connect, window was closed and synchronisation was send again.
Android store session cookie when app is closed but iOS don't.
Each time user open app on iOS, he need to open window authentificator.
Is it a way to store much longer cookies on iOS ?
Thanks
EVURLCache may help you.
This is a NSURLCache subclass for handeling all web requests that use
NSURLRequest. (This includes UIWebView)
The EVURLCache is meant for handeling the following caching
strategies:
The app has to be functional even if there is no internet connection.
The app has to be functional right after the app has been downloaden
from the app store. (This means that the required content can be
included in the app.)
You do want to be a able to download new/updated
content if it's available.
Note:
Support: iOS 8+ OSX 10.9+ WOS 2+ TVOS 9+
I have an app that shows a content using UIWebView. Apple rejects the app, because it doesn't support IPv6 network. Do you have any idea how to fix that? I have to import some libraries or do something else?
I am not using IP address for the URL, but it's domain name, for example:
https://asd.com
Your UIWebView not the reason of rejection the reason was your link or you server not support IPV6, Firstly test if your link support ipv6 that apple mean from this link you can do it , If you not pass this test search for how to configuration your server to support IPV6, I hope I help you
If your application is targeting above iOS 8, try using WebKit instead of UIWebView.
Refer to the following link which clarifies the text below it:
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/
Note: "In apps that run in iOS 8 and later, use the WKWebView class instead of using UIWebView. Additionally, consider setting the WKPreferences property javaScriptEnabled to false if you render files that are not supposed to run JavaScript."