提交 8776c934 编写于 作者: X xster 提交者: GitHub

Let the FlutterAppDelegate's messenger be customizable if the...

Let the FlutterAppDelegate's messenger be customizable if the rootViewController isn't a FlutterViewController (#3916)

* Customizable messenger

* rename
上级 3e245ae8
...@@ -29,6 +29,12 @@ FLUTTER_EXPORT ...@@ -29,6 +29,12 @@ FLUTTER_EXPORT
@property(strong, nonatomic) UIWindow* window; @property(strong, nonatomic) UIWindow* window;
// Can be overriden by subclasses to provide a custom FlutterBinaryMessenger,
// typically a FlutterViewController, for plugin interop.
//
// Defaults to window's rootViewController.
- (NSObject<FlutterBinaryMessenger>*) binaryMessenger;
@end @end
#endif // FLUTTER_FLUTTERDARTPROJECT_H_ #endif // FLUTTER_FLUTTERDARTPROJECT_H_
...@@ -212,6 +212,11 @@ ...@@ -212,6 +212,11 @@
} }
} }
// TODO(xster): move when doing https://github.com/flutter/flutter/issues/3671.
- (NSObject<FlutterBinaryMessenger>*)binaryMessenger {
return self.rootFlutterViewController;
}
- (NSObject<FlutterPluginRegistrar>*)registrarForPlugin:(NSString*)pluginKey { - (NSObject<FlutterPluginRegistrar>*)registrarForPlugin:(NSString*)pluginKey {
NSAssert(self.pluginPublications[pluginKey] == nil, @"Duplicate plugin key: %@", pluginKey); NSAssert(self.pluginPublications[pluginKey] == nil, @"Duplicate plugin key: %@", pluginKey);
self.pluginPublications[pluginKey] = [NSNull null]; self.pluginPublications[pluginKey] = [NSNull null];
...@@ -248,7 +253,7 @@ ...@@ -248,7 +253,7 @@
} }
- (NSObject<FlutterBinaryMessenger>*)messenger { - (NSObject<FlutterBinaryMessenger>*)messenger {
return (FlutterViewController*)_appDelegate.window.rootViewController; return [_appDelegate binaryMessenger];
} }
- (void)publish:(NSObject*)value { - (void)publish:(NSObject*)value {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册