@@ -120,6 +120,8 @@ class NotificationsPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable
120120 static let shared = NotificationsPigeonCodec ( readerWriter: NotificationsPigeonCodecReaderWriter ( ) )
121121}
122122
123+ var notificationsPigeonMethodCodec = FlutterStandardMethodCodec ( readerWriter: NotificationsPigeonCodecReaderWriter ( ) ) ;
124+
123125/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
124126protocol NotificationHostApi {
125127 /// Retrieves notification data if the app was launched by tapping on a notification.
@@ -154,3 +156,67 @@ class NotificationHostApiSetup {
154156 }
155157 }
156158}
159+
160+ private class PigeonStreamHandler < ReturnType> : NSObject , FlutterStreamHandler {
161+ private let wrapper : PigeonEventChannelWrapper < ReturnType >
162+ private var pigeonSink : PigeonEventSink < ReturnType > ? = nil
163+
164+ init ( wrapper: PigeonEventChannelWrapper < ReturnType > ) {
165+ self . wrapper = wrapper
166+ }
167+
168+ func onListen( withArguments arguments: Any ? , eventSink events: @escaping FlutterEventSink )
169+ -> FlutterError ?
170+ {
171+ pigeonSink = PigeonEventSink < ReturnType > ( events)
172+ wrapper. onListen ( withArguments: arguments, sink: pigeonSink!)
173+ return nil
174+ }
175+
176+ func onCancel( withArguments arguments: Any ? ) -> FlutterError ? {
177+ pigeonSink = nil
178+ wrapper. onCancel ( withArguments: arguments)
179+ return nil
180+ }
181+ }
182+
183+ class PigeonEventChannelWrapper < ReturnType> {
184+ func onListen( withArguments arguments: Any ? , sink: PigeonEventSink < ReturnType > ) { }
185+ func onCancel( withArguments arguments: Any ? ) { }
186+ }
187+
188+ class PigeonEventSink < ReturnType> {
189+ private let sink : FlutterEventSink
190+
191+ init ( _ sink: @escaping FlutterEventSink ) {
192+ self . sink = sink
193+ }
194+
195+ func success( _ value: ReturnType ) {
196+ sink ( value)
197+ }
198+
199+ func error( code: String , message: String ? , details: Any ? ) {
200+ sink ( FlutterError ( code: code, message: message, details: details) )
201+ }
202+
203+ func endOfStream( ) {
204+ sink ( FlutterEndOfEventStream)
205+ }
206+
207+ }
208+
209+ class NotificationTapEventsStreamHandler : PigeonEventChannelWrapper < NotificationPayloadForOpen > {
210+ static func register( with messenger: FlutterBinaryMessenger ,
211+ instanceName: String = " " ,
212+ streamHandler: NotificationTapEventsStreamHandler ) {
213+ var channelName = " dev.flutter.pigeon.zulip.NotificationHostEvents.notificationTapEvents "
214+ if !instanceName. isEmpty {
215+ channelName += " . \( instanceName) "
216+ }
217+ let internalStreamHandler = PigeonStreamHandler < NotificationPayloadForOpen > ( wrapper: streamHandler)
218+ let channel = FlutterEventChannel ( name: channelName, binaryMessenger: messenger, codec: notificationsPigeonMethodCodec)
219+ channel. setStreamHandler ( internalStreamHandler)
220+ }
221+ }
222+
0 commit comments