I’ve two targets in xcode: One iOS app and one watch App. The AppDelegate throughout the iOS App has this code:
lazy var flutterEngine = FlutterEngine(identify: "XXX")
non-public var session: WCSession?
non-public var channel: FlutterMethodChannel?
override func software(
_ software: 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 when you've got plugins with iOS platform code).
GeneratedPluginRegistrant.register(with: self.flutterEngine)
Its essential 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 methodology forwardToAppleWatch on channel xxx.xxx.xxx.watchkitapp)
Evidently it loses the MethodChannel perform from the appDelegate whereas the brand new ViewController is offered.
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?