getUserId method

  1. @override
Future<String?> getUserId()
override

Retrieves the user ID associated with the Grouplink SDK.

Implementation

@override
Future<String?> getUserId() async {
  if (Platform.isAndroid) {
    String userId;
    try {
      // if(userIdNr!=0)return;
      debugPrint("getUserId()");
      final String result = await methodChannel.invokeMethod('getUserId');
      userId = result;
      debugPrint(userId);
    } on PlatformException catch (e) {
      userId = "UserId: '${e.message}'.";
      log("Error getiOSUserID: ${e.message}");
      rethrow;
    }
    return userId;
  } else {
    if (Platform.isIOS) {
      try {
        final String? userID =
            await iOSSDKChannel.invokeMethod<String>('getiOSUserID');
        return userID;
      } on PlatformException catch (e) {
        log("Error getiOSUserID: ${e.message}");
        rethrow;
      }
    }
    return "not registered.";
  }
}