registerDevice abstract method

Future<Either<RepositoryFailure, Unit>> registerDevice()

Registers or updates the current device in Firestore.

Called automatically on login/auth refresh when connected to AuthService. Creates or updates the device document with current timezone, offset, platform, app version, and marks the device as active.

This is best-effort and should not block app startup. On success, updates internal cache for timezone/offset throttling.

When Called

  • On initial login (via addOnAuthenticatedCallback)
  • Can be called manually if needed

Returns

  • Right(unit) on success
  • Left(RepositoryFailure) on failure (logged, not surfaced to user)

Example

final result = await deviceService.registerDevice();
result.fold(
  (failure) => log('Device registration failed: $failure'),
  (_) => log('Device registered successfully'),
);

Implementation

Future<Either<RepositoryFailure, Unit>> registerDevice();