diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 33f7434..dadba05 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -8,11 +8,12 @@ plugins { android { namespace = "com.example.submanager" compileSdk = flutter.compileSdkVersion - ndkVersion = flutter.ndkVersion + ndkVersion = "27.0.12077973" compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 + isCoreLibraryDesugaringEnabled = true } kotlinOptions { @@ -42,3 +43,7 @@ android { flutter { source = "../.." } + +dependencies { + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4") +} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 9adc6cc..797fa90 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ + requestPermission() async { - final result = await _notifications - .resolvePlatformSpecificImplementation< - AndroidFlutterLocalNotificationsPlugin>() - ?.requestPermission(); - return result ?? false; + // 웹 플랫폼인 경우 false 반환 + if (_isWeb) return false; + + // iOS 처리 + if (Platform.isIOS) { + final iosImplementation = _notifications + .resolvePlatformSpecificImplementation< + IOSFlutterLocalNotificationsPlugin>(); + + if (iosImplementation != null) { + final granted = await iosImplementation.requestPermissions( + alert: true, + badge: true, + sound: true, + ); + return granted ?? false; + } + } + + // Android 처리 + if (Platform.isAndroid) { + final androidImplementation = _notifications + .resolvePlatformSpecificImplementation< + AndroidFlutterLocalNotificationsPlugin>(); + + if (androidImplementation != null) { + final granted = await androidImplementation + .requestNotificationsPermission(); + return granted ?? false; + } + } + + return false; + } + + // 권한 상태 확인 + static Future checkPermission() async { + // 웹 플랫폼인 경우 false 반환 + if (_isWeb) return false; + + // Android 처리 + if (Platform.isAndroid) { + final androidImplementation = _notifications + .resolvePlatformSpecificImplementation< + AndroidFlutterLocalNotificationsPlugin>(); + + if (androidImplementation != null) { + // Android 13 이상에서만 권한 확인 필요 + final isEnabled = await androidImplementation.areNotificationsEnabled(); + return isEnabled ?? false; + } + } + + // iOS 처리 + if (Platform.isIOS) { + final iosImplementation = _notifications + .resolvePlatformSpecificImplementation< + IOSFlutterLocalNotificationsPlugin>(); + + if (iosImplementation != null) { + final settings = await iosImplementation.checkPermissions(); + return settings?.isEnabled ?? false; + } + } + + return true; // 기본값 } // 알림 스케줄 설정 diff --git a/macos/Podfile.lock b/macos/Podfile.lock index ec872a9..bb4b814 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -59,7 +59,7 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/webview_flutter_wkwebview/darwin SPEC CHECKSUMS: - flutter_local_notifications: 3805ca215b2fb7f397d78b66db91f6a747af52e4 + flutter_local_notifications: 4b427ffabf278fc6ea9484c97505e231166927a5 flutter_secure_storage_macos: c2754d3483d20bb207bb9e5a14f1b8e771abcdb9 FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 local_auth_darwin: 66e40372f1c29f383a314c738c7446e2f7fdadc3 diff --git a/pubspec.lock b/pubspec.lock index b2272a4..3b2ecb9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -343,10 +343,10 @@ packages: dependency: "direct main" description: name: flutter_local_notifications - sha256: "401643a6ea9d8451365f2ec11145335bf130560cfde367bdf8f0be6d60f89479" + sha256: "674173fd3c9eda9d4c8528da2ce0ea69f161577495a9cc835a2a4ecd7eadeb35" url: "https://pub.dev" source: hosted - version: "15.1.3" + version: "17.2.4" flutter_local_notifications_linux: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 30bd70a..9bf2367 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: provider: ^6.1.1 hive: ^2.2.3 hive_flutter: ^1.1.0 - flutter_local_notifications: ^15.1.0 + flutter_local_notifications: ^17.2.4 flutter_secure_storage: ^9.0.0 local_auth: ^2.1.6 fl_chart: ^0.66.2