addIdentity method

void addIdentity(
  1. Identity identity,
  2. Function onSuccess,
  3. dynamic onConflict(
    1. ConflictUser
    ),
  4. Function onError,
)

Adds Identity for the specified provider.

identity Identity to be added. onSuccess A callback to indicate if this operation was successful. onConflict Called if there was a conflict. onError Called if operation failed.

Implementation

void addIdentity(Identity identity, Function onSuccess,
    Function(ConflictUser) onConflict, Function onError) {
  NativeBridge.async('CurrentUser.addIdentity', jsonEncode(identity.toJSON()))
      .then((value) {
    if (jsonDecode(value)['result'] == '') {
      onSuccess();
    } else {
      onConflict(ConflictUser.fromJSON(jsonDecode(value)));
    }
  }).catchError(onError);
}