isUserConnected static method

Future<bool> isUserConnected({
  1. required String key,
  2. required String uuid,
  3. required String platformName,
})

Returns whether the user is connected to the given platform or not

Implementation

static Future<bool> isUserConnected(
    {required String key,
    required String uuid,
    required String platformName}) async {
  var repo = HekaHealth(key);
  // TODO: this should be cached when Heka or HekaManager is initialized
  var failureOrSuccess = await repo.fetchConnection(uuid);
  return failureOrSuccess.fold((error) => false, (connection) async {
    if (connection == null) {
      return false;
    }
    String? deviceId;
    if (platformName == PlatformName.appleHealth) {
      deviceId = (await DeviceInfoPlugin().iosInfo).identifierForVendor;
    }
    return connection.isConnected(platformName, deviceId);
  });
}