From b860cb8a93b24937c48b98a3c238a93cb6ac27fc Mon Sep 17 00:00:00 2001 From: kangxuyao Date: Mon, 27 Apr 2020 18:55:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Classes/Api/MOPAppletDelegate.h | 2 ++ ios/Classes/Api/MOPAppletDelegate.m | 12 +++++++++++- ios/Classes/Api/MOP_registerAppletHandler.m | 3 +-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ios/Classes/Api/MOPAppletDelegate.h b/ios/Classes/Api/MOPAppletDelegate.h index c44aa0c..0fab813 100644 --- a/ios/Classes/Api/MOPAppletDelegate.h +++ b/ios/Classes/Api/MOPAppletDelegate.h @@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN @interface MOPAppletDelegate : NSObject ++ (instancetype)instance; + @end NS_ASSUME_NONNULL_END diff --git a/ios/Classes/Api/MOPAppletDelegate.m b/ios/Classes/Api/MOPAppletDelegate.m index 9f00dfd..614dbd7 100644 --- a/ios/Classes/Api/MOPAppletDelegate.m +++ b/ios/Classes/Api/MOPAppletDelegate.m @@ -10,11 +10,21 @@ @implementation MOPAppletDelegate ++ (instancetype)instance +{ + static MOPAppletDelegate *_instance; + static dispatch_once_t once; + dispatch_once(&once, ^{ + _instance = [[self alloc] init]; + }); + return _instance; +} + - (void)forwardAppletWithInfo:(NSDictionary *)contentInfo completion:(void (^)(FATExtensionCode, NSDictionary *))completion { NSLog(@"forwardAppletWithInfo:%@",contentInfo); FlutterMethodChannel *channel = [[MopPlugin instance] methodChannel]; - [channel invokeMethod:@"extensionApi:forwardApplet" arguments:contentInfo result:^(id _Nullable result) { + [channel invokeMethod:@"extensionApi:forwardApplet" arguments:@{@"appletInfo":contentInfo} result:^(id _Nullable result) { if([result isKindOfClass:[FlutterError class]]|| [result isKindOfClass:[FlutterMethodNotImplemented class] ]) { completion(FATExtensionCodeFailure,nil); diff --git a/ios/Classes/Api/MOP_registerAppletHandler.m b/ios/Classes/Api/MOP_registerAppletHandler.m index 2fb6f63..a1a0b63 100644 --- a/ios/Classes/Api/MOP_registerAppletHandler.m +++ b/ios/Classes/Api/MOP_registerAppletHandler.m @@ -15,8 +15,7 @@ - (void)setupApiWithSuccess:(void (^)(NSDictionary * _Nonnull))success failure:(void (^)(id _Nullable))failure cancel:(void (^)(void))cancel { NSLog(@"MOP_registerAppletHandler"); - [[FATClient sharedClient] setDelegate:[[MOPAppletDelegate alloc] init]]; - + [FATClient sharedClient].delegate = [MOPAppletDelegate instance]; } @end