11import 'package:flutter/material.dart' ;
2+ import 'package:flutter_local_notifications/flutter_local_notifications.dart' ;
23import 'package:intl/date_symbol_data_local.dart' ;
34import 'package:ongi/screens/login/login_pw_screen.dart' ;
45import 'package:ongi/screens/splash_screen.dart' ;
@@ -9,6 +10,8 @@ import 'package:firebase_core/firebase_core.dart';
910import 'firebase_options.dart' ;
1011import 'package:firebase_messaging/firebase_messaging.dart' ;
1112
13+ final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin ();
14+
1215void main () async {
1316 WidgetsFlutterBinding .ensureInitialized ();
1417 await initializeDateFormatting ();
@@ -25,9 +28,38 @@ void main() async {
2528 provisional: false ,
2629 sound: true ,
2730 );
31+
32+ messaging.setForegroundNotificationPresentationOptions (
33+ alert: true , badge: true , sound: true ,
34+ );
2835
2936 _initializeFCMIfLoggedIn ();
3037
38+ const categoryId = 'PILL_TAKE_REMINDER' ;
39+ final iosInit = DarwinInitializationSettings (
40+ requestAlertPermission: true ,
41+ requestBadgePermission: true ,
42+ requestSoundPermission: true ,
43+ notificationCategories: [
44+ DarwinNotificationCategory (
45+ categoryId,
46+ actions: [
47+ DarwinNotificationAction .plain ('ACCEPT' , '복용 완료!' ),
48+ ],
49+ ),
50+ ],
51+ );
52+ final initSettings = InitializationSettings (iOS: iosInit);
53+ await flutterLocalNotificationsPlugin.initialize (
54+ initSettings,
55+ onDidReceiveNotificationResponse: (resp) {
56+ switch (resp.actionId) {
57+ case 'ACCEPT' :
58+ break ;
59+ }
60+ }
61+ );
62+
3163 runApp (const OngiApp ());
3264}
3365
0 commit comments