new branch
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sfm_app/product/cache/local_manager.dart';
|
||||
import 'package:sfm_app/product/constant/app/api_path_constant.dart';
|
||||
import 'package:sfm_app/product/constant/enums/local_keys_enums.dart';
|
||||
import 'package:sfm_app/product/network/network_manager.dart';
|
||||
import '../product/base/bloc/base_bloc.dart';
|
||||
import '../product/services/api_services.dart';
|
||||
import '../feature/bell/bell_model.dart';
|
||||
@@ -41,4 +47,32 @@ class MainBloc extends BlocBase {
|
||||
User user = User.fromJson(jsonDecode(data));
|
||||
sinkUserProfile.add(user);
|
||||
}
|
||||
|
||||
getFCMTokenAndPresentations() async {
|
||||
|
||||
String? firebaseAppToken = await FirebaseMessaging.instance.getToken();
|
||||
|
||||
if (firebaseAppToken != null) {
|
||||
log("FCM TOKEN: $firebaseAppToken");
|
||||
sendNotificationToken(firebaseAppToken);
|
||||
} else {
|
||||
log("FCM TOKEN: null");
|
||||
}
|
||||
}
|
||||
|
||||
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<String> getUID() async {
|
||||
String uid = LocaleManager.instance.getStringValue(PreferencesKeys.UID);
|
||||
return uid;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user