Skip to content

Commit 9061a66

Browse files
authored
Merge pull request #7 from Elric-pp/feat/finapplet-init
fix: finApplet init
2 parents 583534f + cb61875 commit 9061a66

File tree

2 files changed

+33
-53
lines changed

2 files changed

+33
-53
lines changed

ios/FINMopsdk.m

Lines changed: 33 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,25 @@ @implementation FINMopsdk
1919
FATConfig *config = [FATConfig configWithAppSecret:secret appKey:appkey];
2020
config.apiServer = [apiServer copy];
2121
config.apiPrefix = [apiPrefix copy];
22-
NSError* error = nil;
23-
[[FATClient sharedClient] initWithConfig:config error:&error];
24-
NSDictionary* ret;
25-
if (error) {
22+
dispatch_async(dispatch_get_main_queue(), ^(void) {
23+
NSError* error = nil;
24+
[[FATClient sharedClient] initWithConfig:config error:&error];
25+
NSDictionary* ret;
26+
if (error) {
27+
ret = @{
28+
@"success": @(NO),
29+
@"errMsg": [NSString stringWithFormat:@"初始化小程序引擎失败%@",error.localizedDescription]
30+
};
31+
callback(@[[ret toJSONString]]);
32+
return;
33+
}
34+
2635
ret = @{
27-
@"success": @(NO),
28-
@"errMsg": [NSString stringWithFormat:@"初始化小程序引擎失败%@",error.localizedDescription]
36+
@"success": @(YES),
37+
@"errMsg": @"initialize:ok"
2938
};
3039
callback(@[[ret toJSONString]]);
31-
return;
32-
}
33-
34-
ret = @{
35-
@"success": @(YES),
36-
@"errMsg": @"initialize:ok"
37-
};
38-
callback(@[[ret toJSONString]]);
40+
});
3941
}
4042
RCT_EXPORT_METHOD(openApplet:(nonnull NSString *)appId path:(NSString *)path query:(NSString*)query sequence:(NSString*)sequence callback:(RCTResponseSenderBlock)callback)
4143
{
@@ -49,43 +51,23 @@ @implementation FINMopsdk
4951
// 打开小程序
5052
dispatch_async(dispatch_get_main_queue(), ^{
5153
UIViewController *currentVC = [MOPTools topViewController];
52-
if (sequence == nil) {
53-
[[FATClient sharedClient] startRemoteApplet:appId startParams:params InParentViewController:currentVC completion:^(BOOL result, NSError *error) {
54-
NSLog(@"result:%d---error:%@", result, error);
55-
NSDictionary* ret;
56-
if (result){
57-
ret = @{
58-
@"success": @(YES),
59-
@"errMsg": @"openApplet:ok"
60-
};
61-
callback(@[[ret toJSONString]]);
62-
}else {
63-
ret = @{
64-
@"success": @(NO),
65-
@"errMsg": error.description
66-
};
67-
callback(@[[ret toJSONString]]);
68-
}
69-
}];
70-
}else{
71-
[[FATClient sharedClient] startRemoteApplet:appId sequence:@([sequence intValue]) startParams:params InParentViewController:currentVC transitionStyle:FATTranstionStylePush completion:^(BOOL result, NSError *error) {
72-
NSLog(@"result:%d---error:%@", result, error);
73-
NSDictionary* ret;
74-
if (result){
75-
ret = @{
76-
@"success": @(YES),
77-
@"errMsg": @"openApplet:ok"
78-
};
79-
callback(@[[ret toJSONString]]);
80-
}else {
81-
ret = @{
82-
@"success": @(NO),
83-
@"errMsg": error.description
84-
};
85-
callback(@[[ret toJSONString]]);
86-
}
87-
}];
88-
}
54+
[[FATClient sharedClient] startRemoteApplet:appId startParams:params InParentViewController:currentVC completion:^(BOOL result, NSError *error) {
55+
NSLog(@"result:%d---error:%@", result, error);
56+
NSDictionary* ret;
57+
if (result){
58+
ret = @{
59+
@"success": @(YES),
60+
@"errMsg": @"openApplet:ok"
61+
};
62+
callback(@[[ret toJSONString]]);
63+
}else {
64+
ret = @{
65+
@"success": @(NO),
66+
@"errMsg": error.description
67+
};
68+
callback(@[[ret toJSONString]]);
69+
}
70+
}];
8971
});
9072

9173
}

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
"licenseFilename": "LICENSE",
2424
"readmeFilename": "README.md",
2525
"peerDependencies": {
26-
"react": "^16.8.1",
2726
"react-native": ">=0.60.0-rc.0 <1.0.x"
2827
},
2928
"devDependencies": {
30-
"react": "^16.9.0",
3129
"react-native": "^0.61.5"
3230
}
3331
}

0 commit comments

Comments
 (0)