Skip to content

Commit

Permalink
Update: InAppWebView Version Upgrade to 6.x.x
Browse files Browse the repository at this point in the history
  • Loading branch information
happycastle114 committed Nov 5, 2024
1 parent 46b9733 commit 9077c89
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 61 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="taxi_notification" />
<provider
android:name="com.pichillilorenzo.flutter_inappwebview.InAppWebViewFileProvider"
android:authorities="${applicationId}.flutter_inappwebview.fileprovider"
android:name="com.pichillilorenzo.flutter_inappwebview_android.InAppWebViewFileProvider"
android:authorities="${applicationId}.flutter_inappwebview_android.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.9.10'
ext.kotlin_version = '1.8.0'
repositories {
google()
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
32 changes: 28 additions & 4 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
327B8813AE4F7CE617097936 /* [CP] Embed Pods Frameworks */,
2749C737F1FC177F84FB6A28 /* [firebase_crashlytics] Crashlytics Upload Symbols */,
);
buildRules = (
);
Expand All @@ -160,7 +161,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import flutter_local_notifications
import Firebase
import FirebaseMessaging

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void main() async {
};

if (Platform.isAndroid) {
await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true);
await InAppWebViewController.setWebContentsDebuggingEnabled(true);
}
// await Future.delayed(Duration(seconds: 5));

Expand Down
83 changes: 39 additions & 44 deletions lib/views/taxiView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class TaxiView extends HookWidget {
useEffect(() {
if (url.value != '' && _controller.value != null) {
_controller.value!
.loadUrl(urlRequest: URLRequest(url: Uri.parse(url.value)))
.loadUrl(urlRequest: URLRequest(url: WebUri(url.value)))
.then((value) {});
}
}, [LoadCount.value]);
Expand Down Expand Up @@ -248,7 +248,7 @@ class TaxiView extends HookWidget {
await Token().deleteAll();
}
await _cookieManager.deleteCookie(
url: Uri.parse(RemoteConfigController().backUrl),
url: WebUri(RemoteConfigController().backUrl),
name: "connect.sid");
isAuthLogin.value = false;
isLogin.value = false;
Expand Down Expand Up @@ -499,29 +499,28 @@ class TaxiView extends HookWidget {

return SafeArea(
child: Stack(children: [
WillPopScope(
onWillPop: () =>
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<String, String>.from(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
);
Expand All @@ -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",
Expand Down Expand Up @@ -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 =
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -911,26 +910,23 @@ class TaxiView extends HookWidget {
]));
}

Future<bool> _goBack(
Future<void> _goBack(
BuildContext context,
ValueNotifier<bool> backCount,
ValueNotifier<bool> isAuthLogin,
InAppWebViewController? _controller) async {
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(
Expand All @@ -939,7 +935,6 @@ class TaxiView extends HookWidget {
textColor: toastTextColor,
toastLength: Toast.LENGTH_SHORT,
);
return false;
}
}
}
7 changes: 3 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9077c89

Please sign in to comment.