Files
Flutter_Shell/ios/Runner/AppDelegate.swift
Booker a1e7b3e52c 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.
2026-05-29 17:56:55 +07:00

46 lines
1.4 KiB
Swift

import Flutter
import UIKit
import WebKit
private let h5CacheChannelName = "io.openim.flutter.im_webview_app/h5_cache"
@main
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
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)
}
}
}