registerLocalUserAccount method
Registers a user account.
Once registered, the user account can be used to identify the local user when the user joins the channel. After the user successfully registers a user account, the SDK triggers the RtcEngineEventHandler.localUserRegistered callback on the local client, reporting the user ID and user account of the local user.
To join a channel with a user account, you can choose either of the following:
- Call the RtcEngine.registerLocalUserAccount method to create a user account, and then the RtcEngine.joinChannelWithUserAccount method to join the channel.
- Call the RtcEngine.joinChannelWithUserAccount method to join the channel. The difference between the two is that for the former, the time elapsed between calling the RtcEngine.joinChannelWithUserAccount method and joining the channel is shorter than the latter.
Note
- Ensure that you set the
userAccount
parameter. Otherwise, this method does not take effect. - Ensure that the value of the userAccount parameter is unique in the channel.
- To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Meta Web SDK, ensure that the uid of the user is set to the same parameter type.
Parameter appId
The App ID of your project.
Parameter userAccount
The user account. The maximum length of this parameter is 255 bytes. Ensure that you set this parameter and do not set it as null. Supported character scopes are:
- All lowercase English letters: a to z.
- All uppercase English letters: A to Z.
- All numeric characters: 0 to 9.
- The space character.
- Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "
", "
", "^", "_", " {", "}", "|", "~", ",".
Implementation
@override
Future<void> registerLocalUserAccount(String appId, String userAccount) {
return _invokeMethod('registerLocalUserAccount',
{'appId': appId, 'userAccount': userAccount});
}