deviceId static method

Future<String?> deviceId()

Get the device id.

Implementation

static Future<String?> deviceId() async {
  String key = "ny_device_id";
  String? deviceUid = await NyStorage.read(key);
  if (deviceUid == null) {
    Uuid uuid = const Uuid();
    int timestamp = DateTime.now().millisecondsSinceEpoch;
    deviceUid = "${uuid.v4()}-${timestamp.toString()}";
    await NyStorage.save(key, deviceUid);
  }
  return deviceUid;
}