From 4cefc7eeec42192c43f53e0e9d5abc1fe1e390b2 Mon Sep 17 00:00:00 2001 From: hujianhui Date: Fri, 31 Dec 2021 18:28:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B7=BB=E5=8A=A0=E5=88=B0?= =?UTF-8?q?=E6=A1=8C=E9=9D=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/MOPAppletDelegate.m | 3 -- ios/Classes/MopPlugin.h | 1 + ios/Classes/MopPlugin.m | 48 ++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/ios/Classes/Api/MOPAppletDelegate.m b/ios/Classes/Api/MOPAppletDelegate.m index 7ef475c..dab0502 100644 --- a/ios/Classes/Api/MOPAppletDelegate.m +++ b/ios/Classes/Api/MOPAppletDelegate.m @@ -78,9 +78,6 @@ FATAppletMenuStyle style = [typeString isEqualToString:@"onMiniProgram"] ? FATAppletMenuStyleOnMiniProgram : FATAppletMenuStyleCommon; model.menuType = style; } - if ([@"Desktop" isEqualToString:model.menuId] && FATAppletVersionTypeRelease != appletInfo.appletVersionType) { - continue; - } [models addObject:model]; } diff --git a/ios/Classes/MopPlugin.h b/ios/Classes/MopPlugin.h index 70db2b6..cd478db 100644 --- a/ios/Classes/MopPlugin.h +++ b/ios/Classes/MopPlugin.h @@ -8,6 +8,7 @@ @property MopEventStream *mopEventStreamHandler; @property FlutterMethodChannel *methodChannel; @property FlutterMethodChannel *shareMethodChannel; +@property FlutterMethodChannel *appletMethodChannel; + (instancetype) instance; @end diff --git a/ios/Classes/MopPlugin.m b/ios/Classes/MopPlugin.m index efa087b..26d2a08 100644 --- a/ios/Classes/MopPlugin.m +++ b/ios/Classes/MopPlugin.m @@ -48,6 +48,13 @@ static MopPlugin *_instance; binaryMessenger:[registrar messenger]]; [registrar addMethodCallDelegate:_instance channel:shareChannel]; _instance.shareMethodChannel = shareChannel; + + FlutterMethodChannel* appletChannel = [FlutterMethodChannel + methodChannelWithName:@"plugins.finosprite.finogeeks.com/applet" + binaryMessenger:[registrar messenger]]; + [registrar addMethodCallDelegate:_instance channel:appletChannel]; + _instance.appletMethodChannel = appletChannel; + } + (instancetype)instance{ @@ -58,7 +65,11 @@ static MopPlugin *_instance; - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { if ([@"getPlatformVersion" isEqualToString:call.method]) { result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]); - } else { + } + else if ([@"getAppletInfo" isEqualToString:call.method]) { + result([self appInfoDictWithAppId:call.arguments[@"appId"]]); + } + else { MOPApiRequest* request = [[MOPApiRequest alloc] init]; request.command = call.method; request.param = (NSDictionary*)call.arguments; @@ -106,4 +117,39 @@ static MopPlugin *_instance; return YES; } + +- (NSDictionary *)appInfoDictWithAppId:(NSString *)appId { + FATAppletInfo *info = [[FATClient sharedClient] currentApplet]; + if ([appId isEqualToString:info.appId]) { + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + dict[@"appId"] = info.appId; + switch (info.appletVersionType) { + case FATAppletVersionTypeRelease: { + dict[@"appType"] = @"release"; + break; + } + case FATAppletVersionTypeTrial: { + dict[@"appType"] = @"trial"; + break; + } + case FATAppletVersionTypeTemporary: { + dict[@"appType"] = @"temporary"; + break; + } + case FATAppletVersionTypeReview: { + dict[@"appType"] = @"review"; + break; + } + case FATAppletVersionTypeDevelopment: { + dict[@"appType"] = @"development"; + break; + } + + default: + break; + } + return dict; + } + return nil;; +} @end