AppDelegate.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import Flutter
  2. import UIKit
  3. @main
  4. @objc class AppDelegate: FlutterAppDelegate {
  5. override func application(
  6. _ application: UIApplication,
  7. didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  8. ) -> Bool {
  9. GeneratedPluginRegistrant.register(with: self)
  10. let controller = window?.rootViewController as! FlutterViewController
  11. FlutterMethodChannelManager.shared.setupMethodChannels(controller: controller)
  12. return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  13. }
  14. override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
  15. // 解析URL参数
  16. let components = URLComponents(url: url, resolvingAgainstBaseURL: true)
  17. let path = url.path
  18. // 将URL信息传递给Flutter
  19. let controller = window?.rootViewController as! FlutterViewController
  20. let channel = FlutterMethodChannel(name: "keyboard_ios", binaryMessenger: controller.binaryMessenger)
  21. if path == "/login" {
  22. channel.invokeMethod("navigateToLogin", arguments: nil)
  23. } else if path == "/member" {
  24. channel.invokeMethod("navigateToMember", arguments: nil)
  25. } else if path == "/character/market" {
  26. channel.invokeMethod("navigateToCharacterMarket", arguments: nil)
  27. } else if path == "/intimacy" {
  28. channel.invokeMethod("navigateToIntimacy", arguments: nil)
  29. } else if path == "/character/custom" {
  30. channel.invokeMethod("navigateToCustomCharacter", arguments: nil)
  31. }
  32. return true
  33. }
  34. }