我正在创建一个flutter x native swift 5集成,我需要访问本地zendesk模块,好的,但是当我按下native zendesk中的关闭按钮时它无法返回flutter。我找不到像我的问题一样的东西,也许这是我调用视图的方式,它在调用本机后消除了所有颤振堆栈。
我的 appDelegate.swift:
import UIKit
import Flutter
import ZendeskSDK
import ZendeskCoreSDK
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
var homeHelpView: ZendeskNavigationController!
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
var homeHelpView: ZendeskNavigationController!
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
let batteryChannel = FlutterMethodChannel(name: "uzzo_native_channel",
binaryMessenger: controller.binaryMessenger)
batteryChannel.setMethodCallHandler({
[weak self] (call: FlutterMethodCall, result: FlutterResult) -> Void in
guard call.method == "open_zendesk" else {
result(FlutterMethodNotImplemented)
return
}
let args = call.arguments as! Array<Any>
Zendesk.initialize(appId: "xxxxxxxxxxxxxxxxx",
clientId: "xxxxxxxxxxxxxxx",
zendeskUrl: "xxxxxxxxxxxxxx")
Support.initialize(withZendesk: Zendesk.instance)
let identity = Identity.createAnonymous(name: (args[1] as! String), email: (args[0] as! String))
Zendesk.instance?.setIdentity(identity)
self?.window = UIWindow(frame: UIScreen.main.bounds)
let config = RequestUiConfiguration()
config.tags = ["ios"]
let helpCenter = HelpCenterUi.buildHelpCenterOverviewUi()
homeHelpView = ZendeskNavigationController(rootViewController: helpCenter)
self?.window?.rootViewController = homeHelpView
self?.window?.makeKeyAndVisible()
})
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
这是 ZendeskNavigationController.swift
import ZendeskSDK
import ZendeskCoreSDK
import UIKit
class ZendeskNavigationController: UINavigationController, UINavigationControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let helpCenter = HelpCenterUi.buildHelpCenterOverviewUi(withConfigs: [])
pushViewController(helpCenter, animated: true)
self.navigationBar.shadowImage = UIImage()
self.navigationBar.isTranslucent = true
self.navigationBar.barTintColor = ConstantsColors.UZZOGreenColor
self.navigationBar.backgroundColor = ConstantsColors.UZZOGreenColor
self.navigationBar.titleTextAttributes = [
NSAttributedString.Key.foregroundColor: UIColor.darkText,
NSAttributedString.Key.font: UIFont.systemFont(ofSize: 28, weight: .heavy)]
self.delegate = self
self.navigationBar.backgroundColor = ConstantsColors.UZZOGreenColor
}
}