After you integrate the WindVane or uni-app miniapp container into a native app, you can associate a user who login to the app with the miniapp container during runtime.
Unless the app user has not logged in yet, when the app user logs in or switches accounts, the app must associate the logged in user with the miniapp container at runtime. After association, the mini program container will use the user information (only UserId) in the following scenarios:
Determine whether the current user has the corresponding device authorization
When switching users, the SDK will automatically clear the WindVane miniapp's cookies based on whether the user information has changed
When reporting PV, UV and other data (reporting plugin needs to be introduced)
Using the whitelist grayscale function of mini programs on open application platforms
Associate a user with a miniapp container
To use the whitelist-based canary release feature and the automatic cache clearing feature, you must call the following interface to associate the user with the miniapp container. Sample code:
[[EMASServiceManager sharedInstance] registerServiceProtocol:@"EMASUserInfoService" IMPClass:@"EMASUserInfoServiceImpl" target:nil];
@implementation EMASUserInfoServiceImpl
- (EMASUserInfo *)getUserInfo {
EMASUserInfo *userInfo = [[EMASUserInfo alloc] init];
userInfo.userId = userId;
return userInfo;
}
@endDevice authorization
- (BOOL)isAuthorized {
id<EMASUserInfoService> userInfoService = [[EMASServiceManager sharedInstance] serviceForProtocol:@"EMASUserInfoService"];
....
EMASUserInfo *userInfo = [userInfoService getUserInfo];
....
return [AuthorizationManagement.sharedInstance getMiniAppScope:scope appId:appId userId: userInfo.userId];
}
Cookie clear
- (void)clearMiniAppCookies {
id<EMASUserInfoService> userInfoService = [[EMASServiceManager sharedInstance] serviceForProtocol:@"EMASUserInfoService"];
...
EMASUserInfo *userInfo = [userInfoService getUserInfo];
if (userInfo) {
currentUserId = userInfo.userId;
}
if([EMASMiniAppUtils isDifferentUser:currentUserId]) {
clearCookie();
}
}
Data report
- (void)reportData() {
id<EMASUserInfoService> userInfoService = [[EMASServiceManager sharedInstance] serviceForProtocol:@"EMASUserInfoService"];
...
EMASUserInfo *userInfo = [userInfoService getUserInfo];
if (userInfo) {
userId = userInfo.userId;
}
// ...
report(userId);
}