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

@@ -21,4 +21,5 @@ class APIPathConstants {
static const JOIN_GROUP_PATH = "/api/groups/join";
static const APPROVE_GROUP_PATH = "/api/groups/approve";
static const DEVICE_LOGS_PATH = "/api/device-logs";
static const NOTIFICATION_TOKEN_PATH = "/api/users/app-token";
}

View File

@@ -49,6 +49,17 @@ class APIServices {
return response.body;
}
Future<int> sendNotificationToken(String token) async{
String uid = await getUID();
Map<String,dynamic> body = {
"user_id": uid,
"app_token": token
};
int statusCode = await NetworkManager.instance!.updateDataInServer(
APIPathConstants.NOTIFICATION_TOKEN_PATH, body);
return statusCode;
}
Future<void> logOut(BuildContext context) async {
showDialog(
context: context,

View File

@@ -75,7 +75,7 @@ class NotificationServices {
importance: androidNotificationChannel.importance,
priority: Priority.high,
ticker: 'ticker',
actions: type == "warn1"
actions: type == "smoke_warning"
? [
const AndroidNotificationAction(
"id1",
@@ -117,9 +117,9 @@ class NotificationServices {
return const RawResourceAndroidNotificationSound("welcome");
} else if (type == "success") {
return const RawResourceAndroidNotificationSound("success_alert");
} else if (type == "warn1") {
} else if (type == "smoke_warning") {
return const RawResourceAndroidNotificationSound("warning_alarm");
} else if (type == "warn2") {
} else if (type == "battery_warning") {
return const RawResourceAndroidNotificationSound("new_alarm");
} else {
return const RawResourceAndroidNotificationSound("normal");