| 1234567891011121314151617181920212223242526272829303132 |
- //
- // MethodChannelManager.swift
- // Runner
- //
- // Created by Destiny on 2024/11/19.
- //
- import Flutter
- import UIKit
- class MethodChannelManager: NSObject {
-
- var channel: FlutterMethodChannel
-
- init(messager: FlutterBinaryMessenger) {
- channel = FlutterMethodChannel(name: "assistant_method_channel", binaryMessenger: messager)
- channel.setMethodCallHandler { (call , result) in
- print("接收到了来自Flutter发送的方法\(call.method)")
- result("我是原生返回给Flutter的消息")
- }
- }
-
- func sendMessage() {
- channel.invokeMethod("ios_method", arguments: "我是原生主动发送过来的") {(result) in
- print(result)
- }
- }
- }
|