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.');
}
// register the user with userId
await js.context.callMethod('Intercom', [
'update',
js.JsObject.jsify({
'user_id': userId,
}),
]);
// send the success callback only as web doesnot support the statusCallback.
statusCallback?.onSuccess?.call();
} else if (email?.isNotEmpty ?? false) {
// register the user with email
await js.context.callMethod('Intercom', [
'update',
js.JsObject.jsify({
'email': email,
}),
]);
// send the success callback only as web doesnot support the statusCallback.
statusCallback?.onSuccess?.call();
} else {
throw ArgumentError(
'An identification method must be provided as a parameter, either `userId` or `email`.');
}
}