Skip to content

Commit dd11626

Browse files
[pigeon] Clean up legacy registrant code (#12205)
Now that the new APIs are available on stable, remove the view controller subclass workaround and use the standard scene-friendly registration system for channel code.
1 parent 1448f08 commit dd11626

3 files changed

Lines changed: 5 additions & 24 deletions

File tree

‎packages/pigeon/example/README.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,7 @@ Register the handler with the generated method.
439439
<?code-excerpt "ios/Runner/AppDelegate.swift (swift-init-event)"?>
440440
```swift
441441
let eventListener = EventListener()
442-
StreamEventsStreamHandler.register(
443-
with: controller.binaryMessenger, streamHandler: eventListener)
442+
StreamEventsStreamHandler.register(with: binaryMessenger, streamHandler: eventListener)
444443
```
445444

446445
### Kotlin

‎packages/pigeon/example/app/ios/Runner/AppDelegate.swift‎

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,33 +95,15 @@ func sendEvents(_ eventListener: EventListener) {
9595

9696
@main
9797
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
98-
override func application(
99-
_ application: UIApplication,
100-
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
101-
) -> Bool {
102-
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
103-
}
104-
10598
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
10699
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
107-
}
108-
}
109-
110-
// TODO(stuartmorgan): Once 3.33+ reaches stable, remove this subclass and move the setup to
111-
// AppDelegate.register(...). This approach is only used because this example needs to support
112-
// both stable and master, and 3.32 doesn't have FlutterPluginRegistrant, while 3.33+ can't use
113-
// the older application(didFinishLaunchingWithOptions) approach.
114-
@objc class ExampleViewController: FlutterViewController {
115-
override func awakeFromNib() {
116-
super.awakeFromNib()
117100

118101
let api = PigeonApiImplementation()
102+
let binaryMessenger = engineBridge.applicationRegistrar.messenger()
119103
ExampleHostApiSetup.setUp(binaryMessenger: binaryMessenger, api: api)
120-
let controller = self
121104
// #docregion swift-init-event
122105
let eventListener = EventListener()
123-
StreamEventsStreamHandler.register(
124-
with: controller.binaryMessenger, streamHandler: eventListener)
106+
StreamEventsStreamHandler.register(with: binaryMessenger, streamHandler: eventListener)
125107
// #enddocregion swift-init-event
126108
sendEvents(eventListener)
127109
}

‎packages/pigeon/example/app/ios/Runner/Base.lproj/Main.storyboard‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
88
</dependencies>
99
<scenes>
10-
<!--Example View Controller-->
10+
<!--Flutter View Controller-->
1111
<scene sceneID="tne-QT-ifu">
1212
<objects>
13-
<viewController id="BYZ-38-t0r" customClass="ExampleViewController" customModule="Runner" customModuleProvider="target" sceneMemberID="viewController">
13+
<viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController">
1414
<layoutGuides>
1515
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
1616
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>

0 commit comments

Comments
 (0)