FCM push Notifications
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user