Nevar pievienot vairāk kā 25 tēmas
Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
|
- //
- // ZhiyingCommNative.m
- // hairuyi_flutter_comm
- //
- // Created by Weller on 2020/5/16.
- //
- #import <Flutter/Flutter.h>
- #import "ZhiyingCommNative.h"
- #import "ZhiyingCommNativeResult.h"
-
- @implementation ZhiyingCommNative
-
-
- static id<ZhiyingCommNativeProtocol> _delegate;
-
- + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
- FlutterMethodChannel* channel = [FlutterMethodChannel
- methodChannelWithName:@"hairuyi_flutter_comm://method"
- binaryMessenger:[registrar messenger]];
- ZhiyingCommNative* instance = [[ZhiyingCommNative alloc] init];
- [registrar addMethodCallDelegate:instance channel:channel];
- }
-
-
- - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
- if ([@"openPage" isEqualToString:call.method]) {
- if ([_delegate respondsToSelector:@selector(openPage:)]) {
- [_delegate openPage:call.arguments];
- }
- result(@{@"success": @"1"});
- } else if ([@"openNativePage" isEqualToString:call.method]) {
- if ([_delegate respondsToSelector:@selector(openNativePage:)]) {
- [_delegate openNativePage:call.arguments];
- }
- result(@{@"success": @"1"});
- } else if ([@"getSetting" isEqualToString:call.method]) {
- NSDictionary *setting = @{};
- if ([_delegate respondsToSelector:@selector(getSetting)]) {
- setting = [_delegate getSetting];
- }
- result(setting);
- } else if ([@"openWechatPay" isEqualToString:call.method]) {
- if ([_delegate respondsToSelector:@selector(openWechatPay:status:)]) {
- [_delegate openWechatPay: call.arguments status: ^(ZhiyingCommNativeResult *res) {
- result([res toDict]);
- }];
- } else {
- result([NativeCommandNotImp toDict]);
- }
- } else if ([@"invokeMethod" isEqualToString:call.method]) {
- NSDictionary *dict = call.arguments;
- NSString *method = [dict valueForKey:@"method"];
- NSDictionary *params = [dict valueForKey:@"params"];
- if ([_delegate respondsToSelector:@selector(invokeMethod:withParams:status:)]) {
- [_delegate invokeMethod:method withParams: params status: ^(ZhiyingCommNativeResult *res) {
- result([res toDict]);
- }];
- } else {
- result([NativeCommandNotImp toDict]);
- }
- } else{
- result(FlutterMethodNotImplemented);
- }
- }
-
- + (void)regist:(id<ZhiyingCommNativeProtocol>) delegate {
- _delegate = delegate;
- }
-
- @end
|