feat(ios): 添加用户信息存储和设置功能
实现用户信息的存储和设置功能,包括添加_userInfo属性和setUserInfo方法 完善getUserInfo方法以返回存储的用户信息
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user