Update: 2026-06-26 04:04:03
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user