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

* Customizable messenger

* rename
This commit is contained in:
xster
2017-08-23 18:50:14 -07:00
committed by GitHub
parent 3bf835e3cd
commit 5f93b1e9f3
2 changed files with 12 additions and 1 deletions

View File

@@ -29,6 +29,12 @@ FLUTTER_EXPORT
@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
#endif // FLUTTER_FLUTTERDARTPROJECT_H_

View File

@@ -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 {
NSAssert(self.pluginPublications[pluginKey] == nil, @"Duplicate plugin key: %@", pluginKey);
self.pluginPublications[pluginKey] = [NSNull null];
@@ -248,7 +253,7 @@
}
- (NSObject<FlutterBinaryMessenger>*)messenger {
return (FlutterViewController*)_appDelegate.window.rootViewController;
return [_appDelegate binaryMessenger];
}
- (void)publish:(NSObject*)value {