Update: 2026-06-26 04:04:03

This commit is contained in:
Hamza-Ayed
2026-06-26 04:04:04 +03:00
parent aea0c8e44e
commit da9e6eb981
10 changed files with 325 additions and 112 deletions

View File

@@ -65,13 +65,21 @@ class FirebaseMessagesController extends GetxController {
// : Get.put(NotificationController());
Future getToken() async {
fcmToken.getToken().then((token) {
// Log.print('fcmToken: ${token}');
box.write(BoxName.tokenFCM, (token.toString()));
});
// 🔹 الاشتراك في topic
await fcmToken.subscribeToTopic("service"); // أو "users" حسب نوع المستخدم
Log.print("Subscribed to 'service' topic ✅");
try {
final token = await fcmToken.getToken();
if (token != null) {
box.write(BoxName.tokenFCM, token);
}
} catch (e) {
Log.print('⚠️ getToken error (APNS not ready yet): $e');
}
try {
await fcmToken.subscribeToTopic("service");
Log.print("Subscribed to 'service' topic ✅");
} catch (e) {
Log.print('⚠️ subscribeToTopic error (APNS not ready yet): $e');
}
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
// If the app is in the background or terminated, show a system tray message