loginIdentifiedUser method
Future<void>
loginIdentifiedUser({
- String? userId,
- String? email,
- IntercomStatusCallback? statusCallback,
override
Function to create a identified user in Intercom. You need to register your users before you can talk to them and track their activity in your app.
You can register a identified user either with userId
or with email
,
but not with both.
Implementation
@override
Future<void> loginIdentifiedUser({
String? userId,
String? email,
IntercomStatusCallback? statusCallback,
}) async {
if (userId?.isNotEmpty ?? false) {
if (email?.isNotEmpty ?? false) {
throw ArgumentError(
'The parameter `email` must be null if `userId` is provided.');
}
try {
await _channel.invokeMethod('loginIdentifiedUserWithUserId', {
'userId': userId,
});
statusCallback?.onSuccess?.call();
} on PlatformException catch (e) {
statusCallback?.onFailure?.call(_convertExceptionToIntercomError(e));
}
} else if (email?.isNotEmpty ?? false) {
try {
await _channel.invokeMethod('loginIdentifiedUserWithEmail', {
'email': email,
});
statusCallback?.onSuccess?.call();
} on PlatformException catch (e) {
statusCallback?.onFailure?.call(_convertExceptionToIntercomError(e));
}
} else {
throw ArgumentError(
'An identification method must be provided as a parameter, either `userId` or `email`.');
}
}