diff --git a/lib/main.dart b/lib/main.dart index 300a032..88b4c14 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -60,6 +60,19 @@ Future initService() async { if (token != null) { DioServices().setAccessToken(token); } + FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler); +} + +Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { + await Firebase.initializeApp(); + print("Handling a background message: ${message.messageId}"); + if (message.notification != null) { + logger.d(message.notification!.title); + logger.d(message.notification!.body); + FcmService.showNotification( + title: message.notification!.title ?? "", + content: message.notification!.body ?? ""); + } } // 알림권한 관련 APNS 토큰 발급 코드 diff --git a/lib/modules/home/widget/home_widget.dart b/lib/modules/home/widget/home_widget.dart index 2df439c..2a3cacb 100644 --- a/lib/modules/home/widget/home_widget.dart +++ b/lib/modules/home/widget/home_widget.dart @@ -202,8 +202,8 @@ class FlameWidget extends StatelessWidget { ? Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - width: 200.w, + Container( + constraints: BoxConstraints(maxWidth: 200.w), child: Text( flameName!.substring(0, flameName!.length - 3), style: AppTextStyles.T1Bold18, diff --git a/lib/provider/api/auth_api.dart b/lib/provider/api/auth_api.dart index ba983b5..4293f84 100644 --- a/lib/provider/api/auth_api.dart +++ b/lib/provider/api/auth_api.dart @@ -85,7 +85,6 @@ class UserAuthApi { ">>> (애플로그인) 사용자의 accessToken: ${response.data[RESULT]["accessToken"]}"); String token = response.data[RESULT]["accessToken"]; DioServices().setAccessToken(token); - } return true; @@ -170,7 +169,7 @@ class UserAuthApi { timeInSecForIosWeb: 1); logger.e(response.data[CODE]); } - logger.e(response.data[RESULT]); + // logger.e(response.data[RESULT]); logger.i( '>>> 로그인 성공 후 사용자의 accessToken: ${response.data[RESULT]["accessToken"]}'); saveToken(response.data[RESULT]); diff --git a/lib/provider/service/fcm_service.dart b/lib/provider/service/fcm_service.dart index dc5cb7d..7aaf8de 100644 --- a/lib/provider/service/fcm_service.dart +++ b/lib/provider/service/fcm_service.dart @@ -20,6 +20,7 @@ class FcmService extends GetxService { @override void onInit() async { super.onInit(); + logger.d("fcm init"); AndroidInitializationSettings androidInitializationSettings = const AndroidInitializationSettings('drawable/splash'); DarwinInitializationSettings iosInitializationSettings = @@ -126,7 +127,7 @@ class FcmService extends GetxService { fcmToken: fcmToken ?? "", deviceId: deviceId); logger.d(tmpResult); } - + await setupInteractedMessage(); await FirebaseMessaging.instance.setAutoInitEnabled(true); FirebaseMessaging.instance.onTokenRefresh.listen((token) async { logger.w("!!!refreseh Token: $token"); @@ -162,25 +163,5 @@ class FcmService extends GetxService { } } }); - FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler); - } - - @pragma('vm:entry-point') - Future _firebaseMessagingBackgroundHandler( - RemoteMessage? message) async { - // If you're going to use other Firebase services in the background, such as Firestore, - // make sure you call `initializeApp` before using other Firebase services. - await Firebase.initializeApp(); - - logger.w("!!!Handling a background message: ${message?.messageId}"); - if (message != null) { - if (message.notification != null) { - logger.d(message.notification!.title); - logger.d(message.notification!.body); - FcmService.showNotification( - title: message.notification!.title ?? "", - content: message.notification!.body ?? ""); - } - } } }