setOpenId
The setOpenId API is called by the super app to set the open ID, which is the user ID the super app returns in the memberInfoService SPI response. To retrieve and set the ID, you need to call this API after the IAPMiniProgram SDK has been initialized and the user logs in to the super app.
Method signature
function setOpenId(
openId: string,
extra?: {
success?: (success: BaseSuccess) => void;
error?: (error: BaseError) => void;
}
)
Request parameters
Field | Data type | Required | Description |
openId | string | Yes | The unique ID that is assigned by the super app to identify a user. It corresponds to the value of the result.memberInfo.userId response parameter of the MemberInfoService SPI. |
extra | Object | No | An extended attribute that is used to provide additional information if necessary. The included parameters are:
|
Response parameters
N/A
Result codes
Result code | Result message | Description | Further action |
1000 |
| The SDK opens the mini program successfully. | N/A |
2000 | The result message varies depending on the error that occurs. | The SDK encounters an error when attempting to open the mini program. | Refer to the result message for specific actions. |
Sample
import { setOpenId } from 'iapminiprogram-rn';
import type { BaseSuccess, BaseError } from 'iapminiprogram-rn';
function setMiniOpenId() {
setOpenId('123xxx789', {
success: (success: BaseSuccess) => {
},
error: (error: BaseError) => {
},
});
}