I’ve two targets in xcode: One iOS app and one watch App. The AppDelegate inside the iOS App has this code:
lazy var flutterEngine = FlutterEngine(title: "XXX")
personal var session: WCSession?
personal var channel: FlutterMethodChannel?
override func utility(
_ utility: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Runs the default Dart entrypoint with a default Flutter route.
flutterEngine.run()
// Watch
initWatchConnectivity()
initFlutterChannel()
// Used to attach plugins (solely in case you have plugins with iOS platform code).
GeneratedPluginRegistrant.register(with: self.flutterEngine)
Its necessary so as to add a FlutterEngine as a result of I work with one other ViewController (Splashviewcontroller with Lottie Animation) as entryPoint.
The SplashViewController Code is that this:
func startFlutterApp() {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let flutterEngine = appDelegate.flutterEngine
let flutterViewController =
FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)
appDelegate.window?.rootViewController = flutterViewController
}
However now my MethodChannel from Flutter shouldn’t be working anymore. I get:
Unhandled Exception: MissingPluginException(No implementation discovered for technique forwardToAppleWatch on channel xxx.xxx.xxx.watchkitapp)
Plainly it loses the MethodChannel perform from the appDelegate whereas the brand new ViewController is introduced.
With out the SplashViewController the MethodChannel is working completely, within the watch goal as nicely. How can I work with an additional view just like the splash controller and the MethodChannel on the identical time?