diff --git a/ios/Classes/Api/MOPAppletDelegate.m b/ios/Classes/Api/MOPAppletDelegate.m index 5d5a66c..da7c6cd 100644 --- a/ios/Classes/Api/MOPAppletDelegate.m +++ b/ios/Classes/Api/MOPAppletDelegate.m @@ -47,25 +47,39 @@ - (NSDictionary *)getUserInfoWithAppletInfo:(FATAppletInfo *)appletInfo { NSLog(@"getUserInfoWithAppletInfo"); __block NSDictionary *userInfo; + CFRunLoopRef runLoop = CFRunLoopGetCurrent(); + FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; [channel invokeMethod:@"extensionApi:getUserInfo" arguments:nil result:^(id _Nullable result) { - CFRunLoopStop(CFRunLoopGetMain()); +// CFRunLoopStop(CFRunLoopGetMain()); + CFRunLoopStop(runLoop); userInfo = result; }]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + CFRunLoopStop(runLoop); + }); CFRunLoopRun(); return userInfo; } - (BOOL)appletInfo:(FATAppletInfo *)appletInfo didClickMoreBtnAtPath:(NSString *)path { __block BOOL flag; + CFRunLoopRef runLoop = CFRunLoopGetCurrent(); + FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; NSLog(@"appletInfo:didClickMoreBtnAtPath,appId=%@,path=%@,channel=%@",appletInfo.appId,path,channel); [channel invokeMethod:@"extensionApi:customCapsuleMoreButtonClick" arguments:@{@"appId": appletInfo.appId} result:^(id _Nullable result) { - CFRunLoopStop(CFRunLoopGetMain()); +// CFRunLoopStop(CFRunLoopGetMain()); + CFRunLoopStop(runLoop); + if ([result isKindOfClass:[NSNumber class]]) { flag = [result boolValue]; } }]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + CFRunLoopStop(runLoop); + }); + CFRunLoopRun(); return flag; @@ -74,14 +88,20 @@ - (NSArray> *)customMenusInApplet:(FATAppletInfo *)appletInfo atPath:(NSString *)path { NSLog(@"customMenusInApplet:%@,appletInfo=%@",path,appletInfo); __block NSArray *list; + CFRunLoopRef runLoop = CFRunLoopGetCurrent(); FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; [channel invokeMethod:@"extensionApi:getCustomMenus" arguments:@{@"appId": appletInfo.appId} result:^(id _Nullable result) { - CFRunLoopStop(CFRunLoopGetMain()); +// CFRunLoopStop(CFRunLoopGetMain()); + CFRunLoopStop(runLoop); if ([result isKindOfClass:[NSArray class]]) { list = result; NSLog(@"customMenusInApplet2222:list=%@",list); } }]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + CFRunLoopStop(runLoop); + }); + CFRunLoopRun(); NSLog(@"customMenusInApplet:%@,list=%@",path,list);