FCM push Notifications

This commit is contained in:
2026-02-25 23:37:08 +08:00
parent 1807dca57d
commit 6ccf820438
9 changed files with 188 additions and 47 deletions
+23
View File
@@ -0,0 +1,23 @@
import 'package:shared_preferences/shared_preferences.dart';
import 'package:uuid/uuid.dart';
class DeviceId {
static const _key = 'tasq_device_id';
/// Returns a stable UUID for this installation. Generated once and persisted
/// in `SharedPreferences`.
static Future<String> getId() async {
final prefs = await SharedPreferences.getInstance();
var id = prefs.getString(_key);
if (id != null && id.isNotEmpty) return id;
id = const Uuid().v4();
await prefs.setString(_key, id);
return id;
}
/// For testing or explicit reset.
static Future<void> reset() async {
final prefs = await SharedPreferences.getInstance();
await prefs.remove(_key);
}
}