From 9077c899c101662f7abc5f9cf2e0d260bf1484c7 Mon Sep 17 00:00:00 2001 From: happycastle <41810556+happycastle114@users.noreply.github.com> Date: Tue, 5 Nov 2024 23:58:42 +0900 Subject: [PATCH] Update: InAppWebView Version Upgrade to 6.x.x --- android/app/build.gradle | 4 +- android/app/src/main/AndroidManifest.xml | 4 +- .../sparcs}/taxi_app/MainActivity.kt | 0 android/build.gradle | 2 +- ios/Flutter/AppFrameworkInfo.plist | 2 +- ios/Runner.xcodeproj/project.pbxproj | 32 ++++++- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- ios/Runner/AppDelegate.swift | 2 +- lib/main.dart | 2 +- lib/views/taxiView.dart | 83 +++++++++---------- pubspec.yaml | 7 +- 11 files changed, 79 insertions(+), 61 deletions(-) rename android/app/src/main/kotlin/{com/example => org/sparcs}/taxi_app/MainActivity.kt (100%) diff --git a/android/app/build.gradle b/android/app/build.gradle index 250dc4e..193d561 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -50,7 +50,7 @@ apply plugin: 'com.google.gms.google-services' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 33 + compileSdkVersion 34 ndkVersion flutter.ndkVersion compileOptions { @@ -72,7 +72,7 @@ android { // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. minSdkVersion 21 // flutter.minSdkVersion - targetSdkVersion 33 + targetSdkVersion 34 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 8a76fc3..5577f12 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -74,8 +74,8 @@ android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="taxi_notification" /> CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 12.0 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 8533716..00cc2d8 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -144,6 +144,7 @@ 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 327B8813AE4F7CE617097936 /* [CP] Embed Pods Frameworks */, + 2749C737F1FC177F84FB6A28 /* [firebase_crashlytics] Crashlytics Upload Symbols */, ); buildRules = ( ); @@ -160,7 +161,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -203,6 +204,29 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 2749C737F1FC177F84FB6A28 /* [firebase_crashlytics] Crashlytics Upload Symbols */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}\"", + "\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/\"", + "\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist\"", + "\"$(BUILT_PRODUCTS_DIR)/$(EXECUTABLE_PATH)\"", + "\"$(PROJECT_DIR)/firebase_app_id_file.json\"", + ); + name = "[firebase_crashlytics] Crashlytics Upload Symbols"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$PODS_ROOT/FirebaseCrashlytics/upload-symbols\" --flutter-project \"$PROJECT_DIR/firebase_app_id_file.json\" "; + }; 327B8813AE4F7CE617097936 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -348,7 +372,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -427,7 +451,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -476,7 +500,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a6b826d..5e31d3d 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ + PopScope( + canPop: false, + onPopInvokedWithResult: (_, __) => _goBack(context, backCount, isAuthLogin, _controller.value), child: Scaffold( body: InAppWebView( - initialOptions: InAppWebViewGroupOptions( - crossPlatform: InAppWebViewOptions( - useShouldOverrideUrlLoading: true, - applicationNameForUserAgent: "taxi-app-webview/" + - (Platform.isAndroid ? "android" : "ios"), - resourceCustomSchemes: [ - 'intent', - 'supertoss', - 'uber', - 'tmoneyonda', - 'kakaotalk', - 'kakaot' - ]), - android: AndroidInAppWebViewOptions( - useHybridComposition: true, - overScrollMode: - AndroidOverScrollMode.OVER_SCROLL_NEVER), - ios: IOSInAppWebViewOptions(disallowOverScroll: true)), + initialSettings: InAppWebViewSettings( + useShouldOverrideUrlLoading: true, + applicationNameForUserAgent: "taxi-app-webview/" + + (Platform.isAndroid ? "android" : "ios"), + resourceCustomSchemes: [ + 'intent', + 'supertoss', + 'uber', + 'tmoneyonda', + 'kakaotalk', + 'kakaot' + ], + useHybridComposition: true, + overScrollMode: OverScrollMode.NEVER, + disallowOverScroll: true), + // initialUrlRequest: URLRequest(url: Uri.parse(address)), shouldOverrideUrlLoading: (controller, navigationAction) async { var newHeaders = Map.from( @@ -587,9 +586,9 @@ class TaxiView extends HookWidget { isAuthLogin.value = false; await _controller.value?.loadUrl( urlRequest: URLRequest( - url: Uri.parse(RemoteConfigController() - .frontUrl - .toString()))); + url: WebUri( + (RemoteConfigController().frontUrl) + .toString()))); } catch (e) { // TODO Fluttertoast.showToast( @@ -715,18 +714,17 @@ class TaxiView extends HookWidget { sessionToken.value != '' && uri?.origin == Uri.parse(address).origin && (await _cookieManager.getCookie( - url: Uri.parse( - RemoteConfigController().backUrl), + url: WebUri(RemoteConfigController().backUrl), name: "connect.sid")) ?.value != sessionToken.value) { try { await _controller.value?.stopLoading(); await _cookieManager.deleteCookie( - url: Uri.parse(RemoteConfigController().backUrl), + url: WebUri(RemoteConfigController().backUrl), name: "connect.sid"); await _cookieManager.setCookie( - url: Uri.parse(RemoteConfigController().backUrl), + url: WebUri(RemoteConfigController().backUrl), name: "connect.sid", value: sessionToken.value, ); @@ -742,15 +740,15 @@ class TaxiView extends HookWidget { } } }, - onLoadResourceCustomScheme: (controller, url) async { - if (!['intent'].contains(url.scheme)) { + onLoadResourceWithCustomScheme: (controller, url) async { + if (!['intent'].contains(url.url.scheme)) { await controller.stopLoading(); if (await canLaunchUrlString(url.toString())) { await launchUrlString(url.toString(), mode: LaunchMode.externalApplication); return; } - switch (url.scheme) { + switch (url.url.scheme) { case 'supertoss': OpenStore.instance.open( androidAppBundleId: "viva.republica.toss", @@ -787,7 +785,7 @@ class TaxiView extends HookWidget { return null; } if (Platform.isAndroid) { - if (url.scheme == 'intent') { + if (url.url.scheme == 'intent') { try { await controller.stopLoading(); const MethodChannel channel = @@ -796,7 +794,7 @@ class TaxiView extends HookWidget { "launchURI", url.toString()); if (result != null) { await _controller.value?.loadUrl( - urlRequest: URLRequest(url: Uri.parse(result))); + urlRequest: URLRequest(url: WebUri(result))); } } catch (e) { // TODO @@ -810,13 +808,14 @@ class TaxiView extends HookWidget { } return null; }, - onLoadError: (controller, url, code, message) { + onReceivedError: (controller, req, err) { // 될 때까지 리로드 if (!isLoaded.value && LoadCount.value < 10) { LoadCount.value++; } else if (isServerError.value == false && - code != 102 && - code != -999) { + err.type != WebResourceErrorType.CANCELLED && + err.type != + WebResourceErrorType.USER_CANCELLED_AUTHENTICATION) { Fluttertoast.showToast( msg: "서버와의 연결에 실패했습니다.", toastLength: Toast.LENGTH_SHORT, @@ -911,7 +910,7 @@ class TaxiView extends HookWidget { ])); } - Future _goBack( + Future _goBack( BuildContext context, ValueNotifier backCount, ValueNotifier isAuthLogin, @@ -919,18 +918,15 @@ class TaxiView extends HookWidget { Uri? current_uri = await _controller!.getUrl(); final address = RemoteConfigController().frontUrl; if (Uri.parse(address).origin != current_uri?.origin) { - await _controller.loadUrl( - urlRequest: URLRequest(url: Uri.parse(address))); + await _controller.loadUrl(urlRequest: URLRequest(url: WebUri(address))); backCount.value = false; - return false; } else if (await _controller.canGoBack() && (current_uri?.path != '/') && (current_uri?.path != '/home')) { _controller.goBack(); backCount.value = false; - return false; } else if (backCount.value) { - return true; + Navigator.pop(context); } else { backCount.value = true; Fluttertoast.showToast( @@ -939,7 +935,6 @@ class TaxiView extends HookWidget { textColor: toastTextColor, toastLength: Toast.LENGTH_SHORT, ); - return false; } } } diff --git a/pubspec.yaml b/pubspec.yaml index 98ceec1..5b1f7c1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,16 +34,15 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 flutter_hooks: ^0.18.6 - flutter_inappwebview: ^5.7.2 + flutter_inappwebview: ^6.1.5 flutter_secure_storage: ^8.0.0 dio: ^5.0.0 firebase_messaging: ^14.6.1 - flutter_local_notifications: ^14.0.0 + flutter_local_notifications: ^18.0.0 firebase_core: ^2.13.0 - flutter_web_auth: ^0.5.0 dio_cookie_manager: ^2.1.4 google_fonts: ^4.0.0 - fluttertoast: ^8.2.1 + fluttertoast: ^8.2.8 cookie_jar: ^3.0.1 flutter_dotenv: ^5.0.2 package_info: ^2.0.2