|
| 1 | +// Autogenerated from Pigeon (v25.0.0), do not edit directly. |
| 2 | +// See also: https://pub.dev/packages/pigeon |
| 3 | + |
| 4 | +import Foundation |
| 5 | + |
| 6 | +#if os(iOS) |
| 7 | + import Flutter |
| 8 | +#elseif os(macOS) |
| 9 | + import FlutterMacOS |
| 10 | +#else |
| 11 | + #error("Unsupported platform.") |
| 12 | +#endif |
| 13 | + |
| 14 | +/// Error class for passing custom error details to Dart side. |
| 15 | +final class PigeonError: Error { |
| 16 | + let code: String |
| 17 | + let message: String? |
| 18 | + let details: Sendable? |
| 19 | + |
| 20 | + init(code: String, message: String?, details: Sendable?) { |
| 21 | + self.code = code |
| 22 | + self.message = message |
| 23 | + self.details = details |
| 24 | + } |
| 25 | + |
| 26 | + var localizedDescription: String { |
| 27 | + return |
| 28 | + "PigeonError(code: \(code), message: \(message ?? "<nil>"), details: \(details ?? "<nil>")" |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +private func wrapResult(_ result: Any?) -> [Any?] { |
| 33 | + return [result] |
| 34 | +} |
| 35 | + |
| 36 | +private func wrapError(_ error: Any) -> [Any?] { |
| 37 | + if let pigeonError = error as? PigeonError { |
| 38 | + return [ |
| 39 | + pigeonError.code, |
| 40 | + pigeonError.message, |
| 41 | + pigeonError.details, |
| 42 | + ] |
| 43 | + } |
| 44 | + if let flutterError = error as? FlutterError { |
| 45 | + return [ |
| 46 | + flutterError.code, |
| 47 | + flutterError.message, |
| 48 | + flutterError.details, |
| 49 | + ] |
| 50 | + } |
| 51 | + return [ |
| 52 | + "\(error)", |
| 53 | + "\(type(of: error))", |
| 54 | + "Stacktrace: \(Thread.callStackSymbols)", |
| 55 | + ] |
| 56 | +} |
| 57 | + |
| 58 | +private func isNullish(_ value: Any?) -> Bool { |
| 59 | + return value is NSNull || value == nil |
| 60 | +} |
| 61 | + |
| 62 | +private func nilOrValue<T>(_ value: Any?) -> T? { |
| 63 | + if value is NSNull { return nil } |
| 64 | + return value as! T? |
| 65 | +} |
| 66 | + |
| 67 | +/// Generated class from Pigeon that represents data sent in messages. |
| 68 | +struct NotificationDataFromLaunch { |
| 69 | + /// The raw payload that is attached to the notification, |
| 70 | + /// holding the information required to carry out the navigation. |
| 71 | + var payload: [AnyHashable?: Any?] |
| 72 | + |
| 73 | + |
| 74 | + // swift-format-ignore: AlwaysUseLowerCamelCase |
| 75 | + static func fromList(_ pigeonVar_list: [Any?]) -> NotificationDataFromLaunch? { |
| 76 | + let payload = pigeonVar_list[0] as! [AnyHashable?: Any?] |
| 77 | + |
| 78 | + return NotificationDataFromLaunch( |
| 79 | + payload: payload |
| 80 | + ) |
| 81 | + } |
| 82 | + func toList() -> [Any?] { |
| 83 | + return [ |
| 84 | + payload |
| 85 | + ] |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | +private class NotificationsPigeonCodecReader: FlutterStandardReader { |
| 90 | + override func readValue(ofType type: UInt8) -> Any? { |
| 91 | + switch type { |
| 92 | + case 129: |
| 93 | + return NotificationDataFromLaunch.fromList(self.readValue() as! [Any?]) |
| 94 | + default: |
| 95 | + return super.readValue(ofType: type) |
| 96 | + } |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | +private class NotificationsPigeonCodecWriter: FlutterStandardWriter { |
| 101 | + override func writeValue(_ value: Any) { |
| 102 | + if let value = value as? NotificationDataFromLaunch { |
| 103 | + super.writeByte(129) |
| 104 | + super.writeValue(value.toList()) |
| 105 | + } else { |
| 106 | + super.writeValue(value) |
| 107 | + } |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | +private class NotificationsPigeonCodecReaderWriter: FlutterStandardReaderWriter { |
| 112 | + override func reader(with data: Data) -> FlutterStandardReader { |
| 113 | + return NotificationsPigeonCodecReader(data: data) |
| 114 | + } |
| 115 | + |
| 116 | + override func writer(with data: NSMutableData) -> FlutterStandardWriter { |
| 117 | + return NotificationsPigeonCodecWriter(data: data) |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +class NotificationsPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable { |
| 122 | + static let shared = NotificationsPigeonCodec(readerWriter: NotificationsPigeonCodecReaderWriter()) |
| 123 | +} |
| 124 | + |
| 125 | +/// Generated protocol from Pigeon that represents a handler of messages from Flutter. |
| 126 | +protocol NotificationHostApi { |
| 127 | + /// Retrieves notification data if the app was launched by tapping on a notification. |
| 128 | + /// |
| 129 | + /// Returns `launchOptions.remoteNotification`, |
| 130 | + /// which is the raw APNs data dictionary |
| 131 | + /// if the app launch was opened by a notification tap, |
| 132 | + /// else null. See Apple doc: |
| 133 | + /// https://developer.apple.com/documentation/uikit/uiapplication/launchoptionskey/remotenotification |
| 134 | + func getNotificationDataFromLaunch() throws -> NotificationDataFromLaunch? |
| 135 | +} |
| 136 | + |
| 137 | +/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. |
| 138 | +class NotificationHostApiSetup { |
| 139 | + static var codec: FlutterStandardMessageCodec { NotificationsPigeonCodec.shared } |
| 140 | + /// Sets up an instance of `NotificationHostApi` to handle messages through the `binaryMessenger`. |
| 141 | + static func setUp(binaryMessenger: FlutterBinaryMessenger, api: NotificationHostApi?, messageChannelSuffix: String = "") { |
| 142 | + let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : "" |
| 143 | + /// Retrieves notification data if the app was launched by tapping on a notification. |
| 144 | + /// |
| 145 | + /// Returns `launchOptions.remoteNotification`, |
| 146 | + /// which is the raw APNs data dictionary |
| 147 | + /// if the app launch was opened by a notification tap, |
| 148 | + /// else null. See Apple doc: |
| 149 | + /// https://developer.apple.com/documentation/uikit/uiapplication/launchoptionskey/remotenotification |
| 150 | + let getNotificationDataFromLaunchChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.zulip.NotificationHostApi.getNotificationDataFromLaunch\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) |
| 151 | + if let api = api { |
| 152 | + getNotificationDataFromLaunchChannel.setMessageHandler { _, reply in |
| 153 | + do { |
| 154 | + let result = try api.getNotificationDataFromLaunch() |
| 155 | + reply(wrapResult(result)) |
| 156 | + } catch { |
| 157 | + reply(wrapError(error)) |
| 158 | + } |
| 159 | + } |
| 160 | + } else { |
| 161 | + getNotificationDataFromLaunchChannel.setMessageHandler(nil) |
| 162 | + } |
| 163 | + } |
| 164 | +} |
0 commit comments