flutter IOS 原生交互同一个插件多个方法调用
由于代码比价简单直接上代码
ios/Runner/AppDelegate.swift
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
      GeneratedPluginRegistrant.register(with: self)
      
      let messenger : FlutterBinaryMessenger = window?.rootViewController as! FlutterBinaryMessenger
         
     testPlugin(messenger: messenger)
      
      
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}
func testPlugin(messenger: FlutterBinaryMessenger) {
   let channel = FlutterMethodChannel(name: "plugin_apple", binaryMessenger: messenger)
   channel.setMethodCallHandler { (call:FlutterMethodCall, result:@escaping FlutterResult) in
   
       if (call.method == "apple_one") {
           result(["result":"success","code":200]);
       }
       
       if (call.method == "apple_two") {
           result(["result":"success","code":404]);
       }
   }
}
本文来自博客园,作者:vx_guanchaoguo0,转载请注明原文链接:https://www.cnblogs.com/guanchaoguo/p/17932668.html
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号