You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.6 KiB
49 lines
1.6 KiB
import Flutter
|
|
import UIKit
|
|
|
|
@main
|
|
@objc class AppDelegate: FlutterAppDelegate {
|
|
override func application(
|
|
_ application: UIApplication,
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
) -> Bool {
|
|
application.applicationIconBadgeNumber = 0
|
|
GeneratedPluginRegistrant.register(with: self)
|
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
}
|
|
|
|
override func applicationDidBecomeActive(_ application: UIApplication) {
|
|
application.applicationIconBadgeNumber = 0
|
|
super.applicationDidBecomeActive(application)
|
|
}
|
|
|
|
// 添加URL回调监听
|
|
override func application(
|
|
_ app: UIApplication,
|
|
open url: URL,
|
|
options: [UIApplication.OpenURLOptionsKey : Any] = [:]
|
|
) -> Bool {
|
|
print("AppDelegate收到URL回调: \(url.absoluteString)")
|
|
|
|
// 首先尝试让父类处理
|
|
if super.application(app, open: url, options: options) {
|
|
return true
|
|
}
|
|
|
|
// 检查是否是Eaimar相关的URL
|
|
if url.scheme == "eaimar" {
|
|
print("处理 eaimar URL: \(url.absoluteString)")
|
|
|
|
// 通过Flutter的方法通道通知QQ音乐插件处理这个URL
|
|
if let flutterViewController = window?.rootViewController as? FlutterViewController {
|
|
let channel = FlutterMethodChannel(name: "qq_music", binaryMessenger: flutterViewController.binaryMessenger)
|
|
channel.invokeMethod("openUrl", arguments: ["url": url.absoluteString]) { result in
|
|
print("QQ音乐插件处理URL结果: \(String(describing: result))")
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
}
|
|
|