diff --git a/android/build.gradle b/android/build.gradle index bb6af65..3622782 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -91,6 +91,6 @@ kapt { } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'com.finogeeks.lib:finapplet:2.33.3' - implementation 'com.finogeeks.mop:plugins:2.33.3' + implementation 'com.finogeeks.lib:finapplet:2.33.5' + implementation 'com.finogeeks.mop:plugins:2.33.5' } \ No newline at end of file diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java index 575de50..f892b22 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/BaseModule.java @@ -71,6 +71,8 @@ public class BaseModule extends BaseApi { if (encryptServerData == null) encryptServerData = false; Boolean debug = (Boolean) param.get("debug"); if (debug == null) debug = false; + Boolean bindAppletWithMainProcess = (Boolean) param.get("bindAppletWithMainProcess"); + if (bindAppletWithMainProcess == null) bindAppletWithMainProcess = false; FinAppConfig config = new FinAppConfig.Builder() .setSdkKey(appkey) @@ -82,6 +84,7 @@ public class BaseModule extends BaseApi { .setUserId(userId) .setDebugMode(debug) .setDisableRequestPermissions(disablePermission) + .setBindAppletWithMainProcess(bindAppletWithMainProcess) .build(); final Application application = MopPluginService.getInstance().getActivity().getApplication(); diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java index 70269da..b6cc51f 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java @@ -6,6 +6,7 @@ import android.os.Looper; import android.util.Log; import com.finogeeks.lib.applet.client.FinAppClient; +import com.finogeeks.lib.applet.client.FinAppTrace; import com.finogeeks.mop.api.BaseApi; import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.service.MopPluginService; @@ -22,6 +23,8 @@ import io.flutter.plugin.common.MethodChannel; public class ExtensionApiModule extends BaseApi { + private static final String TAG = "ExtensionApiModule"; + private Handler handler = new Handler(Looper.getMainLooper()); public ExtensionApiModule(Context context) { @@ -52,18 +55,33 @@ public class ExtensionApiModule extends BaseApi { @Override public void success(Object result) { String json = GsonUtil.gson.toJson(result); + FinAppTrace.d(ExtensionApiModule.TAG, "channel invokeMethod:" + name + + " success, result=" + result + ", json=" + json); JSONObject ret = null; - if (json != null && !json.equals("null")) + if (json != null && !json.equals("null")) { try { ret = new JSONObject(json); + if (ret.has("errMsg")) { + String errMsg = ret.getString("errMsg"); + if (errMsg.startsWith(name + ":fail")) { + iCallback.onFail(ret); + return; + } + } } catch (JSONException e) { e.printStackTrace(); } + } + iCallback.onSuccess(ret); } @Override public void error(String errorCode, String errorMessage, Object errorDetails) { + FinAppTrace.e(ExtensionApiModule.TAG, "channel invokeMethod:" + name + + " error, errorCode=" + errorCode + + ", errorMessage=" + errorMessage + + ", errorDetails=" + errorDetails); iCallback.onFail(); } diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 46de6ce..82c7661 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"mop","path":"/Users/beetle/Desktop/finogeeks/gitlab/finosprite/finclip-flutter-sdk/","dependencies":[]}],"android":[{"name":"mop","path":"/Users/beetle/Desktop/finogeeks/gitlab/finosprite/finclip-flutter-sdk/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"mop","dependencies":[]}],"date_created":"2021-08-13 09:53:09.007824","version":"2.2.2"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"mop","path":"/Users/beetle/Desktop/finogeeks/gitlab/finosprite/finclip-flutter-sdk/","dependencies":[]}],"android":[{"name":"mop","path":"/Users/beetle/Desktop/finogeeks/gitlab/finosprite/finclip-flutter-sdk/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"mop","dependencies":[]}],"date_created":"2021-08-19 15:38:17.756101","version":"2.2.2"} \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index 75c4c64..83d3ca0 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -87,7 +87,7 @@ packages: path: ".." relative: true source: path - version: "2.33.5" + version: "2.33.3" path: dependency: transitive description: diff --git a/ios/Classes/Api/MOP_registerExtensionApi.m b/ios/Classes/Api/MOP_registerExtensionApi.m index f4fd119..c1dedaf 100644 --- a/ios/Classes/Api/MOP_registerExtensionApi.m +++ b/ios/Classes/Api/MOP_registerExtensionApi.m @@ -22,15 +22,28 @@ NSString* api = [@"extensionApi:" stringByAppendingString:self.name]; [channel invokeMethod:api arguments:param result:^(id _Nullable result) { NSLog(@"extensionApi reslut:%@",result); - if([result isKindOfClass:[FlutterError class]] || result == FlutterMethodNotImplemented) - { + // 先判断是否flutter发生错误 + BOOL isFlutterError = [result isKindOfClass:[FlutterError class]] || result == FlutterMethodNotImplemented; + if (isFlutterError) { NSLog(@"extensionApi reslut:fail"); callback(FATExtensionCodeFailure,nil); - }else - { - NSLog(@"extensionApi callback:%@",result); - callback(FATExtensionCodeSuccess,result); + return; } + // 再判断回调是否为失败 + BOOL hasError = [[result allKeys] containsObject:@"errMsg"]; + if (hasError) { + NSString *errMsg = result[@"errMsg"]; + NSString *errPrefix = [NSString stringWithFormat:@"%@:fail", self.name]; + BOOL isFail = [errMsg hasPrefix:errPrefix]; + if (isFail) { + NSLog(@"extensionApi reslut:fail"); + callback(FATExtensionCodeFailure,nil); + return; + } + } + // 其他的按成功处理 + NSLog(@"extensionApi callback:%@",result); + callback(FATExtensionCodeSuccess,result); }]; }]; success(@{}); diff --git a/ios/mop.podspec b/ios/mop.podspec index 62aa5d0..84ba3bf 100644 --- a/ios/mop.podspec +++ b/ios/mop.podspec @@ -17,7 +17,8 @@ A finclip miniprogram flutter sdk. s.dependency 'Flutter' s.ios.deployment_target = '9.0' - s.dependency 'FinApplet' , '2.33.3' - s.dependency 'FinAppletExt' , '2.33.3' + s.dependency 'FinApplet' , '2.33.8-alpha20210826v03' + s.dependency 'FinAppletExt' , '2.33.8-alpha20210826v03' + end diff --git a/lib/mop.dart b/lib/mop.dart index 7590e2d..e422084 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -76,7 +76,8 @@ class Mop { bool disablePermission, String userId, bool encryptServerData = false, - bool debug = false}) async { + bool debug = false, + bool bindAppletWithMainProcess = false}) async { final Map ret = await _channel.invokeMethod('initialize', { 'appkey': appkey, 'secret': secret, @@ -86,7 +87,8 @@ class Mop { 'disablePermission': disablePermission, 'userId': userId, "encryptServerData": encryptServerData, - "debug": debug + "debug": debug, + "bindAppletWithMainProcess": bindAppletWithMainProcess }); return ret; } diff --git a/pubspec.yaml b/pubspec.yaml index 5356e25..347f6d6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: mop description: A Finogeeks MiniProgram Flutter SDK. -version: '2.33.3' +version: '2.33.5' homepage: https://github.com/finogeeks/mop-flutter-sdk environment: