should have push notifs as well as Battery SOC monitoring

This commit is contained in:
2026-03-09 02:31:49 -05:00
parent 8776fe9679
commit ea0326394f
22 changed files with 354 additions and 16 deletions

View File

@@ -0,0 +1,18 @@
import 'package:blind_master/BlindMasterResources/secure_transmissions.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
class FcmService {
/// Request permission, fetch the FCM token, and register it with the server.
/// Safe to call on every login/session-restore — the server just upserts the value.
static Future<void> register() async {
try {
final messaging = FirebaseMessaging.instance;
await messaging.requestPermission(alert: true, badge: true, sound: true);
final token = await messaging.getToken();
if (token == null) return;
await securePost({'token': token}, 'register_fcm_token');
} catch (_) {
// Non-fatal — push notifications simply won't work until the next successful registration.
}
}
}