diff --git a/android/build.gradle b/android/build.gradle index 5d64687..019b617 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.8.77' + implementation 'com.finogeeks.lib:finapplet:2.9.2' } diff --git a/android/src/main/java/com/finogeeks/mop/api/ApisManager.java b/android/src/main/java/com/finogeeks/mop/api/ApisManager.java index 1d3152b..c9dca8b 100644 --- a/android/src/main/java/com/finogeeks/mop/api/ApisManager.java +++ b/android/src/main/java/com/finogeeks/mop/api/ApisManager.java @@ -8,6 +8,7 @@ import com.finogeeks.mop.api.mop.AppletManageModule; import com.finogeeks.mop.api.mop.AppletModule; import com.finogeeks.mop.api.mop.BaseModule; import com.finogeeks.mop.api.mop.ExtensionApiModule; +import com.finogeeks.mop.api.mop.VersionModule; import com.finogeeks.mop.interfaces.Event; import com.finogeeks.mop.interfaces.IApi; @@ -67,6 +68,7 @@ public class ApisManager { add(new AppletManageModule(activity)); add(new AppletHandlerModule(activity)); add(new ExtensionApiModule(activity)); + add(new VersionModule(activity)); } private void add(IApi api) { diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/VersionModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/VersionModule.java new file mode 100644 index 0000000..7088f3f --- /dev/null +++ b/android/src/main/java/com/finogeeks/mop/api/mop/VersionModule.java @@ -0,0 +1,27 @@ +package com.finogeeks.mop.api.mop; + + +import android.content.Context; + +import com.finogeeks.lib.applet.BuildConfig; +import com.finogeeks.mop.api.BaseApi; +import com.finogeeks.mop.interfaces.ICallback; + +import java.util.Map; + +public class VersionModule extends BaseApi { + + public VersionModule(Context context) { + super(context); + } + + @Override + public String[] apis() { + return new String[]{"sdkVersion"}; + } + + @Override + public void invoke(String event, Map param, ICallback callback) { + callback.onSuccess(BuildConfig.VERSION_NAME); + } +} diff --git a/ios/Classes/Api/MOP_sdkVersion.h b/ios/Classes/Api/MOP_sdkVersion.h new file mode 100644 index 0000000..03fe5d4 --- /dev/null +++ b/ios/Classes/Api/MOP_sdkVersion.h @@ -0,0 +1,17 @@ +// +// MOP_sdkVersion.h +// mop +// +// Created by 康旭耀 on 2020/7/22. +// + +#import +#import "MOPBaseApi.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MOP_sdkVersion : MOPBaseApi + +@end + +NS_ASSUME_NONNULL_END diff --git a/ios/Classes/Api/MOP_sdkVersion.m b/ios/Classes/Api/MOP_sdkVersion.m new file mode 100644 index 0000000..f0509c8 --- /dev/null +++ b/ios/Classes/Api/MOP_sdkVersion.m @@ -0,0 +1,20 @@ +// +// MOP_sdkVersion.m +// mop +// +// Created by 康旭耀 on 2020/7/22. +// + +#import "MOP_sdkVersion.h" +#import + +@implementation MOP_sdkVersion + +- (void)setupApiWithSuccess:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel +{ + NSLog(@"sdkVersion"); + NSString *version = [[FATClient sharedClient] version]; + success(version); +} + +@end diff --git a/lib/mop.dart b/lib/mop.dart index d27cb5a..8f51b33 100644 --- a/lib/mop.dart +++ b/lib/mop.dart @@ -129,6 +129,15 @@ class Mop { return await _channel.invokeMethod("clearApplets"); } + /// + /// 获取运行时版本号 + /// + Future sdkVersion() async { + return await _channel + .invokeMapMethod("sdkVersion") + .then((value) => value["data"]); + } + /// /// register handler to provide custom info or behaviour /// 注册小程序事件处理