MemberInfoService
When the mini program or the IAPMiniProgram SDK requests basic user information, the SDK calls the MemberInfoService SPI to retrieve such information from the super app. For details on how the SPI functions, refer to the MemberInfoService workflow.
This SPI provides the getMemberInfo
method. The method details are as follows:
getMemberInfo
The SDK calls the getMemberInfo
method to retrieve basic user information from the super app.
Method signature
Future<MemberInfoFetchResult> getMemberInfo(MemberInfoFetchStrategy strategy,
MemberInfoScope scope, APIContext apiContext);
Request parameters
Field | Data type | Required | Description |
strategy | MemberInfoFetchStrategy | Yes | The strategy of getting users' information. Valid values are:
|
scope | Yes | An object that specifies the types of the user information that is requested. | |
apiContext | APIContext | Yes | A context object, which carries the mini program runtime metadata. |
Response parameters
Field | Data type | Required | Description |
result | Future<MemberInfoFetchResult> | Yes | The result of the |
Error codes
Error code | Error message | |
1000 | ERROR_CODE_UNKNOWN_ERROR | Unknown error |
1001 | ERROR_CODE_USER_CANCEL | The user cancels the operation. |
1002 | ERROR_CODE_APP_SERVICE_ERROR | The app service is wrong. |
1003 | ERROR_CODE_TIMEOUT | Timeout |
1005 | ERROR_CODE_SYSTEM_ERROR | System error |
2001 | ERROR_CODE_AUTH_PENDING_AGREEMENT | Authorization is not finished or is pending. |
Sample
The following sample shows how to implement the MemberInfoService SPI to provide basic user information to the SDK and mini programs:
- Create a class that implements the MemberInfoService interface.
- Implement the
getMemberInfo
method.
class TestMemberInfoService implements MemberInfoService {
@override
Future<MemberInfoFetchResult> getMemberInfo(MemberInfoFetchStrategy strategy,
MemberInfoScope scope, APIContext apiContext) async {
MemberInfo memberInfo = MemberInfo("userId_xxx");
memberInfo.avatar = 'avatar_xxx';
MemberInfoFetchResult result = MemberInfoFetchResult();
result.memberInfo = memberInfo;
return result;
}
}