Files
packages.dart/packages/app_review/ios/Classes/Messages.g.swift
T
2026-01-15 00:37:49 -08:00

242 lines
8.7 KiB
Swift

// Autogenerated from Pigeon (v26.1.5), do not edit directly.
// See also: https://pub.dev/packages/pigeon
import Foundation
#if os(iOS)
import Flutter
#elseif os(macOS)
import FlutterMacOS
#else
#error("Unsupported platform.")
#endif
/// Error class for passing custom error details to Dart side.
final class PigeonError: Error {
let code: String
let message: String?
let details: Sendable?
init(code: String, message: String?, details: Sendable?) {
self.code = code
self.message = message
self.details = details
}
var localizedDescription: String {
return
"PigeonError(code: \(code), message: \(message ?? "<nil>"), details: \(details ?? "<nil>")"
}
}
private func wrapResult(_ result: Any?) -> [Any?] {
return [result]
}
private func wrapError(_ error: Any) -> [Any?] {
if let pigeonError = error as? PigeonError {
return [
pigeonError.code,
pigeonError.message,
pigeonError.details,
]
}
if let flutterError = error as? FlutterError {
return [
flutterError.code,
flutterError.message,
flutterError.details,
]
}
return [
"\(error)",
"\(type(of: error))",
"Stacktrace: \(Thread.callStackSymbols)",
]
}
private func isNullish(_ value: Any?) -> Bool {
return value is NSNull || value == nil
}
private func nilOrValue<T>(_ value: Any?) -> T? {
if value is NSNull { return nil }
return value as! T?
}
private class MessagesPigeonCodecReader: FlutterStandardReader {
}
private class MessagesPigeonCodecWriter: FlutterStandardWriter {
}
private class MessagesPigeonCodecReaderWriter: FlutterStandardReaderWriter {
override func reader(with data: Data) -> FlutterStandardReader {
return MessagesPigeonCodecReader(data: data)
}
override func writer(with data: NSMutableData) -> FlutterStandardWriter {
return MessagesPigeonCodecWriter(data: data)
}
}
class MessagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable {
static let shared = MessagesPigeonCodec(readerWriter: MessagesPigeonCodecReaderWriter())
}
/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
protocol AppReviewApi {
/// Request review.
///
/// Tells StoreKit / Play Store to ask the user to rate or review your app, if appropriate.
/// Supported only in iOS 10.3+ and Android with Play Services installed (see [isRequestReviewAvailable]).
///
/// Returns string with details message.
func requestReview(testMode: Bool, completion: @escaping (Result<String?, Error>) -> Void)
/// Check if [requestReview] feature available.
func isRequestReviewAvailable(completion: @escaping (Result<Bool, Error>) -> Void)
/// Opens the store listing for the specified app.
///
/// [storeId] is the package name (Android) or App ID (iOS/macOS).
func openStoreListing(storeId: String?, completion: @escaping (Result<Void, Error>) -> Void)
/// Opens the App Store review page (iOS/macOS only).
///
/// [storeId] is the App ID.
func openAppStoreReview(storeId: String?, completion: @escaping (Result<Void, Error>) -> Void)
/// Returns package name for application.
func getBundleId(completion: @escaping (Result<String, Error>) -> Void)
/// Requests the App ID from the App Store (via iTunes Lookup API).
///
/// [bundleId] is the bundle identifier to look up.
/// [countryCode] is the optional country code.
func lookupAppId(bundleId: String, countryCode: String?, completion: @escaping (Result<String?, Error>) -> Void)
}
/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
class AppReviewApiSetup {
static var codec: FlutterStandardMessageCodec { MessagesPigeonCodec.shared }
/// Sets up an instance of `AppReviewApi` to handle messages through the `binaryMessenger`.
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: AppReviewApi?, messageChannelSuffix: String = "") {
let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : ""
/// Request review.
///
/// Tells StoreKit / Play Store to ask the user to rate or review your app, if appropriate.
/// Supported only in iOS 10.3+ and Android with Play Services installed (see [isRequestReviewAvailable]).
///
/// Returns string with details message.
let requestReviewChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app_review.AppReviewApi.requestReview\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
requestReviewChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let testModeArg = args[0] as! Bool
api.requestReview(testMode: testModeArg) { result in
switch result {
case .success(let res):
reply(wrapResult(res))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
requestReviewChannel.setMessageHandler(nil)
}
/// Check if [requestReview] feature available.
let isRequestReviewAvailableChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app_review.AppReviewApi.isRequestReviewAvailable\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
isRequestReviewAvailableChannel.setMessageHandler { _, reply in
api.isRequestReviewAvailable { result in
switch result {
case .success(let res):
reply(wrapResult(res))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
isRequestReviewAvailableChannel.setMessageHandler(nil)
}
/// Opens the store listing for the specified app.
///
/// [storeId] is the package name (Android) or App ID (iOS/macOS).
let openStoreListingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app_review.AppReviewApi.openStoreListing\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
openStoreListingChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let storeIdArg: String? = nilOrValue(args[0])
api.openStoreListing(storeId: storeIdArg) { result in
switch result {
case .success:
reply(wrapResult(nil))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
openStoreListingChannel.setMessageHandler(nil)
}
/// Opens the App Store review page (iOS/macOS only).
///
/// [storeId] is the App ID.
let openAppStoreReviewChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app_review.AppReviewApi.openAppStoreReview\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
openAppStoreReviewChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let storeIdArg: String? = nilOrValue(args[0])
api.openAppStoreReview(storeId: storeIdArg) { result in
switch result {
case .success:
reply(wrapResult(nil))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
openAppStoreReviewChannel.setMessageHandler(nil)
}
/// Returns package name for application.
let getBundleIdChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app_review.AppReviewApi.getBundleId\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
getBundleIdChannel.setMessageHandler { _, reply in
api.getBundleId { result in
switch result {
case .success(let res):
reply(wrapResult(res))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
getBundleIdChannel.setMessageHandler(nil)
}
/// Requests the App ID from the App Store (via iTunes Lookup API).
///
/// [bundleId] is the bundle identifier to look up.
/// [countryCode] is the optional country code.
let lookupAppIdChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.app_review.AppReviewApi.lookupAppId\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
lookupAppIdChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let bundleIdArg = args[0] as! String
let countryCodeArg: String? = nilOrValue(args[1])
api.lookupAppId(bundleId: bundleIdArg, countryCode: countryCodeArg) { result in
switch result {
case .success(let res):
reply(wrapResult(res))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
lookupAppIdChannel.setMessageHandler(nil)
}
}
}