Update send FCM Token to Server

This commit is contained in:
anhtunz
2025-03-14 22:35:54 +07:00
parent a6fa3b1572
commit c21667606a
4 changed files with 23 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:sfm_app/product/services/api_services.dart';
import 'product/services/notification_services.dart';
import 'product/services/theme_services.dart';
import 'product/services/language_services.dart';
@@ -58,7 +59,7 @@ class _MyAppState extends State<MyApp> {
LanguageServices languageServices = LanguageServices();
ThemeServices themeServices = ThemeServices();
final NotificationServices notificationServices = NotificationServices();
APIServices apiServices = APIServices();
setLocale(Locale locale) {
_locale = locale;
mainBloc.sinkLanguage.add(_locale);
@@ -77,9 +78,15 @@ class _MyAppState extends State<MyApp> {
// notificationServices.setupInteractMessage();
notificationServices.getDeviceToken().then((token){
print("Firebase Token: $token");
sendNotificationToken(token);
});
}
void sendNotificationToken (String token) async {
int statusCode = await apiServices.sendNotificationToken(token);
log("Notification Send StatusCode : $statusCode");
}
@override
void didChangeDependencies() {
languageServices.getLocale().then((locale) => {setLocale(locale)});