feat(ios): 添加用户信息存储和设置功能

实现用户信息的存储和设置功能,包括添加_userInfo属性和setUserInfo方法
完善getUserInfo方法以返回存储的用户信息
This commit is contained in:
2026-01-15 13:17:16 +08:00
parent bd0ed35830
commit bd44518b74

View File

@@ -6,11 +6,14 @@
@interface ShutoApi : CDVPlugin <NSObject> {
// ID
NSString* _eventCallbackId;
//
NSDictionary* _userInfo;
}
- (void)close:(CDVInvokedUrlCommand*)command;
- (void)registerEvent:(CDVInvokedUrlCommand*)command;
- (void)getUserInfo:(CDVInvokedUrlCommand*)command;
- (void)setUserInfo:(CDVInvokedUrlCommand*)command;
- (void)navigateToRoute:(NSString*)route parameters:(NSDictionary*)parameters __attribute__((objc_method_family(none)));
@end
@@ -68,11 +71,28 @@
- (void)getUserInfo:(CDVInvokedUrlCommand*)command
{
// TODO: Implement getUserInfo method
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
//
CDVPluginResult* pluginResult;
if (_userInfo) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:_userInfo];
} else {
//
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:nil];
}
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void)setUserInfo:(NSDictionary*)userInfo
{
//
if (userInfo) {
_userInfo = userInfo;
NSLog(@"ShutoApi: User info set successfully: %@", userInfo);
} else {
NSLog(@"ShutoApi: Invalid user info provided");
}
}
//
- (void)navigateToRoute:(NSString*)route parameters:(NSDictionary*)parameters {
if (!_eventCallbackId) {