registerUser method

  1. @override
Future<void> registerUser(
  1. String userIdentifier, {
  2. String fcmToken = FlyConstants.empty,
  3. bool isForceRegister = true,
  4. String userType = "",
  5. List<IdentifierMetaData>? identifierMetaData,
  6. required dynamic callback(
    1. FlyResponse response
    ),
})
override

This method is used to register the user.

Implementation

@override
Future<void> registerUser(String userIdentifier,
    {String fcmToken = FlyConstants.empty,
    bool isForceRegister = true,
    String userType = "",
    List<IdentifierMetaData>? identifierMetaData,
    required Function(FlyResponse response) callback}) async {
  String? registerResponse;
  try {
    registerResponse =
        await mirrorFlyMethodChannel.invokeMethod('register_user', {
      "userIdentifier": userIdentifier,
      "token": fcmToken,
      "userType": userType,
      "isForceRegister": isForceRegister,
      "metaData": identifierMetaData != null
          ? List<dynamic>.from(identifierMetaData.map((x) => x.toMap()))
          : null
    });
    var res = convertRegisterUserJsonFromString(registerResponse);
    callback.call(FlyResponse(true, res, "Registered Successfully"));
  } on PlatformException catch (e) {
    LogMessage.d("Platform Exception =", " $e");
    callback.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
        FlyException(e.code, e.message, e.details)));
  } on Exception catch (e) {
    LogMessage.d("Exception ", " $e");
    callback.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
        FlyException(FlyErrorCode.unHandle, FlyErrorMessage.unHandle, e)));
  }
}