@@ -19,23 +19,25 @@ @implementation FINMopsdk
19
19
FATConfig *config = [FATConfig configWithAppSecret: secret appKey: appkey];
20
20
config.apiServer = [apiServer copy ];
21
21
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
+
26
35
ret = @{
27
- @" success" : @(NO ),
28
- @" errMsg" : [ NSString stringWithFormat: @" 初始化小程序引擎失败 %@ " ,error.localizedDescription]
36
+ @" success" : @(YES ),
37
+ @" errMsg" : @" initialize:ok "
29
38
};
30
39
callback (@[[ret toJSONString ]]);
31
- return ;
32
- }
33
-
34
- ret = @{
35
- @" success" : @(YES ),
36
- @" errMsg" : @" initialize:ok"
37
- };
38
- callback (@[[ret toJSONString ]]);
40
+ });
39
41
}
40
42
RCT_EXPORT_METHOD (openApplet:(nonnull NSString *)appId path:(NSString *)path query:(NSString *)query sequence:(NSString *)sequence callback:(RCTResponseSenderBlock)callback)
41
43
{
@@ -49,43 +51,23 @@ @implementation FINMopsdk
49
51
// 打开小程序
50
52
dispatch_async (dispatch_get_main_queue (), ^{
51
53
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
+ }];
89
71
});
90
72
91
73
}
0 commit comments