register method

Future<User> register(
  1. String userId,
  2. String activationToken,
  3. String pin, [
  4. String? pushToken,
])

Provides end-user registration.

Registers an end-user for a given MIRACL Trust Project on the MIRACL Trust platform.

Parameters:

  • userId: The unique user identifier (e.g., email address).
  • activationToken: The token received after a successful verification process.
  • pin: The user's desired PIN.
  • pushToken: An optional push notification token for this device. This should be provided if your project is configured to use push notifications.

Throws RegistrationException if any part of the registration process fails.

Implementation

Future<User> register(String userId, String activationToken, String pin, [ String? pushToken ]) async {
  try {
    final mUser = await _sdk.register(userId, activationToken, pin, pushToken);
    final user = mUser._toUser();

    return user;
  } on PlatformException catch(e) {
    final exceptionCode = e._getExceptionCode();
    if (exceptionCode is MRegistrationExceptionCode) {
      throw RegistrationException._create(
        exceptionCode.toRegistrationExceptionCode(),
        e.details["error"]
      );
    } else {
      rethrow;
    }
  }
}