identifyUser method

  1. @override
Future<String?> identifyUser({
  1. String? email,
  2. String? phone,
  3. String? countryCode,
})
override

Identifies the user using either email or phone with an optional countryCode.

Implementation

@override
Future<String?> identifyUser(
    {String? email, String? phone, String? countryCode}) async {
  _ensureInitialized();
  if ((email == null && phone == null) || (email != null && phone != null)) {
    throw ArgumentError(
      'Invalid input: Either email or phone (but not both) must be provided.',
    );
  }
  try {
    final String? result = await methodChannel.invokeMethod('identifyUser', {
      'email': email,
      'phone': phone,
      'countryCode': countryCode,
    });
    log("Identify User event logged successfully with result: $result");
    return result;
  } on PlatformException catch (e) {
    log("Failed to identify user: ${e.message}");
    return 'Failed to identify user: ${e.message}';
  }
}