From 0a25869196641ca914ac76534d07f9eb7423be40 Mon Sep 17 00:00:00 2001 From: kangxuyao Date: Wed, 22 Jul 2020 15:30:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BF=90=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.gradle | 2 +- .../com/finogeeks/mop/api/ApisManager.java | 2 ++ .../finogeeks/mop/api/mop/VersionModule.java | 27 +++++++++++++++++++ ios/Classes/Api/MOP_sdkVersion.h | 17 ++++++++++++ ios/Classes/Api/MOP_sdkVersion.m | 20 ++++++++++++++ lib/mop.dart | 9 +++++++ 6 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 android/src/main/java/com/finogeeks/mop/api/mop/VersionModule.java create mode 100644 ios/Classes/Api/MOP_sdkVersion.h create mode 100644 ios/Classes/Api/MOP_sdkVersion.m 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 /// 注册小程序事件处理