From b79003969653a1b02c0d76fb34a9c2a9b35a9002 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Wed, 12 Oct 2022 00:37:06 +0200 Subject: [PATCH] fixed WebResourceError iOS, updated code docs --- .../ios/Flutter/flutter_export_environment.sh | 4 +-- ios/Classes/InAppWebView/InAppWebView.swift | 4 +-- .../chrome_safari_browser_settings.dart | 26 +++++++++---------- lib/src/cookie_manager.dart | 6 +---- lib/src/web_storage/web_storage_manager.dart | 4 +++ 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index 03bce7c9..9e98dd5e 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -3,11 +3,11 @@ export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/2.10.4" export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example" export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=integration_test/webview_flutter_test.dart" +export "FLUTTER_TARGET=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/lib/main.dart" export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" -export "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" +export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" diff --git a/ios/Classes/InAppWebView/InAppWebView.swift b/ios/Classes/InAppWebView/InAppWebView.swift index 0ab27780..774602b5 100755 --- a/ios/Classes/InAppWebView/InAppWebView.swift +++ b/ios/Classes/InAppWebView/InAppWebView.swift @@ -1819,8 +1819,8 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, InAppWebView.credentialsProposed = [] var urlError: URL = url ?? URL(string: "about:blank")! - var errorCode = error._code - var errorDescription = error.localizedDescription + var errorCode = -1 + var errorDescription = "domain=\(error._domain), code=\(error._code), \(error.localizedDescription)" if let info = error as? URLError { if let failingURL = info.failingURL { diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart b/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart index 4a35cdc6..3794f710 100755 --- a/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart +++ b/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart @@ -37,7 +37,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///**NOTE**: Not available in a Trusted Web Activity. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android CustomTabsShareState shareState; ///Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`. @@ -45,13 +45,13 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///**NOTE**: Not available in a Trusted Web Activity. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android bool showTitle; ///Set the custom background color of the toolbar. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android Color? toolbarBackgroundColor; ///Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`. @@ -59,7 +59,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///**NOTE**: Not available in a Trusted Web Activity. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android bool enableUrlBarHiding; ///Set to `true` to enable Instant Apps. The default value is `false`. @@ -67,7 +67,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///**NOTE**: Not available in a Trusted Web Activity. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android bool instantAppsEnabled; ///Set an explicit application package name that limits @@ -77,31 +77,31 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///application package. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android String? packageName; ///Set to `true` to enable Keep Alive. The default value is `false`. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android bool keepAliveEnabled; ///Set to `true` to launch the Android activity in `singleInstance` mode. The default value is `false`. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android bool isSingleInstance; ///Set to `true` to launch the Android intent with the flag `FLAG_ACTIVITY_NO_HISTORY`. The default value is `false`. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android bool noHistory; ///Set to `true` to launch the Custom Tab as a Trusted Web Activity. The default value is `false`. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android bool isTrustedWebActivity; ///Sets a list of additional trusted origins that the user may navigate or be redirected to from the starting uri. @@ -109,7 +109,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///**NOTE**: Available only in a Trusted Web Activity. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android List additionalTrustedOrigins; ///Sets a display mode of a Trusted Web Activity. @@ -117,7 +117,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///**NOTE**: Available only in a Trusted Web Activity. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android TrustedWebActivityDisplayMode? displayMode; ///Sets a screen orientation. This can be used e.g. to enable the locking of an orientation lock type. @@ -125,7 +125,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///**NOTE**: Available only in a Trusted Web Activity. /// ///**Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android TrustedWebActivityScreenOrientation screenOrientation; ///Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`. diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index c96cac5b..68819efb 100755 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -14,14 +14,10 @@ import 'types/main.dart'; ///On Android, it is implemented using [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager). ///On iOS, it is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore). /// -///**NOTE for iOS below 11.0 (LIMITED SUPPORT!)**: in this case, almost all of the methods ([CookieManager.deleteAllCookies] and [CookieManager.getAllCookies] are not supported!) +///**NOTE for iOS below 11.0 and Web platform (LIMITED SUPPORT!)**: in this case, almost all of the methods ([CookieManager.deleteAllCookies] and [CookieManager.getAllCookies] are not supported!) ///has been implemented using JavaScript because there is no other way to work with them on iOS below 11.0. ///See https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies for JavaScript restrictions. /// -///**NOTE for Web (LIMITED SUPPORT!)**: in this case, almost all of the methods ([CookieManager.deleteAllCookies] and [CookieManager.getAllCookies] are not supported!) -///has been implemented using JavaScript, so all methods will have effect only if the iframe has the same origin. -///See https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies for JavaScript restrictions. -/// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS diff --git a/lib/src/web_storage/web_storage_manager.dart b/lib/src/web_storage/web_storage_manager.dart index 0710bf03..255bb002 100755 --- a/lib/src/web_storage/web_storage_manager.dart +++ b/lib/src/web_storage/web_storage_manager.dart @@ -13,6 +13,10 @@ import '../types/main.dart'; ///On iOS, it is implemented using [WKWebsiteDataStore.default()](https://developer.apple.com/documentation/webkit/wkwebsitedatastore). /// ///**NOTE for iOS**: available from iOS 9.0+. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +///- iOS class WebStorageManager { static WebStorageManager? _instance; static const MethodChannel _staticChannel = WEB_STORAGE_STATIC_CHANNEL;