getDeviceId static method

FutureEither<String> getDeviceId()

Implementation

static FutureEither<String> getDeviceId() async {
  var preferences = await SharedPreferences.getInstance();
  var base64Id = preferences.getString('ana.deviceId');
  if (base64Id != null) {
    var deviceId = utf8.decode(base64Decode(base64Id));
    return right(deviceId);
  }
  var divId = await PlatformDeviceId.getDeviceId;
  if (divId == null) return left('DeviceId is null');
  base64Id = base64Encode(utf8.encode(divId));
  preferences.setString('ana.deviceId', base64Id);
  return right(divId);
}