Refactor H5 line management and cache handling in WebView app
- Introduced shared_preferences for initial H5 cache management. - Added methods to clear H5 caches and probe line availability. - Enhanced error handling for line loading and switching. - Removed openim_common package and its configurations. - Updated widget tests to reflect changes in H5 line handling and URL management.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import Flutter
|
||||
import UIKit
|
||||
import WebKit
|
||||
|
||||
private let h5CacheChannelName = "io.openim.flutter.im_webview_app/h5_cache"
|
||||
|
||||
@main
|
||||
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
|
||||
@@ -12,5 +15,31 @@ import UIKit
|
||||
|
||||
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
|
||||
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
|
||||
let h5CacheChannel = FlutterMethodChannel(
|
||||
name: h5CacheChannelName,
|
||||
binaryMessenger: engineBridge.applicationRegistrar.messenger()
|
||||
)
|
||||
h5CacheChannel.setMethodCallHandler { [weak self] call, result in
|
||||
switch call.method {
|
||||
case "clearAllWebsiteData":
|
||||
guard let self else {
|
||||
result(false)
|
||||
return
|
||||
}
|
||||
self.clearAllH5WebsiteData(result: result)
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func clearAllH5WebsiteData(result: @escaping FlutterResult) {
|
||||
let dataTypes = WKWebsiteDataStore.allWebsiteDataTypes()
|
||||
WKWebsiteDataStore.default().removeData(
|
||||
ofTypes: dataTypes,
|
||||
modifiedSince: Date(timeIntervalSince1970: 0)
|
||||
) {
|
||||
result(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user