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