feat: 알림 권한 처리 개선 및 빌드 시스템 업데이트

- Android NDK 버전을 27.0.12077973으로 업데이트
- Core library desugaring 설정 추가
- POST_NOTIFICATIONS 권한 추가 (Android 13+)
- flutter_local_notifications 17.2.4로 업데이트
- iOS/Android 알림 권한 요청 메서드 개선
- 권한 상태 확인 메서드 추가
This commit is contained in:
JiWoong Sul
2025-07-17 19:34:23 +09:00
parent a9a715d67c
commit 58727af659
6 changed files with 78 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ import 'package:timezone/timezone.dart' as tz;
import 'package:timezone/data/latest_all.dart' as tz;
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'dart:io' show Platform;
import '../models/subscription_model.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
@@ -151,11 +152,72 @@ class NotificationService {
static Future<bool> 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<bool> 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; // 기본값
}
// 알림 스케줄 설정