From 8c92718d597f990af94adc89e70e8c3fc3770c7a Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Fri, 28 Nov 2025 14:18:11 +0000 Subject: [PATCH 01/25] feat(installations): Add support for pigeons --- ...eratedAndroidFirebaseAppInstallations.java | 553 ++++++++++++++++++ .../firebase_app_installations_messages.g.h | 61 ++ .../firebase_app_installations_messages.g.m | 298 ++++++++++ .../windows/messages.g.cpp | 403 +++++++++++++ .../windows/messages.g.h | 193 ++++++ ...od_channel_firebase_app_installations.dart | 27 +- .../lib/src/pigeon/messages.pigeon.dart | 346 +++++++++++ .../pigeons/copyright.txt | 3 + .../pigeons/messages.dart | 72 +++ .../pubspec.yaml | 1 + .../test/pigeon/test_api.dart | 199 +++++++ 11 files changed, 2141 insertions(+), 15 deletions(-) create mode 100644 packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java create mode 100644 packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h create mode 100644 packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m create mode 100644 packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp create mode 100644 packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h create mode 100644 packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart create mode 100644 packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/copyright.txt create mode 100644 packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart create mode 100644 packages/firebase_app_installations/firebase_app_installations_platform_interface/test/pigeon/test_api.dart diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java new file mode 100644 index 000000000000..3535e8dda82f --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java @@ -0,0 +1,553 @@ +// Copyright 2025, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Autogenerated from Pigeon (v25.3.2), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +package io.flutter.plugins.firebase.installations; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.CLASS; + +import android.util.Log; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import io.flutter.plugin.common.BasicMessageChannel; +import io.flutter.plugin.common.BinaryMessenger; +import io.flutter.plugin.common.MessageCodec; +import io.flutter.plugin.common.StandardMessageCodec; +import java.io.ByteArrayOutputStream; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Generated class from Pigeon. */ +@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression", "serial"}) +public class GeneratedAndroidFirebaseAppInstallations { + + /** Error class for passing custom error details to Flutter via a thrown PlatformException. */ + public static class FlutterError extends RuntimeException { + + /** The error code. */ + public final String code; + + /** The error details. Must be a datatype supported by the api codec. */ + public final Object details; + + public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) + { + super(message); + this.code = code; + this.details = details; + } + } + + @NonNull + protected static ArrayList wrapError(@NonNull Throwable exception) { + ArrayList errorList = new ArrayList<>(3); + if (exception instanceof FlutterError) { + FlutterError error = (FlutterError) exception; + errorList.add(error.code); + errorList.add(error.getMessage()); + errorList.add(error.details); + } else { + errorList.add(exception.toString()); + errorList.add(exception.getClass().getSimpleName()); + errorList.add( + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + } + return errorList; + } + + @NonNull + protected static FlutterError createConnectionError(@NonNull String channelName) { + return new FlutterError("channel-error", "Unable to establish connection on channel: " + channelName + ".", ""); + } + + @Target(METHOD) + @Retention(CLASS) + @interface CanIgnoreReturnValue {} + + /** Generated class from Pigeon that represents data sent in messages. */ + public static final class AppInstallationsPigeonSettings { + private @NonNull Boolean persistenceEnabled; + + public @NonNull Boolean getPersistenceEnabled() { + return persistenceEnabled; + } + + public void setPersistenceEnabled(@NonNull Boolean setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"persistenceEnabled\" is null."); + } + this.persistenceEnabled = setterArg; + } + + private @NonNull Boolean forceRefreshOnSignIn; + + public @NonNull Boolean getForceRefreshOnSignIn() { + return forceRefreshOnSignIn; + } + + public void setForceRefreshOnSignIn(@NonNull Boolean setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"forceRefreshOnSignIn\" is null."); + } + this.forceRefreshOnSignIn = setterArg; + } + + private @NonNull Boolean forceRefreshOnTokenChange; + + public @NonNull Boolean getForceRefreshOnTokenChange() { + return forceRefreshOnTokenChange; + } + + public void setForceRefreshOnTokenChange(@NonNull Boolean setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"forceRefreshOnTokenChange\" is null."); + } + this.forceRefreshOnTokenChange = setterArg; + } + + private @NonNull Boolean forceRefreshOnAppUpdate; + + public @NonNull Boolean getForceRefreshOnAppUpdate() { + return forceRefreshOnAppUpdate; + } + + public void setForceRefreshOnAppUpdate(@NonNull Boolean setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"forceRefreshOnAppUpdate\" is null."); + } + this.forceRefreshOnAppUpdate = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + AppInstallationsPigeonSettings() {} + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + AppInstallationsPigeonSettings that = (AppInstallationsPigeonSettings) o; + return persistenceEnabled.equals(that.persistenceEnabled) && forceRefreshOnSignIn.equals(that.forceRefreshOnSignIn) && forceRefreshOnTokenChange.equals(that.forceRefreshOnTokenChange) && forceRefreshOnAppUpdate.equals(that.forceRefreshOnAppUpdate); + } + + @Override + public int hashCode() { + return Objects.hash(persistenceEnabled, forceRefreshOnSignIn, forceRefreshOnTokenChange, forceRefreshOnAppUpdate); + } + + public static final class Builder { + + private @Nullable Boolean persistenceEnabled; + + @CanIgnoreReturnValue + public @NonNull Builder setPersistenceEnabled(@NonNull Boolean setterArg) { + this.persistenceEnabled = setterArg; + return this; + } + + private @Nullable Boolean forceRefreshOnSignIn; + + @CanIgnoreReturnValue + public @NonNull Builder setForceRefreshOnSignIn(@NonNull Boolean setterArg) { + this.forceRefreshOnSignIn = setterArg; + return this; + } + + private @Nullable Boolean forceRefreshOnTokenChange; + + @CanIgnoreReturnValue + public @NonNull Builder setForceRefreshOnTokenChange(@NonNull Boolean setterArg) { + this.forceRefreshOnTokenChange = setterArg; + return this; + } + + private @Nullable Boolean forceRefreshOnAppUpdate; + + @CanIgnoreReturnValue + public @NonNull Builder setForceRefreshOnAppUpdate(@NonNull Boolean setterArg) { + this.forceRefreshOnAppUpdate = setterArg; + return this; + } + + public @NonNull AppInstallationsPigeonSettings build() { + AppInstallationsPigeonSettings pigeonReturn = new AppInstallationsPigeonSettings(); + pigeonReturn.setPersistenceEnabled(persistenceEnabled); + pigeonReturn.setForceRefreshOnSignIn(forceRefreshOnSignIn); + pigeonReturn.setForceRefreshOnTokenChange(forceRefreshOnTokenChange); + pigeonReturn.setForceRefreshOnAppUpdate(forceRefreshOnAppUpdate); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(4); + toListResult.add(persistenceEnabled); + toListResult.add(forceRefreshOnSignIn); + toListResult.add(forceRefreshOnTokenChange); + toListResult.add(forceRefreshOnAppUpdate); + return toListResult; + } + + static @NonNull AppInstallationsPigeonSettings fromList(@NonNull ArrayList pigeonVar_list) { + AppInstallationsPigeonSettings pigeonResult = new AppInstallationsPigeonSettings(); + Object persistenceEnabled = pigeonVar_list.get(0); + pigeonResult.setPersistenceEnabled((Boolean) persistenceEnabled); + Object forceRefreshOnSignIn = pigeonVar_list.get(1); + pigeonResult.setForceRefreshOnSignIn((Boolean) forceRefreshOnSignIn); + Object forceRefreshOnTokenChange = pigeonVar_list.get(2); + pigeonResult.setForceRefreshOnTokenChange((Boolean) forceRefreshOnTokenChange); + Object forceRefreshOnAppUpdate = pigeonVar_list.get(3); + pigeonResult.setForceRefreshOnAppUpdate((Boolean) forceRefreshOnAppUpdate); + return pigeonResult; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static final class AppInstallationsPigeonFirebaseApp { + private @NonNull String appName; + + public @NonNull String getAppName() { + return appName; + } + + public void setAppName(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"appName\" is null."); + } + this.appName = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + AppInstallationsPigeonFirebaseApp() {} + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + AppInstallationsPigeonFirebaseApp that = (AppInstallationsPigeonFirebaseApp) o; + return appName.equals(that.appName); + } + + @Override + public int hashCode() { + return Objects.hash(appName); + } + + public static final class Builder { + + private @Nullable String appName; + + @CanIgnoreReturnValue + public @NonNull Builder setAppName(@NonNull String setterArg) { + this.appName = setterArg; + return this; + } + + public @NonNull AppInstallationsPigeonFirebaseApp build() { + AppInstallationsPigeonFirebaseApp pigeonReturn = new AppInstallationsPigeonFirebaseApp(); + pigeonReturn.setAppName(appName); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(1); + toListResult.add(appName); + return toListResult; + } + + static @NonNull AppInstallationsPigeonFirebaseApp fromList(@NonNull ArrayList pigeonVar_list) { + AppInstallationsPigeonFirebaseApp pigeonResult = new AppInstallationsPigeonFirebaseApp(); + Object appName = pigeonVar_list.get(0); + pigeonResult.setAppName((String) appName); + return pigeonResult; + } + } + + private static class PigeonCodec extends StandardMessageCodec { + public static final PigeonCodec INSTANCE = new PigeonCodec(); + + private PigeonCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 129: + return AppInstallationsPigeonSettings.fromList((ArrayList) readValue(buffer)); + case (byte) 130: + return AppInstallationsPigeonFirebaseApp.fromList((ArrayList) readValue(buffer)); + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof AppInstallationsPigeonSettings) { + stream.write(129); + writeValue(stream, ((AppInstallationsPigeonSettings) value).toList()); + } else if (value instanceof AppInstallationsPigeonFirebaseApp) { + stream.write(130); + writeValue(stream, ((AppInstallationsPigeonFirebaseApp) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + + /** Asynchronous error handling return type for non-nullable API method returns. */ + public interface Result { + /** Success case callback method for handling returns. */ + void success(@NonNull T result); + + /** Failure case callback method for handling errors. */ + void error(@NonNull Throwable error); + } + /** Asynchronous error handling return type for nullable API method returns. */ + public interface NullableResult { + /** Success case callback method for handling returns. */ + void success(@Nullable T result); + + /** Failure case callback method for handling errors. */ + void error(@NonNull Throwable error); + } + /** Asynchronous error handling return type for void API method returns. */ + public interface VoidResult { + /** Success case callback method for handling returns. */ + void success(); + + /** Failure case callback method for handling errors. */ + void error(@NonNull Throwable error); + } + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ + public interface FirebaseAppInstallationsHostApi { + + void initializeApp(@NonNull AppInstallationsPigeonFirebaseApp app, @NonNull AppInstallationsPigeonSettings settings, @NonNull VoidResult result); + + void delete(@NonNull AppInstallationsPigeonFirebaseApp app, @NonNull VoidResult result); + + void getId(@NonNull AppInstallationsPigeonFirebaseApp app, @NonNull Result result); + + void getToken(@NonNull AppInstallationsPigeonFirebaseApp app, @NonNull Boolean forceRefresh, @NonNull Result result); + + void onIdChange(@NonNull AppInstallationsPigeonFirebaseApp app, @NonNull String newId, @NonNull VoidResult result); + + /** The codec used by FirebaseAppInstallationsHostApi. */ + static @NonNull MessageCodec getCodec() { + return PigeonCodec.INSTANCE; + } + /**Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages through the `binaryMessenger`. */ + static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable FirebaseAppInstallationsHostApi api) { + setUp(binaryMessenger, "", api); + } + static void setUp(@NonNull BinaryMessenger binaryMessenger, @NonNull String messageChannelSuffix, @Nullable FirebaseAppInstallationsHostApi api) { + messageChannelSuffix = messageChannelSuffix.isEmpty() ? "" : "." + messageChannelSuffix; + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp" + messageChannelSuffix, getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + ArrayList args = (ArrayList) message; + AppInstallationsPigeonFirebaseApp appArg = (AppInstallationsPigeonFirebaseApp) args.get(0); + AppInstallationsPigeonSettings settingsArg = (AppInstallationsPigeonSettings) args.get(1); + VoidResult resultCallback = + new VoidResult() { + public void success() { + wrapped.add(0, null); + reply.reply(wrapped); + } + + public void error(Throwable error) { + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); + } + }; + + api.initializeApp(appArg, settingsArg, resultCallback); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete" + messageChannelSuffix, getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + ArrayList args = (ArrayList) message; + AppInstallationsPigeonFirebaseApp appArg = (AppInstallationsPigeonFirebaseApp) args.get(0); + VoidResult resultCallback = + new VoidResult() { + public void success() { + wrapped.add(0, null); + reply.reply(wrapped); + } + + public void error(Throwable error) { + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); + } + }; + + api.delete(appArg, resultCallback); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId" + messageChannelSuffix, getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + ArrayList args = (ArrayList) message; + AppInstallationsPigeonFirebaseApp appArg = (AppInstallationsPigeonFirebaseApp) args.get(0); + Result resultCallback = + new Result() { + public void success(String result) { + wrapped.add(0, result); + reply.reply(wrapped); + } + + public void error(Throwable error) { + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); + } + }; + + api.getId(appArg, resultCallback); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken" + messageChannelSuffix, getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + ArrayList args = (ArrayList) message; + AppInstallationsPigeonFirebaseApp appArg = (AppInstallationsPigeonFirebaseApp) args.get(0); + Boolean forceRefreshArg = (Boolean) args.get(1); + Result resultCallback = + new Result() { + public void success(String result) { + wrapped.add(0, result); + reply.reply(wrapped); + } + + public void error(Throwable error) { + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); + } + }; + + api.getToken(appArg, forceRefreshArg, resultCallback); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange" + messageChannelSuffix, getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + ArrayList args = (ArrayList) message; + AppInstallationsPigeonFirebaseApp appArg = (AppInstallationsPigeonFirebaseApp) args.get(0); + String newIdArg = (String) args.get(1); + VoidResult resultCallback = + new VoidResult() { + public void success() { + wrapped.add(0, null); + reply.reply(wrapped); + } + + public void error(Throwable error) { + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); + } + }; + + api.onIdChange(appArg, newIdArg, resultCallback); + }); + } else { + channel.setMessageHandler(null); + } + } + } + } + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class FirebaseAppInstallationsFlutterApi { + private final @NonNull BinaryMessenger binaryMessenger; + private final String messageChannelSuffix; + + public FirebaseAppInstallationsFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { + this(argBinaryMessenger, ""); + } + public FirebaseAppInstallationsFlutterApi(@NonNull BinaryMessenger argBinaryMessenger, @NonNull String messageChannelSuffix) { + this.binaryMessenger = argBinaryMessenger; + this.messageChannelSuffix = messageChannelSuffix.isEmpty() ? "" : "." + messageChannelSuffix; + } + + /** + * Public interface for sending reply. + * The codec used by FirebaseAppInstallationsFlutterApi. + */ + static @NonNull MessageCodec getCodec() { + return PigeonCodec.INSTANCE; + } + public void registerIdTokenListener(@NonNull AppInstallationsPigeonFirebaseApp appArg, @NonNull Result result) { + final String channelName = "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener" + messageChannelSuffix; + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, channelName, getCodec()); + channel.send( + new ArrayList<>(Collections.singletonList(appArg)), + channelReply -> { + if (channelReply instanceof List) { + List listReply = (List) channelReply; + if (listReply.size() > 1) { + result.error(new FlutterError((String) listReply.get(0), (String) listReply.get(1), listReply.get(2))); + } else if (listReply.get(0) == null) { + result.error(new FlutterError("null-error", "Flutter api returned null value for non-null return value.", "")); + } else { + @SuppressWarnings("ConstantConditions") + String output = (String) listReply.get(0); + result.success(output); + } + } else { + result.error(createConnectionError(channelName)); + } + }); + } + } +} diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h new file mode 100644 index 000000000000..45f075ab07ad --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h @@ -0,0 +1,61 @@ +// Copyright 2025, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Autogenerated from Pigeon (v25.3.2), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +#import + +@protocol FlutterBinaryMessenger; +@protocol FlutterMessageCodec; +@class FlutterError; +@class FlutterStandardTypedData; + +NS_ASSUME_NONNULL_BEGIN + +@class AppInstallationsPigeonSettings; +@class AppInstallationsPigeonFirebaseApp; + +@interface AppInstallationsPigeonSettings : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithPersistenceEnabled:(BOOL )persistenceEnabled + forceRefreshOnSignIn:(BOOL )forceRefreshOnSignIn + forceRefreshOnTokenChange:(BOOL )forceRefreshOnTokenChange + forceRefreshOnAppUpdate:(BOOL )forceRefreshOnAppUpdate; +@property(nonatomic, assign) BOOL persistenceEnabled; +@property(nonatomic, assign) BOOL forceRefreshOnSignIn; +@property(nonatomic, assign) BOOL forceRefreshOnTokenChange; +@property(nonatomic, assign) BOOL forceRefreshOnAppUpdate; +@end + +@interface AppInstallationsPigeonFirebaseApp : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithAppName:(NSString *)appName; +@property(nonatomic, copy) NSString * appName; +@end + +/// The codec used by all APIs. +NSObject *nullGetFirebaseAppInstallationsMessagesCodec(void); + +@protocol FirebaseAppInstallationsHostApi +- (void)initializeAppApp:(AppInstallationsPigeonFirebaseApp *)app settings:(AppInstallationsPigeonSettings *)settings completion:(void (^)(FlutterError *_Nullable))completion; +- (void)deleteApp:(AppInstallationsPigeonFirebaseApp *)app completion:(void (^)(FlutterError *_Nullable))completion; +- (void)getIdApp:(AppInstallationsPigeonFirebaseApp *)app completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; +- (void)getTokenApp:(AppInstallationsPigeonFirebaseApp *)app forceRefresh:(BOOL)forceRefresh completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; +- (void)onIdChangeApp:(AppInstallationsPigeonFirebaseApp *)app newId:(NSString *)newId completion:(void (^)(FlutterError *_Nullable))completion; +@end + +extern void SetUpFirebaseAppInstallationsHostApi(id binaryMessenger, NSObject *_Nullable api); + +extern void SetUpFirebaseAppInstallationsHostApiWithSuffix(id binaryMessenger, NSObject *_Nullable api, NSString *messageChannelSuffix); + + +@interface FirebaseAppInstallationsFlutterApi : NSObject +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger; +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger messageChannelSuffix:(nullable NSString *)messageChannelSuffix; +- (void)registerIdTokenListenerApp:(AppInstallationsPigeonFirebaseApp *)app completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; +@end + +NS_ASSUME_NONNULL_END diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m new file mode 100644 index 000000000000..504ed4fef493 --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m @@ -0,0 +1,298 @@ +// Copyright 2025, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Autogenerated from Pigeon (v25.3.2), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +#import "firebase_app_installations_messages.g.h" + +#if TARGET_OS_OSX +#import +#else +#import +#endif + +#if !__has_feature(objc_arc) +#error File requires ARC to be enabled. +#endif + +static NSArray *wrapResult(id result, FlutterError *error) { + if (error) { + return @[ + error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null] + ]; + } + return @[ result ?: [NSNull null] ]; +} + +static FlutterError *createConnectionError(NSString *channelName) { + return [FlutterError errorWithCode:@"channel-error" message:[NSString stringWithFormat:@"%@/%@/%@", @"Unable to establish connection on channel: '", channelName, @"'."] details:@""]; +} + +static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { + id result = array[key]; + return (result == [NSNull null]) ? nil : result; +} + +@interface AppInstallationsPigeonSettings () ++ (AppInstallationsPigeonSettings *)fromList:(NSArray *)list; ++ (nullable AppInstallationsPigeonSettings *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@interface AppInstallationsPigeonFirebaseApp () ++ (AppInstallationsPigeonFirebaseApp *)fromList:(NSArray *)list; ++ (nullable AppInstallationsPigeonFirebaseApp *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + +@implementation AppInstallationsPigeonSettings ++ (instancetype)makeWithPersistenceEnabled:(BOOL )persistenceEnabled + forceRefreshOnSignIn:(BOOL )forceRefreshOnSignIn + forceRefreshOnTokenChange:(BOOL )forceRefreshOnTokenChange + forceRefreshOnAppUpdate:(BOOL )forceRefreshOnAppUpdate { + AppInstallationsPigeonSettings* pigeonResult = [[AppInstallationsPigeonSettings alloc] init]; + pigeonResult.persistenceEnabled = persistenceEnabled; + pigeonResult.forceRefreshOnSignIn = forceRefreshOnSignIn; + pigeonResult.forceRefreshOnTokenChange = forceRefreshOnTokenChange; + pigeonResult.forceRefreshOnAppUpdate = forceRefreshOnAppUpdate; + return pigeonResult; +} ++ (AppInstallationsPigeonSettings *)fromList:(NSArray *)list { + AppInstallationsPigeonSettings *pigeonResult = [[AppInstallationsPigeonSettings alloc] init]; + pigeonResult.persistenceEnabled = [GetNullableObjectAtIndex(list, 0) boolValue]; + pigeonResult.forceRefreshOnSignIn = [GetNullableObjectAtIndex(list, 1) boolValue]; + pigeonResult.forceRefreshOnTokenChange = [GetNullableObjectAtIndex(list, 2) boolValue]; + pigeonResult.forceRefreshOnAppUpdate = [GetNullableObjectAtIndex(list, 3) boolValue]; + return pigeonResult; +} ++ (nullable AppInstallationsPigeonSettings *)nullableFromList:(NSArray *)list { + return (list) ? [AppInstallationsPigeonSettings fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + @(self.persistenceEnabled), + @(self.forceRefreshOnSignIn), + @(self.forceRefreshOnTokenChange), + @(self.forceRefreshOnAppUpdate), + ]; +} +@end + +@implementation AppInstallationsPigeonFirebaseApp ++ (instancetype)makeWithAppName:(NSString *)appName { + AppInstallationsPigeonFirebaseApp* pigeonResult = [[AppInstallationsPigeonFirebaseApp alloc] init]; + pigeonResult.appName = appName; + return pigeonResult; +} ++ (AppInstallationsPigeonFirebaseApp *)fromList:(NSArray *)list { + AppInstallationsPigeonFirebaseApp *pigeonResult = [[AppInstallationsPigeonFirebaseApp alloc] init]; + pigeonResult.appName = GetNullableObjectAtIndex(list, 0); + return pigeonResult; +} ++ (nullable AppInstallationsPigeonFirebaseApp *)nullableFromList:(NSArray *)list { + return (list) ? [AppInstallationsPigeonFirebaseApp fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + self.appName ?: [NSNull null], + ]; +} +@end + +@interface nullFirebaseAppInstallationsMessagesPigeonCodecReader : FlutterStandardReader +@end +@implementation nullFirebaseAppInstallationsMessagesPigeonCodecReader +- (nullable id)readValueOfType:(UInt8)type { + switch (type) { + case 129: + return [AppInstallationsPigeonSettings fromList:[self readValue]]; + case 130: + return [AppInstallationsPigeonFirebaseApp fromList:[self readValue]]; + default: + return [super readValueOfType:type]; + } +} +@end + +@interface nullFirebaseAppInstallationsMessagesPigeonCodecWriter : FlutterStandardWriter +@end +@implementation nullFirebaseAppInstallationsMessagesPigeonCodecWriter +- (void)writeValue:(id)value { + if ([value isKindOfClass:[AppInstallationsPigeonSettings class]]) { + [self writeByte:129]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[AppInstallationsPigeonFirebaseApp class]]) { + [self writeByte:130]; + [self writeValue:[value toList]]; + } else { + [super writeValue:value]; + } +} +@end + +@interface nullFirebaseAppInstallationsMessagesPigeonCodecReaderWriter : FlutterStandardReaderWriter +@end +@implementation nullFirebaseAppInstallationsMessagesPigeonCodecReaderWriter +- (FlutterStandardWriter *)writerWithData:(NSMutableData *)data { + return [[nullFirebaseAppInstallationsMessagesPigeonCodecWriter alloc] initWithData:data]; +} +- (FlutterStandardReader *)readerWithData:(NSData *)data { + return [[nullFirebaseAppInstallationsMessagesPigeonCodecReader alloc] initWithData:data]; +} +@end + +NSObject *nullGetFirebaseAppInstallationsMessagesCodec(void) { + static FlutterStandardMessageCodec *sSharedObject = nil; + static dispatch_once_t sPred = 0; + dispatch_once(&sPred, ^{ + nullFirebaseAppInstallationsMessagesPigeonCodecReaderWriter *readerWriter = [[nullFirebaseAppInstallationsMessagesPigeonCodecReaderWriter alloc] init]; + sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; + }); + return sSharedObject; +} +void SetUpFirebaseAppInstallationsHostApi(id binaryMessenger, NSObject *api) { + SetUpFirebaseAppInstallationsHostApiWithSuffix(binaryMessenger, api, @""); +} + +void SetUpFirebaseAppInstallationsHostApiWithSuffix(id binaryMessenger, NSObject *api, NSString *messageChannelSuffix) { + messageChannelSuffix = messageChannelSuffix.length > 0 ? [NSString stringWithFormat: @".%@", messageChannelSuffix] : @""; + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp", messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + if (api) { + NSCAssert([api respondsToSelector:@selector(initializeAppApp:settings:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(initializeAppApp:settings:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + AppInstallationsPigeonFirebaseApp *arg_app = GetNullableObjectAtIndex(args, 0); + AppInstallationsPigeonSettings *arg_settings = GetNullableObjectAtIndex(args, 1); + [api initializeAppApp:arg_app settings:arg_settings completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; + }]; + } else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete", messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + if (api) { + NSCAssert([api respondsToSelector:@selector(deleteApp:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(deleteApp:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + AppInstallationsPigeonFirebaseApp *arg_app = GetNullableObjectAtIndex(args, 0); + [api deleteApp:arg_app completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; + }]; + } else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId", messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + if (api) { + NSCAssert([api respondsToSelector:@selector(getIdApp:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(getIdApp:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + AppInstallationsPigeonFirebaseApp *arg_app = GetNullableObjectAtIndex(args, 0); + [api getIdApp:arg_app completion:^(NSString *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; + }]; + } else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken", messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + if (api) { + NSCAssert([api respondsToSelector:@selector(getTokenApp:forceRefresh:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(getTokenApp:forceRefresh:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + AppInstallationsPigeonFirebaseApp *arg_app = GetNullableObjectAtIndex(args, 0); + BOOL arg_forceRefresh = [GetNullableObjectAtIndex(args, 1) boolValue]; + [api getTokenApp:arg_app forceRefresh:arg_forceRefresh completion:^(NSString *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; + }]; + } else { + [channel setMessageHandler:nil]; + } + } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange", messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + if (api) { + NSCAssert([api respondsToSelector:@selector(onIdChangeApp:newId:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(onIdChangeApp:newId:completion:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + NSArray *args = message; + AppInstallationsPigeonFirebaseApp *arg_app = GetNullableObjectAtIndex(args, 0); + NSString *arg_newId = GetNullableObjectAtIndex(args, 1); + [api onIdChangeApp:arg_app newId:arg_newId completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; + }]; + } else { + [channel setMessageHandler:nil]; + } + } +} +@interface FirebaseAppInstallationsFlutterApi () +@property(nonatomic, strong) NSObject *binaryMessenger; +@property(nonatomic, strong) NSString *messageChannelSuffix; +@end + +@implementation FirebaseAppInstallationsFlutterApi + +- (instancetype)initWithBinaryMessenger:(NSObject *)binaryMessenger { + return [self initWithBinaryMessenger:binaryMessenger messageChannelSuffix:@""]; +} +- (instancetype)initWithBinaryMessenger:(NSObject *)binaryMessenger messageChannelSuffix:(nullable NSString*)messageChannelSuffix{ + self = [self init]; + if (self) { + _binaryMessenger = binaryMessenger; + _messageChannelSuffix = [messageChannelSuffix length] == 0 ? @"" : [NSString stringWithFormat: @".%@", messageChannelSuffix]; + } + return self; +} +- (void)registerIdTokenListenerApp:(AppInstallationsPigeonFirebaseApp *)arg_app completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion { + NSString *channelName = [NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener", _messageChannelSuffix]; + FlutterBasicMessageChannel *channel = + [FlutterBasicMessageChannel + messageChannelWithName:channelName + binaryMessenger:self.binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + [channel sendMessage:@[arg_app ?: [NSNull null]] reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion(nil, [FlutterError errorWithCode:reply[0] message:reply[1] details:reply[2]]); + } else { + NSString *output = reply[0] == [NSNull null] ? nil : reply[0]; + completion(output, nil); + } + } else { + completion(nil, createConnectionError(channelName)); + } + }]; +} +@end + diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp new file mode 100644 index 000000000000..d9ee0205e5ec --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp @@ -0,0 +1,403 @@ +// Copyright 2025, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Autogenerated from Pigeon (v25.3.2), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +#undef _HAS_EXCEPTIONS + +#include "messages.g.h" + +#include +#include +#include +#include + +#include +#include +#include + +namespace firebase_app_installations_windows { +using flutter::BasicMessageChannel; +using flutter::CustomEncodableValue; +using flutter::EncodableList; +using flutter::EncodableMap; +using flutter::EncodableValue; + +FlutterError CreateConnectionError(const std::string channel_name) { + return FlutterError( + "channel-error", + "Unable to establish connection on channel: '" + channel_name + "'.", + EncodableValue("")); +} + +// AppInstallationsPigeonSettings + +AppInstallationsPigeonSettings::AppInstallationsPigeonSettings( + bool persistence_enabled, + bool force_refresh_on_sign_in, + bool force_refresh_on_token_change, + bool force_refresh_on_app_update) + : persistence_enabled_(persistence_enabled), + force_refresh_on_sign_in_(force_refresh_on_sign_in), + force_refresh_on_token_change_(force_refresh_on_token_change), + force_refresh_on_app_update_(force_refresh_on_app_update) {} + +bool AppInstallationsPigeonSettings::persistence_enabled() const { + return persistence_enabled_; +} + +void AppInstallationsPigeonSettings::set_persistence_enabled(bool value_arg) { + persistence_enabled_ = value_arg; +} + + +bool AppInstallationsPigeonSettings::force_refresh_on_sign_in() const { + return force_refresh_on_sign_in_; +} + +void AppInstallationsPigeonSettings::set_force_refresh_on_sign_in(bool value_arg) { + force_refresh_on_sign_in_ = value_arg; +} + + +bool AppInstallationsPigeonSettings::force_refresh_on_token_change() const { + return force_refresh_on_token_change_; +} + +void AppInstallationsPigeonSettings::set_force_refresh_on_token_change(bool value_arg) { + force_refresh_on_token_change_ = value_arg; +} + + +bool AppInstallationsPigeonSettings::force_refresh_on_app_update() const { + return force_refresh_on_app_update_; +} + +void AppInstallationsPigeonSettings::set_force_refresh_on_app_update(bool value_arg) { + force_refresh_on_app_update_ = value_arg; +} + + +EncodableList AppInstallationsPigeonSettings::ToEncodableList() const { + EncodableList list; + list.reserve(4); + list.push_back(EncodableValue(persistence_enabled_)); + list.push_back(EncodableValue(force_refresh_on_sign_in_)); + list.push_back(EncodableValue(force_refresh_on_token_change_)); + list.push_back(EncodableValue(force_refresh_on_app_update_)); + return list; +} + +AppInstallationsPigeonSettings AppInstallationsPigeonSettings::FromEncodableList(const EncodableList& list) { + AppInstallationsPigeonSettings decoded( + std::get(list[0]), + std::get(list[1]), + std::get(list[2]), + std::get(list[3])); + return decoded; +} + +// AppInstallationsPigeonFirebaseApp + +AppInstallationsPigeonFirebaseApp::AppInstallationsPigeonFirebaseApp(const std::string& app_name) + : app_name_(app_name) {} + +const std::string& AppInstallationsPigeonFirebaseApp::app_name() const { + return app_name_; +} + +void AppInstallationsPigeonFirebaseApp::set_app_name(std::string_view value_arg) { + app_name_ = value_arg; +} + + +EncodableList AppInstallationsPigeonFirebaseApp::ToEncodableList() const { + EncodableList list; + list.reserve(1); + list.push_back(EncodableValue(app_name_)); + return list; +} + +AppInstallationsPigeonFirebaseApp AppInstallationsPigeonFirebaseApp::FromEncodableList(const EncodableList& list) { + AppInstallationsPigeonFirebaseApp decoded( + std::get(list[0])); + return decoded; +} + + +PigeonInternalCodecSerializer::PigeonInternalCodecSerializer() {} + +EncodableValue PigeonInternalCodecSerializer::ReadValueOfType( + uint8_t type, + flutter::ByteStreamReader* stream) const { + switch (type) { + case 129: { + return CustomEncodableValue(AppInstallationsPigeonSettings::FromEncodableList(std::get(ReadValue(stream)))); + } + case 130: { + return CustomEncodableValue(AppInstallationsPigeonFirebaseApp::FromEncodableList(std::get(ReadValue(stream)))); + } + default: + return flutter::StandardCodecSerializer::ReadValueOfType(type, stream); + } +} + +void PigeonInternalCodecSerializer::WriteValue( + const EncodableValue& value, + flutter::ByteStreamWriter* stream) const { + if (const CustomEncodableValue* custom_value = std::get_if(&value)) { + if (custom_value->type() == typeid(AppInstallationsPigeonSettings)) { + stream->WriteByte(129); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + return; + } + if (custom_value->type() == typeid(AppInstallationsPigeonFirebaseApp)) { + stream->WriteByte(130); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + return; + } + } + flutter::StandardCodecSerializer::WriteValue(value, stream); +} + +/// The codec used by FirebaseAppInstallationsHostApi. +const flutter::StandardMessageCodec& FirebaseAppInstallationsHostApi::GetCodec() { + return flutter::StandardMessageCodec::GetInstance(&PigeonInternalCodecSerializer::GetInstance()); +} + +// Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages through the `binary_messenger`. +void FirebaseAppInstallationsHostApi::SetUp( + flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api) { + FirebaseAppInstallationsHostApi::SetUp(binary_messenger, api, ""); +} + +void FirebaseAppInstallationsHostApi::SetUp( + flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api, + const std::string& message_channel_suffix) { + const std::string prepended_suffix = message_channel_suffix.length() > 0 ? std::string(".") + message_channel_suffix : ""; + { + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp" + prepended_suffix, &GetCodec()); + if (api != nullptr) { + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } + const auto& app_arg = std::any_cast(std::get(encodable_app_arg)); + const auto& encodable_settings_arg = args.at(1); + if (encodable_settings_arg.IsNull()) { + reply(WrapError("settings_arg unexpectedly null.")); + return; + } + const auto& settings_arg = std::any_cast(std::get(encodable_settings_arg)); + api->InitializeApp(app_arg, settings_arg, [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel.SetMessageHandler(nullptr); + } + } + { + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete" + prepended_suffix, &GetCodec()); + if (api != nullptr) { + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } + const auto& app_arg = std::any_cast(std::get(encodable_app_arg)); + api->Delete(app_arg, [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel.SetMessageHandler(nullptr); + } + } + { + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId" + prepended_suffix, &GetCodec()); + if (api != nullptr) { + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } + const auto& app_arg = std::any_cast(std::get(encodable_app_arg)); + api->GetId(app_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel.SetMessageHandler(nullptr); + } + } + { + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken" + prepended_suffix, &GetCodec()); + if (api != nullptr) { + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } + const auto& app_arg = std::any_cast(std::get(encodable_app_arg)); + const auto& encodable_force_refresh_arg = args.at(1); + if (encodable_force_refresh_arg.IsNull()) { + reply(WrapError("force_refresh_arg unexpectedly null.")); + return; + } + const auto& force_refresh_arg = std::get(encodable_force_refresh_arg); + api->GetToken(app_arg, force_refresh_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel.SetMessageHandler(nullptr); + } + } + { + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange" + prepended_suffix, &GetCodec()); + if (api != nullptr) { + channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } + const auto& app_arg = std::any_cast(std::get(encodable_app_arg)); + const auto& encodable_new_id_arg = args.at(1); + if (encodable_new_id_arg.IsNull()) { + reply(WrapError("new_id_arg unexpectedly null.")); + return; + } + const auto& new_id_arg = std::get(encodable_new_id_arg); + api->OnIdChange(app_arg, new_id_arg, [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel.SetMessageHandler(nullptr); + } + } +} + +EncodableValue FirebaseAppInstallationsHostApi::WrapError(std::string_view error_message) { + return EncodableValue(EncodableList{ + EncodableValue(std::string(error_message)), + EncodableValue("Error"), + EncodableValue() + }); +} + +EncodableValue FirebaseAppInstallationsHostApi::WrapError(const FlutterError& error) { + return EncodableValue(EncodableList{ + EncodableValue(error.code()), + EncodableValue(error.message()), + error.details() + }); +} + +// Generated class from Pigeon that represents Flutter messages that can be called from C++. +FirebaseAppInstallationsFlutterApi::FirebaseAppInstallationsFlutterApi(flutter::BinaryMessenger* binary_messenger) + : binary_messenger_(binary_messenger), + message_channel_suffix_("") {} + +FirebaseAppInstallationsFlutterApi::FirebaseAppInstallationsFlutterApi( + flutter::BinaryMessenger* binary_messenger, + const std::string& message_channel_suffix) + : binary_messenger_(binary_messenger), + message_channel_suffix_(message_channel_suffix.length() > 0 ? std::string(".") + message_channel_suffix : "") {} + +const flutter::StandardMessageCodec& FirebaseAppInstallationsFlutterApi::GetCodec() { + return flutter::StandardMessageCodec::GetInstance(&PigeonInternalCodecSerializer::GetInstance()); +} + +void FirebaseAppInstallationsFlutterApi::RegisterIdTokenListener( + const AppInstallationsPigeonFirebaseApp& app_arg, + std::function&& on_success, + std::function&& on_error) { + const std::string channel_name = "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener" + message_channel_suffix_; + BasicMessageChannel<> channel(binary_messenger_, channel_name, &GetCodec()); + EncodableValue encoded_api_arguments = EncodableValue(EncodableList{ + CustomEncodableValue(app_arg), + }); + channel.Send(encoded_api_arguments, [channel_name, on_success = std::move(on_success), on_error = std::move(on_error)](const uint8_t* reply, size_t reply_size) { + std::unique_ptr response = GetCodec().DecodeMessage(reply, reply_size); + const auto& encodable_return_value = *response; + const auto* list_return_value = std::get_if(&encodable_return_value); + if (list_return_value) { + if (list_return_value->size() > 1) { + on_error(FlutterError(std::get(list_return_value->at(0)), std::get(list_return_value->at(1)), list_return_value->at(2))); + } else { + const auto& return_value = std::get(list_return_value->at(0)); + on_success(return_value); + } + } else { + on_error(CreateConnectionError(channel_name)); + } + }); +} + +} // namespace firebase_app_installations_windows diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h new file mode 100644 index 000000000000..a64ac343c764 --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h @@ -0,0 +1,193 @@ +// Copyright 2025, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Autogenerated from Pigeon (v25.3.2), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +#ifndef PIGEON_MESSAGES_G_H_ +#define PIGEON_MESSAGES_G_H_ +#include +#include +#include +#include + +#include +#include +#include + +namespace firebase_app_installations_windows { + + +// Generated class from Pigeon. + +class FlutterError { + public: + explicit FlutterError(const std::string& code) + : code_(code) {} + explicit FlutterError(const std::string& code, const std::string& message) + : code_(code), message_(message) {} + explicit FlutterError(const std::string& code, const std::string& message, const flutter::EncodableValue& details) + : code_(code), message_(message), details_(details) {} + + const std::string& code() const { return code_; } + const std::string& message() const { return message_; } + const flutter::EncodableValue& details() const { return details_; } + + private: + std::string code_; + std::string message_; + flutter::EncodableValue details_; +}; + +template class ErrorOr { + public: + ErrorOr(const T& rhs) : v_(rhs) {} + ErrorOr(const T&& rhs) : v_(std::move(rhs)) {} + ErrorOr(const FlutterError& rhs) : v_(rhs) {} + ErrorOr(const FlutterError&& rhs) : v_(std::move(rhs)) {} + + bool has_error() const { return std::holds_alternative(v_); } + const T& value() const { return std::get(v_); }; + const FlutterError& error() const { return std::get(v_); }; + + private: + friend class FirebaseAppInstallationsHostApi; + friend class FirebaseAppInstallationsFlutterApi; + ErrorOr() = default; + T TakeValue() && { return std::get(std::move(v_)); } + + std::variant v_; +}; + + + +// Generated class from Pigeon that represents data sent in messages. +class AppInstallationsPigeonSettings { + public: + // Constructs an object setting all fields. + explicit AppInstallationsPigeonSettings( + bool persistence_enabled, + bool force_refresh_on_sign_in, + bool force_refresh_on_token_change, + bool force_refresh_on_app_update); + + bool persistence_enabled() const; + void set_persistence_enabled(bool value_arg); + + bool force_refresh_on_sign_in() const; + void set_force_refresh_on_sign_in(bool value_arg); + + bool force_refresh_on_token_change() const; + void set_force_refresh_on_token_change(bool value_arg); + + bool force_refresh_on_app_update() const; + void set_force_refresh_on_app_update(bool value_arg); + + private: + static AppInstallationsPigeonSettings FromEncodableList(const flutter::EncodableList& list); + flutter::EncodableList ToEncodableList() const; + friend class FirebaseAppInstallationsHostApi; + friend class FirebaseAppInstallationsFlutterApi; + friend class PigeonInternalCodecSerializer; + bool persistence_enabled_; + bool force_refresh_on_sign_in_; + bool force_refresh_on_token_change_; + bool force_refresh_on_app_update_; +}; + + +// Generated class from Pigeon that represents data sent in messages. +class AppInstallationsPigeonFirebaseApp { + public: + // Constructs an object setting all fields. + explicit AppInstallationsPigeonFirebaseApp(const std::string& app_name); + + const std::string& app_name() const; + void set_app_name(std::string_view value_arg); + + private: + static AppInstallationsPigeonFirebaseApp FromEncodableList(const flutter::EncodableList& list); + flutter::EncodableList ToEncodableList() const; + friend class FirebaseAppInstallationsHostApi; + friend class FirebaseAppInstallationsFlutterApi; + friend class PigeonInternalCodecSerializer; + std::string app_name_; +}; + + +class PigeonInternalCodecSerializer : public flutter::StandardCodecSerializer { + public: + PigeonInternalCodecSerializer(); + inline static PigeonInternalCodecSerializer& GetInstance() { + static PigeonInternalCodecSerializer sInstance; + return sInstance; + } + + void WriteValue( + const flutter::EncodableValue& value, + flutter::ByteStreamWriter* stream) const override; + protected: + flutter::EncodableValue ReadValueOfType( + uint8_t type, + flutter::ByteStreamReader* stream) const override; +}; + +// Generated interface from Pigeon that represents a handler of messages from Flutter. +class FirebaseAppInstallationsHostApi { + public: + FirebaseAppInstallationsHostApi(const FirebaseAppInstallationsHostApi&) = delete; + FirebaseAppInstallationsHostApi& operator=(const FirebaseAppInstallationsHostApi&) = delete; + virtual ~FirebaseAppInstallationsHostApi() {} + virtual void InitializeApp( + const AppInstallationsPigeonFirebaseApp& app, + const AppInstallationsPigeonSettings& settings, + std::function reply)> result) = 0; + virtual void Delete( + const AppInstallationsPigeonFirebaseApp& app, + std::function reply)> result) = 0; + virtual void GetId( + const AppInstallationsPigeonFirebaseApp& app, + std::function reply)> result) = 0; + virtual void GetToken( + const AppInstallationsPigeonFirebaseApp& app, + bool force_refresh, + std::function reply)> result) = 0; + virtual void OnIdChange( + const AppInstallationsPigeonFirebaseApp& app, + const std::string& new_id, + std::function reply)> result) = 0; + + // The codec used by FirebaseAppInstallationsHostApi. + static const flutter::StandardMessageCodec& GetCodec(); + // Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages through the `binary_messenger`. + static void SetUp( + flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api); + static void SetUp( + flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api, + const std::string& message_channel_suffix); + static flutter::EncodableValue WrapError(std::string_view error_message); + static flutter::EncodableValue WrapError(const FlutterError& error); + protected: + FirebaseAppInstallationsHostApi() = default; +}; +// Generated class from Pigeon that represents Flutter messages that can be called from C++. +class FirebaseAppInstallationsFlutterApi { + public: + FirebaseAppInstallationsFlutterApi(flutter::BinaryMessenger* binary_messenger); + FirebaseAppInstallationsFlutterApi( + flutter::BinaryMessenger* binary_messenger, + const std::string& message_channel_suffix); + static const flutter::StandardMessageCodec& GetCodec(); + void RegisterIdTokenListener( + const AppInstallationsPigeonFirebaseApp& app, + std::function&& on_success, + std::function&& on_error); + private: + flutter::BinaryMessenger* binary_messenger_; + std::string message_channel_suffix_; +}; + +} // namespace firebase_app_installations_windows +#endif // PIGEON_MESSAGES_G_H_ diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart index 8ab904811d42..b9e37385dd00 100644 --- a/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart @@ -8,11 +8,13 @@ import 'package:_flutterfire_internals/_flutterfire_internals.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_app_installations_platform_interface/firebase_app_installations_platform_interface.dart'; import 'package:flutter/services.dart'; +import 'package:firebase_app_installations_platform_interface/src/pigeon/messages.pigeon.dart'; import 'utils/exception.dart'; class MethodChannelFirebaseAppInstallations extends FirebaseAppInstallationsPlatform { + final FirebaseAppInstallationsHostApi _api = FirebaseAppInstallationsHostApi(); /// Returns a stub instance to allow the platform interface to access /// the class instance statically. static MethodChannelFirebaseAppInstallations get instance { @@ -62,9 +64,9 @@ class MethodChannelFirebaseAppInstallations @override Future delete() async { try { - await channel.invokeMethod('FirebaseInstallations#delete', { - 'appName': app!.name, - }); + await _api.delete( + AppInstallationsPigeonFirebaseApp(appName: app!.name), + ); } catch (e, s) { convertPlatformException(e, s); } @@ -73,12 +75,9 @@ class MethodChannelFirebaseAppInstallations @override Future getId() async { try { - final id = (await channel.invokeMethod( - 'FirebaseInstallations#getId', - {'appName': app!.name}, - ))!; - - return id; + return await _api.getId( + AppInstallationsPigeonFirebaseApp(appName: app!.name), + ); } catch (e, s) { convertPlatformException(e, s); } @@ -87,12 +86,10 @@ class MethodChannelFirebaseAppInstallations @override Future getToken(bool forceRefresh) async { try { - final id = (await channel.invokeMethod( - 'FirebaseInstallations#getToken', - {'appName': app!.name, 'forceRefresh': forceRefresh}, - ))!; - - return id; + return await _api.getToken( + AppInstallationsPigeonFirebaseApp(appName: app!.name), + forceRefresh, + ); } catch (e, s) { convertPlatformException(e, s); } diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart new file mode 100644 index 000000000000..5f082a02172a --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart @@ -0,0 +1,346 @@ +// Copyright 2025, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Autogenerated from Pigeon (v25.3.2), do not edit directly. +// See also: https://pub.dev/packages/pigeon +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers + +import 'dart:async'; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; + +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; +import 'package:flutter/services.dart'; + +PlatformException _createConnectionError(String channelName) { + return PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel: "$channelName".', + ); +} + +List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { + if (empty) { + return []; + } + if (error == null) { + return [result]; + } + return [error.code, error.message, error.details]; +} +bool _deepEquals(Object? a, Object? b) { + if (a is List && b is List) { + return a.length == b.length && + a.indexed + .every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1])); + } + if (a is Map && b is Map) { + return a.length == b.length && a.entries.every((MapEntry entry) => + (b as Map).containsKey(entry.key) && + _deepEquals(entry.value, b[entry.key])); + } + return a == b; +} + + +class AppInstallationsPigeonSettings { + AppInstallationsPigeonSettings({ + required this.persistenceEnabled, + required this.forceRefreshOnSignIn, + required this.forceRefreshOnTokenChange, + required this.forceRefreshOnAppUpdate, + }); + + bool persistenceEnabled; + + bool forceRefreshOnSignIn; + + bool forceRefreshOnTokenChange; + + bool forceRefreshOnAppUpdate; + + List _toList() { + return [ + persistenceEnabled, + forceRefreshOnSignIn, + forceRefreshOnTokenChange, + forceRefreshOnAppUpdate, + ]; + } + + Object encode() { + return _toList(); } + + static AppInstallationsPigeonSettings decode(Object result) { + result as List; + return AppInstallationsPigeonSettings( + persistenceEnabled: result[0]! as bool, + forceRefreshOnSignIn: result[1]! as bool, + forceRefreshOnTokenChange: result[2]! as bool, + forceRefreshOnAppUpdate: result[3]! as bool, + ); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! AppInstallationsPigeonSettings || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; +} + +class AppInstallationsPigeonFirebaseApp { + AppInstallationsPigeonFirebaseApp({ + required this.appName, + }); + + String appName; + + List _toList() { + return [ + appName, + ]; + } + + Object encode() { + return _toList(); } + + static AppInstallationsPigeonFirebaseApp decode(Object result) { + result as List; + return AppInstallationsPigeonFirebaseApp( + appName: result[0]! as String, + ); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! AppInstallationsPigeonFirebaseApp || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()) +; +} + + +class _PigeonCodec extends StandardMessageCodec { + const _PigeonCodec(); + @override + void writeValue(WriteBuffer buffer, Object? value) { + if (value is int) { + buffer.putUint8(4); + buffer.putInt64(value); + } else if (value is AppInstallationsPigeonSettings) { + buffer.putUint8(129); + writeValue(buffer, value.encode()); + } else if (value is AppInstallationsPigeonFirebaseApp) { + buffer.putUint8(130); + writeValue(buffer, value.encode()); + } else { + super.writeValue(buffer, value); + } + } + + @override + Object? readValueOfType(int type, ReadBuffer buffer) { + switch (type) { + case 129: + return AppInstallationsPigeonSettings.decode(readValue(buffer)!); + case 130: + return AppInstallationsPigeonFirebaseApp.decode(readValue(buffer)!); + default: + return super.readValueOfType(type, buffer); + } + } +} + +class FirebaseAppInstallationsHostApi { + /// Constructor for [FirebaseAppInstallationsHostApi]. The [binaryMessenger] named argument is + /// available for dependency injection. If it is left null, the default + /// BinaryMessenger will be used which routes to the host platform. + FirebaseAppInstallationsHostApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + final BinaryMessenger? pigeonVar_binaryMessenger; + + static const MessageCodec pigeonChannelCodec = _PigeonCodec(); + + final String pigeonVar_messageChannelSuffix; + + Future initializeApp(AppInstallationsPigeonFirebaseApp app, AppInstallationsPigeonSettings settings) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([app, settings]); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + Future delete(AppInstallationsPigeonFirebaseApp app) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([app]); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + Future getId(AppInstallationsPigeonFirebaseApp app) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([app]); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else if (pigeonVar_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (pigeonVar_replyList[0] as String?)!; + } + } + + Future getToken(AppInstallationsPigeonFirebaseApp app, bool forceRefresh) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([app, forceRefresh]); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else if (pigeonVar_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (pigeonVar_replyList[0] as String?)!; + } + } + + Future onIdChange(AppInstallationsPigeonFirebaseApp app, String newId) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([app, newId]); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } +} + +abstract class FirebaseAppInstallationsFlutterApi { + static const MessageCodec pigeonChannelCodec = _PigeonCodec(); + + Future registerIdTokenListener(AppInstallationsPigeonFirebaseApp app); + + static void setUp(FirebaseAppInstallationsFlutterApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { + messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + { + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener$messageChannelSuffix', pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (api == null) { + pigeonVar_channel.setMessageHandler(null); + } else { + pigeonVar_channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener was null.'); + final List args = (message as List?)!; + final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + assert(arg_app != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener was null, expected non-null AppInstallationsPigeonFirebaseApp.'); + try { + final String output = await api.registerIdTokenListener(arg_app!); + return wrapResponse(result: output); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } +} diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/copyright.txt b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/copyright.txt new file mode 100644 index 000000000000..4e197781c6db --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/copyright.txt @@ -0,0 +1,3 @@ +Copyright 2025, the Chromium project authors. Please see the AUTHORS file +for details. All rights reserved. Use of this source code is governed by a +BSD-style license that can be found in the LICENSE file. \ No newline at end of file diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart new file mode 100644 index 000000000000..7a59f2cc8689 --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart @@ -0,0 +1,72 @@ +// Copyright 2025 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:pigeon/pigeon.dart'; + +@ConfigurePigeon( + PigeonOptions( + dartOut: 'lib/src/pigeon/messages.pigeon.dart', + dartTestOut: 'test/pigeon/test_api.dart', + dartPackageName: 'firebase_app_installations_platform_interface', + javaOut: + '../firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java', + javaOptions: JavaOptions( + package: 'io.flutter.plugins.firebase.installations', + className: 'GeneratedAndroidFirebaseAppInstallations', + ), + objcHeaderOut: + '../firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h', + objcSourceOut: + '../firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m', + cppHeaderOut: '../firebase_app_installations/windows/messages.g.h', + cppSourceOut: '../firebase_app_installations/windows/messages.g.cpp', + cppOptions: CppOptions(namespace: 'firebase_app_installations_windows'), + copyrightHeader: 'pigeons/copyright.txt', + ), +) +class AppInstallationsPigeonSettings { + const AppInstallationsPigeonSettings({ + required this.persistenceEnabled, + required this.forceRefreshOnSignIn, + required this.forceRefreshOnTokenChange, + required this.forceRefreshOnAppUpdate, + }); + + final bool persistenceEnabled; + final bool forceRefreshOnSignIn; + final bool forceRefreshOnTokenChange; + final bool forceRefreshOnAppUpdate; +} + +class AppInstallationsPigeonFirebaseApp { + const AppInstallationsPigeonFirebaseApp({ + required this.appName, + }); + + final String appName; +} + +@HostApi(dartHostTestHandler: 'TestFirebaseAppInstallationsHostApi') +abstract class FirebaseAppInstallationsHostApi { + @async + void initializeApp(AppInstallationsPigeonFirebaseApp app, AppInstallationsPigeonSettings settings); + + @async + void delete(AppInstallationsPigeonFirebaseApp app); + + @async + String getId(AppInstallationsPigeonFirebaseApp app); + + @async + String getToken(AppInstallationsPigeonFirebaseApp app, bool forceRefresh); + + @async + void onIdChange(AppInstallationsPigeonFirebaseApp app, String newId); +} + +@FlutterApi() +abstract class FirebaseAppInstallationsFlutterApi { + @async + String registerIdTokenListener(AppInstallationsPigeonFirebaseApp app); +} diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pubspec.yaml b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pubspec.yaml index 15dcc6272874..55722ebfaf47 100644 --- a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pubspec.yaml +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pubspec.yaml @@ -21,3 +21,4 @@ dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^4.0.0 + pigeon: 25.3.2 \ No newline at end of file diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/test/pigeon/test_api.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/test/pigeon/test_api.dart new file mode 100644 index 000000000000..fc63484a77a8 --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/test/pigeon/test_api.dart @@ -0,0 +1,199 @@ +// Copyright 2025, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Autogenerated from Pigeon (v25.3.2), do not edit directly. +// See also: https://pub.dev/packages/pigeon +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import, no_leading_underscores_for_local_identifiers +// ignore_for_file: avoid_relative_lib_imports +import 'dart:async'; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:firebase_app_installations_platform_interface/src/pigeon/messages.pigeon.dart'; + + +class _PigeonCodec extends StandardMessageCodec { + const _PigeonCodec(); + @override + void writeValue(WriteBuffer buffer, Object? value) { + if (value is int) { + buffer.putUint8(4); + buffer.putInt64(value); + } else if (value is AppInstallationsPigeonSettings) { + buffer.putUint8(129); + writeValue(buffer, value.encode()); + } else if (value is AppInstallationsPigeonFirebaseApp) { + buffer.putUint8(130); + writeValue(buffer, value.encode()); + } else { + super.writeValue(buffer, value); + } + } + + @override + Object? readValueOfType(int type, ReadBuffer buffer) { + switch (type) { + case 129: + return AppInstallationsPigeonSettings.decode(readValue(buffer)!); + case 130: + return AppInstallationsPigeonFirebaseApp.decode(readValue(buffer)!); + default: + return super.readValueOfType(type, buffer); + } + } +} + +abstract class TestFirebaseAppInstallationsHostApi { + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static const MessageCodec pigeonChannelCodec = _PigeonCodec(); + + Future initializeApp(AppInstallationsPigeonFirebaseApp app, AppInstallationsPigeonSettings settings); + + Future delete(AppInstallationsPigeonFirebaseApp app); + + Future getId(AppInstallationsPigeonFirebaseApp app); + + Future getToken(AppInstallationsPigeonFirebaseApp app, bool forceRefresh); + + Future onIdChange(AppInstallationsPigeonFirebaseApp app, String newId); + + static void setUp(TestFirebaseAppInstallationsHostApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { + messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + { + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp$messageChannelSuffix', pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp was null.'); + final List args = (message as List?)!; + final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + assert(arg_app != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp was null, expected non-null AppInstallationsPigeonFirebaseApp.'); + final AppInstallationsPigeonSettings? arg_settings = (args[1] as AppInstallationsPigeonSettings?); + assert(arg_settings != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp was null, expected non-null AppInstallationsPigeonSettings.'); + try { + await api.initializeApp(arg_app!, arg_settings!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + { + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete$messageChannelSuffix', pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete was null.'); + final List args = (message as List?)!; + final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + assert(arg_app != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete was null, expected non-null AppInstallationsPigeonFirebaseApp.'); + try { + await api.delete(arg_app!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + { + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId$messageChannelSuffix', pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId was null.'); + final List args = (message as List?)!; + final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + assert(arg_app != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId was null, expected non-null AppInstallationsPigeonFirebaseApp.'); + try { + final String output = await api.getId(arg_app!); + return [output]; + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + { + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken$messageChannelSuffix', pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken was null.'); + final List args = (message as List?)!; + final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + assert(arg_app != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken was null, expected non-null AppInstallationsPigeonFirebaseApp.'); + final bool? arg_forceRefresh = (args[1] as bool?); + assert(arg_forceRefresh != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken was null, expected non-null bool.'); + try { + final String output = await api.getToken(arg_app!, arg_forceRefresh!); + return [output]; + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + { + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange$messageChannelSuffix', pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange was null.'); + final List args = (message as List?)!; + final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + assert(arg_app != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange was null, expected non-null AppInstallationsPigeonFirebaseApp.'); + final String? arg_newId = (args[1] as String?); + assert(arg_newId != null, + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange was null, expected non-null String.'); + try { + await api.onIdChange(arg_app!, arg_newId!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + } +} From 28f95e200dd7aff2e4b1b950cadd3de44a45801d Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Fri, 28 Nov 2025 14:37:14 +0000 Subject: [PATCH 02/25] feat: use new api with android --- .../FirebaseInstallationsPlugin.java | 96 ++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java index 2ddb5d1e54fd..18abcbfb7f1a 100644 --- a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java @@ -21,13 +21,19 @@ import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugins.firebase.core.FlutterFirebasePlugin; import io.flutter.plugins.firebase.core.FlutterFirebasePluginRegistry; +import io.flutter.plugins.firebase.installations.GeneratedAndroidFirebaseAppInstallations; +import io.flutter.plugins.firebase.installations.GeneratedAndroidFirebaseAppInstallations.AppInstallationsPigeonFirebaseApp; +import io.flutter.plugins.firebase.installations.GeneratedAndroidFirebaseAppInstallations.AppInstallationsPigeonSettings; import java.util.HashMap; import java.util.Map; import java.util.Objects; /** FirebaseInstallationsPlugin */ public class FirebaseInstallationsPlugin - implements FlutterFirebasePlugin, FlutterPlugin, MethodCallHandler { + implements FlutterFirebasePlugin, + FlutterPlugin, + MethodCallHandler, + GeneratedAndroidFirebaseAppInstallations.FirebaseAppInstallationsHostApi { private MethodChannel channel; private static final String METHOD_CHANNEL_NAME = "plugins.flutter.io/firebase_app_installations"; private final Map streamHandlers = new HashMap<>(); @@ -38,6 +44,9 @@ private MethodChannel setup(BinaryMessenger binaryMessenger) { final MethodChannel channel = new MethodChannel(binaryMessenger, METHOD_CHANNEL_NAME); channel.setMethodCallHandler(this); this.messenger = binaryMessenger; + // Set up Pigeon host API handlers. + GeneratedAndroidFirebaseAppInstallations.FirebaseAppInstallationsHostApi.setUp( + binaryMessenger, this); return channel; } @@ -64,6 +73,12 @@ private FirebaseInstallations getInstallations(Map arguments) { return FirebaseInstallations.getInstance(app); } + private FirebaseInstallations getInstallations(AppInstallationsPigeonFirebaseApp appArg) { + @NonNull String appName = appArg.getAppName(); + FirebaseApp app = FirebaseApp.getInstance(appName); + return FirebaseInstallations.getInstance(app); + } + private Task getId(Map arguments) { TaskCompletionSource taskCompletionSource = new TaskCompletionSource<>(); @@ -145,6 +160,85 @@ private Task deleteId(Map arguments) { return taskCompletionSource.getTask(); } + // Pigeon FirebaseAppInstallationsHostApi implementation. + + @Override + public void initializeApp( + @NonNull AppInstallationsPigeonFirebaseApp app, + @NonNull AppInstallationsPigeonSettings settings, + @NonNull GeneratedAndroidFirebaseAppInstallations.VoidResult result) { + // Currently there is no per-app configurable behavior required on Android for these settings. + // We execute asynchronously to keep the threading model consistent. + cachedThreadPool.execute( + () -> { + try { + // Touch the instance to ensure it's initialized. + getInstallations(app); + result.success(); + } catch (Exception e) { + result.error(e); + } + }); + } + + @Override + public void delete( + @NonNull AppInstallationsPigeonFirebaseApp app, + @NonNull GeneratedAndroidFirebaseAppInstallations.VoidResult result) { + cachedThreadPool.execute( + () -> { + try { + Tasks.await(getInstallations(app).delete()); + result.success(); + } catch (Exception e) { + result.error(e); + } + }); + } + + @Override + public void getId( + @NonNull AppInstallationsPigeonFirebaseApp app, + @NonNull GeneratedAndroidFirebaseAppInstallations.Result result) { + cachedThreadPool.execute( + () -> { + try { + String id = Tasks.await(getInstallations(app).getId()); + result.success(id); + } catch (Exception e) { + result.error(e); + } + }); + } + + @Override + public void getToken( + @NonNull AppInstallationsPigeonFirebaseApp app, + @NonNull Boolean forceRefresh, + @NonNull GeneratedAndroidFirebaseAppInstallations.Result result) { + cachedThreadPool.execute( + () -> { + try { + FirebaseInstallations firebaseInstallations = getInstallations(app); + InstallationTokenResult tokenResult = + Tasks.await(firebaseInstallations.getToken(forceRefresh)); + result.success(tokenResult.getToken()); + } catch (Exception e) { + result.error(e); + } + }); + } + + @Override + public void onIdChange( + @NonNull AppInstallationsPigeonFirebaseApp app, + @NonNull String newId, + @NonNull GeneratedAndroidFirebaseAppInstallations.VoidResult result) { + // The Dart side currently uses an EventChannel-based listener, so this Pigeon hook + // is a no-op placeholder to satisfy the interface. + result.success(); + } + @Override public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { Task methodCallTask; From b3efe21eed4178f0b5f3d2b1f8dc4395d5cfadbf Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Fri, 28 Nov 2025 15:00:09 +0000 Subject: [PATCH 03/25] feat: ios pigeons --- .../FirebaseInstallationsPlugin.swift | 84 ++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift index fb9ed2a06894..3f911a3a0630 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift @@ -17,7 +17,8 @@ import FirebaseInstallations let kFLTFirebaseInstallationsChannelName = "plugins.flutter.io/firebase_app_installations" -public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, FlutterPlugin { +public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, + FlutterPlugin, FirebaseAppInstallationsHostApi { private var eventSink: FlutterEventSink? private var messenger: FlutterBinaryMessenger private var streamHandler = [String: IdChangedStreamHandler?]() @@ -42,6 +43,9 @@ public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, F let instance = FirebaseInstallationsPlugin(messenger: binaryMessenger) FLTFirebasePluginRegistry.sharedInstance().register(instance) registrar.addMethodCallDelegate(instance, channel: channel) + + // Set up Pigeon host API handlers for Dart-side FirebaseAppInstallationsHostApi. + SetUpFirebaseAppInstallationsHostApi(binaryMessenger, instance) } public func firebaseLibraryVersion() -> String { @@ -71,6 +75,10 @@ public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, F return Installations.installations(app: app) } + private func getInstallations(app: AppInstallationsPigeonFirebaseApp) -> Installations { + getInstallations(appName: app.appName) + } + /// Gets Installations Id for an instance. /// - Parameter arguments: the arguments passed by the Dart calling method /// - Parameter result: the result instance used to send the result to Dart. @@ -122,6 +130,80 @@ public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, F } } + // MARK: - FirebaseAppInstallationsHostApi (Pigeon) + + public func initializeAppApp( + _ app: AppInstallationsPigeonFirebaseApp, + settings: AppInstallationsPigeonSettings, + completion: @escaping (FlutterError?) -> Void + ) { + // Currently no per-app settings are applied on iOS; ensure the instance is created. + _ = getInstallations(app: app) + completion(nil) + } + + public func deleteApp( + _ app: AppInstallationsPigeonFirebaseApp, + completion: @escaping (FlutterError?) -> Void + ) { + let instance = getInstallations(app: app) + instance.delete { error in + if let error = error as NSError? { + let code = self + .mapInstallationsErrorCodes(code: UInt(error.code)) as String + completion(FlutterError(code: code, message: error.localizedDescription, details: nil)) + } else { + completion(nil) + } + } + } + + public func getIdApp( + _ app: AppInstallationsPigeonFirebaseApp, + completion: @escaping (String?, FlutterError?) -> Void + ) { + let instance = getInstallations(app: app) + instance.installationID { id, error in + if let error = error as NSError? { + let code = self + .mapInstallationsErrorCodes(code: UInt(error.code)) as String + completion(nil, FlutterError(code: code, message: error.localizedDescription, details: nil)) + } else { + completion(id, nil) + } + } + } + + public func getTokenApp( + _ app: AppInstallationsPigeonFirebaseApp, + forceRefresh: Bool, + completion: @escaping (String?, FlutterError?) -> Void + ) { + let instance = getInstallations(app: app) + instance.authTokenForcingRefresh(forceRefresh) { tokenResult, error in + if let error = error as NSError? { + let code = self + .mapInstallationsErrorCodes(code: UInt(error.code)) as String + completion( + nil, + FlutterError(code: code, message: error.localizedDescription, details: nil) + ) + } else { + completion(tokenResult?.authToken, nil) + } + } + } + + public func onIdChangeApp( + _ app: AppInstallationsPigeonFirebaseApp, + newId: String, + completion: @escaping (FlutterError?) -> Void + ) { + // The Dart side currently uses an EventChannel-based listener, so this Pigeon hook + // is a no-op placeholder to satisfy the interface. + completion(nil) + } + /// Registers a listener for changes in the Installations Id. /// - Parameter arguments: the arguments passed by the Dart calling method /// - Parameter result: the result instance used to send the result to Dart. From caa7c3568af2a744e482d19f5a86966f748090ce Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 2 Dec 2025 11:44:29 +0000 Subject: [PATCH 04/25] fix(ios): iswift headers --- .../ios/firebase_app_installations.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec index e99dea9b9010..9f08ec7140ef 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec @@ -24,7 +24,7 @@ Pod::Spec.new do |s| s.license = { :file => '../LICENSE' } s.authors = 'The Chromium Authors' s.source = { :path => '.' } - s.source_files = 'firebase_app_installations/Sources/**/*.swift' + s.source_files = 'firebase_app_installations/Sources/**/*.{swift,h,m}' s.ios.deployment_target = '15.0' From 569f915abceebdbe615ba8d5a95c46a5e479ecc7 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 2 Dec 2025 11:57:24 +0000 Subject: [PATCH 05/25] fix(ios): rename functions --- .../FirebaseInstallationsPlugin.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift index 3f911a3a0630..e4df327c541d 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift @@ -142,7 +142,7 @@ public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, completion(nil) } - public func deleteApp( + public func delete( _ app: AppInstallationsPigeonFirebaseApp, completion: @escaping (FlutterError?) -> Void ) { @@ -194,7 +194,7 @@ public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, } } - public func onIdChangeApp( + public func onIdChange( _ app: AppInstallationsPigeonFirebaseApp, newId: String, completion: @escaping (FlutterError?) -> Void From 83f7636de700148f92420ac01d675b3ffcb0482f Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 2 Dec 2025 12:13:00 +0000 Subject: [PATCH 06/25] fix(ios): expose pigeons --- .../ios/firebase_app_installations.podspec | 1 + .../firebase_app_installations.h | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec index 9f08ec7140ef..c86a3d138086 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec @@ -25,6 +25,7 @@ Pod::Spec.new do |s| s.authors = 'The Chromium Authors' s.source = { :path => '.' } s.source_files = 'firebase_app_installations/Sources/**/*.{swift,h,m}' + s.public_header_files = 'firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h' s.ios.deployment_target = '15.0' diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h new file mode 100644 index 000000000000..8cfd4491d404 --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h @@ -0,0 +1,8 @@ +// Umbrella header for the firebase_app_installations iOS pod. +// Exposes the generated Pigeon APIs to Swift and ObjC consumers. + +#import + +#import "firebase_app_installations_messages.g.h" + + From c410c26e8570d739678df48ab7dab10ab9386579 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 2 Dec 2025 12:25:02 +0000 Subject: [PATCH 07/25] fix(ios): imports --- .../ios/firebase_app_installations.podspec | 5 ++++- .../firebase_app_installations/firebase_app_installations.h | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec index c86a3d138086..610ce415e688 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec @@ -25,7 +25,10 @@ Pod::Spec.new do |s| s.authors = 'The Chromium Authors' s.source = { :path => '.' } s.source_files = 'firebase_app_installations/Sources/**/*.{swift,h,m}' - s.public_header_files = 'firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h' + s.public_header_files = [ + 'firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h', + 'firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h', + ] s.ios.deployment_target = '15.0' diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h index 8cfd4491d404..82fa063d3df0 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h @@ -3,6 +3,5 @@ #import -#import "firebase_app_installations_messages.g.h" - +#import From b68cdbadcaf0bfdef3b2d14fbd5c20a54e3f00b3 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 2 Dec 2025 13:04:19 +0000 Subject: [PATCH 08/25] fix(macos): include pigeons for swift --- .../FirebaseAppInstallationsMessages.g.swift | 382 ++++++++++++++++++ .../pigeons/messages.dart | 2 + 2 files changed, 384 insertions(+) create mode 100644 packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift new file mode 100644 index 000000000000..02c6767391e3 --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift @@ -0,0 +1,382 @@ +// Copyright 2025, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Autogenerated from Pigeon (v25.3.2), 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 ?? ""), details: \(details ?? "")" + } +} + +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 createConnectionError(withChannelName channelName: String) -> PigeonError { + return PigeonError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") +} + +private func isNullish(_ value: Any?) -> Bool { + return value is NSNull || value == nil +} + +private func nilOrValue(_ value: Any?) -> T? { + if value is NSNull { return nil } + return value as! T? +} + +func deepEqualsFirebaseAppInstallationsMessages(_ lhs: Any?, _ rhs: Any?) -> Bool { + let cleanLhs = nilOrValue(lhs) as Any? + let cleanRhs = nilOrValue(rhs) as Any? + switch (cleanLhs, cleanRhs) { + case (nil, nil): + return true + + case (nil, _), (_, nil): + return false + + case is (Void, Void): + return true + + case let (cleanLhsHashable, cleanRhsHashable) as (AnyHashable, AnyHashable): + return cleanLhsHashable == cleanRhsHashable + + case let (cleanLhsArray, cleanRhsArray) as ([Any?], [Any?]): + guard cleanLhsArray.count == cleanRhsArray.count else { return false } + for (index, element) in cleanLhsArray.enumerated() { + if !deepEqualsFirebaseAppInstallationsMessages(element, cleanRhsArray[index]) { + return false + } + } + return true + + case let (cleanLhsDictionary, cleanRhsDictionary) as ([AnyHashable: Any?], [AnyHashable: Any?]): + guard cleanLhsDictionary.count == cleanRhsDictionary.count else { return false } + for (key, cleanLhsValue) in cleanLhsDictionary { + guard cleanRhsDictionary.index(forKey: key) != nil else { return false } + if !deepEqualsFirebaseAppInstallationsMessages(cleanLhsValue, cleanRhsDictionary[key]!) { + return false + } + } + return true + + default: + // Any other type shouldn't be able to be used with pigeon. File an issue if you find this to be untrue. + return false + } +} + +func deepHashFirebaseAppInstallationsMessages(value: Any?, hasher: inout Hasher) { + if let valueList = value as? [AnyHashable] { + for item in valueList { deepHashFirebaseAppInstallationsMessages(value: item, hasher: &hasher) } + return + } + + if let valueDict = value as? [AnyHashable: AnyHashable] { + for key in valueDict.keys { + hasher.combine(key) + deepHashFirebaseAppInstallationsMessages(value: valueDict[key]!, hasher: &hasher) + } + return + } + + if let hashableValue = value as? AnyHashable { + hasher.combine(hashableValue.hashValue) + } + + return hasher.combine(String(describing: value)) +} + + + +/// Generated class from Pigeon that represents data sent in messages. +struct AppInstallationsPigeonSettings: Hashable { + var persistenceEnabled: Bool + var forceRefreshOnSignIn: Bool + var forceRefreshOnTokenChange: Bool + var forceRefreshOnAppUpdate: Bool + + + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ pigeonVar_list: [Any?]) -> AppInstallationsPigeonSettings? { + let persistenceEnabled = pigeonVar_list[0] as! Bool + let forceRefreshOnSignIn = pigeonVar_list[1] as! Bool + let forceRefreshOnTokenChange = pigeonVar_list[2] as! Bool + let forceRefreshOnAppUpdate = pigeonVar_list[3] as! Bool + + return AppInstallationsPigeonSettings( + persistenceEnabled: persistenceEnabled, + forceRefreshOnSignIn: forceRefreshOnSignIn, + forceRefreshOnTokenChange: forceRefreshOnTokenChange, + forceRefreshOnAppUpdate: forceRefreshOnAppUpdate + ) + } + func toList() -> [Any?] { + return [ + persistenceEnabled, + forceRefreshOnSignIn, + forceRefreshOnTokenChange, + forceRefreshOnAppUpdate, + ] + } + static func == (lhs: AppInstallationsPigeonSettings, rhs: AppInstallationsPigeonSettings) -> Bool { + return deepEqualsFirebaseAppInstallationsMessages(lhs.toList(), rhs.toList()) } + func hash(into hasher: inout Hasher) { + deepHashFirebaseAppInstallationsMessages(value: toList(), hasher: &hasher) + } +} + +/// Generated class from Pigeon that represents data sent in messages. +struct AppInstallationsPigeonFirebaseApp: Hashable { + var appName: String + + + // swift-format-ignore: AlwaysUseLowerCamelCase + static func fromList(_ pigeonVar_list: [Any?]) -> AppInstallationsPigeonFirebaseApp? { + let appName = pigeonVar_list[0] as! String + + return AppInstallationsPigeonFirebaseApp( + appName: appName + ) + } + func toList() -> [Any?] { + return [ + appName + ] + } + static func == (lhs: AppInstallationsPigeonFirebaseApp, rhs: AppInstallationsPigeonFirebaseApp) -> Bool { + return deepEqualsFirebaseAppInstallationsMessages(lhs.toList(), rhs.toList()) } + func hash(into hasher: inout Hasher) { + deepHashFirebaseAppInstallationsMessages(value: toList(), hasher: &hasher) + } +} + +private class FirebaseAppInstallationsMessagesPigeonCodecReader: FlutterStandardReader { + override func readValue(ofType type: UInt8) -> Any? { + switch type { + case 129: + return AppInstallationsPigeonSettings.fromList(self.readValue() as! [Any?]) + case 130: + return AppInstallationsPigeonFirebaseApp.fromList(self.readValue() as! [Any?]) + default: + return super.readValue(ofType: type) + } + } +} + +private class FirebaseAppInstallationsMessagesPigeonCodecWriter: FlutterStandardWriter { + override func writeValue(_ value: Any) { + if let value = value as? AppInstallationsPigeonSettings { + super.writeByte(129) + super.writeValue(value.toList()) + } else if let value = value as? AppInstallationsPigeonFirebaseApp { + super.writeByte(130) + super.writeValue(value.toList()) + } else { + super.writeValue(value) + } + } +} + +private class FirebaseAppInstallationsMessagesPigeonCodecReaderWriter: FlutterStandardReaderWriter { + override func reader(with data: Data) -> FlutterStandardReader { + return FirebaseAppInstallationsMessagesPigeonCodecReader(data: data) + } + + override func writer(with data: NSMutableData) -> FlutterStandardWriter { + return FirebaseAppInstallationsMessagesPigeonCodecWriter(data: data) + } +} + +class FirebaseAppInstallationsMessagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable { + static let shared = FirebaseAppInstallationsMessagesPigeonCodec(readerWriter: FirebaseAppInstallationsMessagesPigeonCodecReaderWriter()) +} + + +/// Generated protocol from Pigeon that represents a handler of messages from Flutter. +protocol FirebaseAppInstallationsHostApi { + func initializeApp(app: AppInstallationsPigeonFirebaseApp, settings: AppInstallationsPigeonSettings, completion: @escaping (Result) -> Void) + func delete(app: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result) -> Void) + func getId(app: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result) -> Void) + func getToken(app: AppInstallationsPigeonFirebaseApp, forceRefresh: Bool, completion: @escaping (Result) -> Void) + func onIdChange(app: AppInstallationsPigeonFirebaseApp, newId: String, completion: @escaping (Result) -> Void) +} + +/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. +class FirebaseAppInstallationsHostApiSetup { + static var codec: FlutterStandardMessageCodec { FirebaseAppInstallationsMessagesPigeonCodec.shared } + /// Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages through the `binaryMessenger`. + static func setUp(binaryMessenger: FlutterBinaryMessenger, api: FirebaseAppInstallationsHostApi?, messageChannelSuffix: String = "") { + let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : "" + let initializeAppChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + initializeAppChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let appArg = args[0] as! AppInstallationsPigeonFirebaseApp + let settingsArg = args[1] as! AppInstallationsPigeonSettings + api.initializeApp(app: appArg, settings: settingsArg) { result in + switch result { + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) + } + } + } + } else { + initializeAppChannel.setMessageHandler(nil) + } + let deleteChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + deleteChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let appArg = args[0] as! AppInstallationsPigeonFirebaseApp + api.delete(app: appArg) { result in + switch result { + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) + } + } + } + } else { + deleteChannel.setMessageHandler(nil) + } + let getIdChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + getIdChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let appArg = args[0] as! AppInstallationsPigeonFirebaseApp + api.getId(app: appArg) { result in + switch result { + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) + } + } + } + } else { + getIdChannel.setMessageHandler(nil) + } + let getTokenChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + getTokenChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let appArg = args[0] as! AppInstallationsPigeonFirebaseApp + let forceRefreshArg = args[1] as! Bool + api.getToken(app: appArg, forceRefresh: forceRefreshArg) { result in + switch result { + case .success(let res): + reply(wrapResult(res)) + case .failure(let error): + reply(wrapError(error)) + } + } + } + } else { + getTokenChannel.setMessageHandler(nil) + } + let onIdChangeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + onIdChangeChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let appArg = args[0] as! AppInstallationsPigeonFirebaseApp + let newIdArg = args[1] as! String + api.onIdChange(app: appArg, newId: newIdArg) { result in + switch result { + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) + } + } + } + } else { + onIdChangeChannel.setMessageHandler(nil) + } + } +} +/// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. +protocol FirebaseAppInstallationsFlutterApiProtocol { + func registerIdTokenListener(app appArg: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result) -> Void) +} +class FirebaseAppInstallationsFlutterApi: FirebaseAppInstallationsFlutterApiProtocol { + private let binaryMessenger: FlutterBinaryMessenger + private let messageChannelSuffix: String + init(binaryMessenger: FlutterBinaryMessenger, messageChannelSuffix: String = "") { + self.binaryMessenger = binaryMessenger + self.messageChannelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : "" + } + var codec: FirebaseAppInstallationsMessagesPigeonCodec { + return FirebaseAppInstallationsMessagesPigeonCodec.shared + } + func registerIdTokenListener(app appArg: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result) -> Void) { + let channelName: String = "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener\(messageChannelSuffix)" + let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + channel.sendMessage([appArg] as [Any?]) { response in + guard let listResponse = response as? [Any?] else { + completion(.failure(createConnectionError(withChannelName: channelName))) + return + } + if listResponse.count > 1 { + let code: String = listResponse[0] as! String + let message: String? = nilOrValue(listResponse[1]) + let details: String? = nilOrValue(listResponse[2]) + completion(.failure(PigeonError(code: code, message: message, details: details))) + } else if listResponse[0] == nil { + completion(.failure(PigeonError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + } else { + let result = listResponse[0] as! String + completion(.success(result)) + } + } + } +} diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart index 7a59f2cc8689..4e1f9378583d 100644 --- a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart @@ -19,6 +19,8 @@ import 'package:pigeon/pigeon.dart'; '../firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h', objcSourceOut: '../firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m', + swiftOut: + '../firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift', cppHeaderOut: '../firebase_app_installations/windows/messages.g.h', cppSourceOut: '../firebase_app_installations/windows/messages.g.cpp', cppOptions: CppOptions(namespace: 'firebase_app_installations_windows'), From 9b6f3a2aab5e26b471cec7c29bd882cefba79373 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 2 Dec 2025 14:47:30 +0000 Subject: [PATCH 09/25] fix(ios, macos): method fixes --- .../FirebaseInstallationsPlugin.swift | 69 +++++++++---------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift index e4df327c541d..a9a56db1ae8c 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift @@ -132,76 +132,75 @@ public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, // MARK: - FirebaseAppInstallationsHostApi (Pigeon) - public func initializeAppApp( - _ app: AppInstallationsPigeonFirebaseApp, + func initializeApp( + app: AppInstallationsPigeonFirebaseApp, settings: AppInstallationsPigeonSettings, - completion: @escaping (FlutterError?) -> Void + completion: @escaping (Result) -> Void ) { // Currently no per-app settings are applied on iOS; ensure the instance is created. _ = getInstallations(app: app) - completion(nil) + completion(.success(())) } - public func delete( - _ app: AppInstallationsPigeonFirebaseApp, - completion: @escaping (FlutterError?) -> Void + func delete( + app: AppInstallationsPigeonFirebaseApp, + completion: @escaping (Result) -> Void ) { let instance = getInstallations(app: app) instance.delete { error in - if let error = error as NSError? { - let code = self - .mapInstallationsErrorCodes(code: UInt(error.code)) as String - completion(FlutterError(code: code, message: error.localizedDescription, details: nil)) + if let error = error { + completion(.failure(error)) } else { - completion(nil) + completion(.success(())) } } } - public func getIdApp( - _ app: AppInstallationsPigeonFirebaseApp, - completion: @escaping (String?, FlutterError?) -> Void + func getId( + app: AppInstallationsPigeonFirebaseApp, + completion: @escaping (Result) -> Void ) { let instance = getInstallations(app: app) instance.installationID { id, error in - if let error = error as NSError? { - let code = self - .mapInstallationsErrorCodes(code: UInt(error.code)) as String - completion(nil, FlutterError(code: code, message: error.localizedDescription, details: nil)) + if let error = error { + completion(.failure(error)) + } else if let id = id { + completion(.success(id)) } else { - completion(id, nil) + completion(.failure(NSError(domain: "firebase_app_installations", + code: -1, + userInfo: [NSLocalizedDescriptionKey: "Installation ID is nil."]))) } } } - public func getTokenApp( - _ app: AppInstallationsPigeonFirebaseApp, + func getToken( + app: AppInstallationsPigeonFirebaseApp, forceRefresh: Bool, - completion: @escaping (String?, FlutterError?) -> Void + completion: @escaping (Result) -> Void ) { let instance = getInstallations(app: app) instance.authTokenForcingRefresh(forceRefresh) { tokenResult, error in - if let error = error as NSError? { - let code = self - .mapInstallationsErrorCodes(code: UInt(error.code)) as String - completion( - nil, - FlutterError(code: code, message: error.localizedDescription, details: nil) - ) + if let error = error { + completion(.failure(error)) + } else if let token = tokenResult?.authToken { + completion(.success(token)) } else { - completion(tokenResult?.authToken, nil) + completion(.failure(NSError(domain: "firebase_app_installations", + code: -1, + userInfo: [NSLocalizedDescriptionKey: "Auth token is nil."]))) } } } - public func onIdChange( - _ app: AppInstallationsPigeonFirebaseApp, + func onIdChange( + app: AppInstallationsPigeonFirebaseApp, newId: String, - completion: @escaping (FlutterError?) -> Void + completion: @escaping (Result) -> Void ) { // The Dart side currently uses an EventChannel-based listener, so this Pigeon hook // is a no-op placeholder to satisfy the interface. - completion(nil) + completion(.success(())) } /// Registers a listener for changes in the Installations Id. From b58634176e3026110aa29c3f11cd42dbde0b0bd9 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 09:54:28 +0000 Subject: [PATCH 10/25] fix(ios): host api --- .../FirebaseInstallationsPlugin.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift index a9a56db1ae8c..5118fc4847f3 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift @@ -45,7 +45,10 @@ public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, registrar.addMethodCallDelegate(instance, channel: channel) // Set up Pigeon host API handlers for Dart-side FirebaseAppInstallationsHostApi. - SetUpFirebaseAppInstallationsHostApi(binaryMessenger, instance) + FirebaseAppInstallationsHostApiSetup.setUp( + binaryMessenger: binaryMessenger, + api: instance + ) } public func firebaseLibraryVersion() -> String { From 88876517f7b40a06b86e6aab37eceba7a07285bf Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 12:01:33 +0000 Subject: [PATCH 11/25] chore: run format --- .../FirebaseAppInstallationsMessages.g.swift | 176 ++++++++++++------ .../FirebaseInstallationsPlugin.swift | 48 ++--- .../firebase_app_installations.h | 6 +- ...od_channel_firebase_app_installations.dart | 4 +- .../lib/src/pigeon/messages.pigeon.dart | 127 ++++++++----- .../pigeons/messages.dart | 3 +- .../test/pigeon/test_api.dart | 153 +++++++++------ 7 files changed, 328 insertions(+), 189 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift index 02c6767391e3..735ae2e8d703 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift @@ -27,13 +27,12 @@ final class PigeonError: Error { } var localizedDescription: String { - return - "PigeonError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" + "PigeonError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" } } private func wrapResult(_ result: Any?) -> [Any?] { - return [result] + [result] } private func wrapError(_ error: Any) -> [Any?] { @@ -59,11 +58,15 @@ private func wrapError(_ error: Any) -> [Any?] { } private func createConnectionError(withChannelName channelName: String) -> PigeonError { - return PigeonError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") + PigeonError( + code: "channel-error", + message: "Unable to establish connection on channel: '\(channelName)'.", + details: "" + ) } private func isNullish(_ value: Any?) -> Bool { - return value is NSNull || value == nil + value is NSNull || value == nil } private func nilOrValue(_ value: Any?) -> T? { @@ -107,19 +110,22 @@ func deepEqualsFirebaseAppInstallationsMessages(_ lhs: Any?, _ rhs: Any?) -> Boo return true default: - // Any other type shouldn't be able to be used with pigeon. File an issue if you find this to be untrue. + // Any other type shouldn't be able to be used with pigeon. File an issue if you find this to be + // untrue. return false } } func deepHashFirebaseAppInstallationsMessages(value: Any?, hasher: inout Hasher) { if let valueList = value as? [AnyHashable] { - for item in valueList { deepHashFirebaseAppInstallationsMessages(value: item, hasher: &hasher) } - return + for item in valueList { + deepHashFirebaseAppInstallationsMessages(value: item, hasher: &hasher) + } + return } if let valueDict = value as? [AnyHashable: AnyHashable] { - for key in valueDict.keys { + for key in valueDict.keys { hasher.combine(key) deepHashFirebaseAppInstallationsMessages(value: valueDict[key]!, hasher: &hasher) } @@ -133,8 +139,6 @@ func deepHashFirebaseAppInstallationsMessages(value: Any?, hasher: inout Hasher) return hasher.combine(String(describing: value)) } - - /// Generated class from Pigeon that represents data sent in messages. struct AppInstallationsPigeonSettings: Hashable { var persistenceEnabled: Bool @@ -142,7 +146,6 @@ struct AppInstallationsPigeonSettings: Hashable { var forceRefreshOnTokenChange: Bool var forceRefreshOnAppUpdate: Bool - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> AppInstallationsPigeonSettings? { let persistenceEnabled = pigeonVar_list[0] as! Bool @@ -157,16 +160,21 @@ struct AppInstallationsPigeonSettings: Hashable { forceRefreshOnAppUpdate: forceRefreshOnAppUpdate ) } + func toList() -> [Any?] { - return [ + [ persistenceEnabled, forceRefreshOnSignIn, forceRefreshOnTokenChange, forceRefreshOnAppUpdate, ] } - static func == (lhs: AppInstallationsPigeonSettings, rhs: AppInstallationsPigeonSettings) -> Bool { - return deepEqualsFirebaseAppInstallationsMessages(lhs.toList(), rhs.toList()) } + + static func == (lhs: AppInstallationsPigeonSettings, + rhs: AppInstallationsPigeonSettings) -> Bool { + deepEqualsFirebaseAppInstallationsMessages(lhs.toList(), rhs.toList()) + } + func hash(into hasher: inout Hasher) { deepHashFirebaseAppInstallationsMessages(value: toList(), hasher: &hasher) } @@ -176,7 +184,6 @@ struct AppInstallationsPigeonSettings: Hashable { struct AppInstallationsPigeonFirebaseApp: Hashable { var appName: String - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> AppInstallationsPigeonFirebaseApp? { let appName = pigeonVar_list[0] as! String @@ -185,13 +192,18 @@ struct AppInstallationsPigeonFirebaseApp: Hashable { appName: appName ) } + func toList() -> [Any?] { - return [ - appName + [ + appName, ] } - static func == (lhs: AppInstallationsPigeonFirebaseApp, rhs: AppInstallationsPigeonFirebaseApp) -> Bool { - return deepEqualsFirebaseAppInstallationsMessages(lhs.toList(), rhs.toList()) } + + static func == (lhs: AppInstallationsPigeonFirebaseApp, + rhs: AppInstallationsPigeonFirebaseApp) -> Bool { + deepEqualsFirebaseAppInstallationsMessages(lhs.toList(), rhs.toList()) + } + func hash(into hasher: inout Hasher) { deepHashFirebaseAppInstallationsMessages(value: toList(), hasher: &hasher) } @@ -201,9 +213,9 @@ private class FirebaseAppInstallationsMessagesPigeonCodecReader: FlutterStandard override func readValue(ofType type: UInt8) -> Any? { switch type { case 129: - return AppInstallationsPigeonSettings.fromList(self.readValue() as! [Any?]) + return AppInstallationsPigeonSettings.fromList(readValue() as! [Any?]) case 130: - return AppInstallationsPigeonFirebaseApp.fromList(self.readValue() as! [Any?]) + return AppInstallationsPigeonFirebaseApp.fromList(readValue() as! [Any?]) default: return super.readValue(ofType: type) } @@ -226,36 +238,54 @@ private class FirebaseAppInstallationsMessagesPigeonCodecWriter: FlutterStandard private class FirebaseAppInstallationsMessagesPigeonCodecReaderWriter: FlutterStandardReaderWriter { override func reader(with data: Data) -> FlutterStandardReader { - return FirebaseAppInstallationsMessagesPigeonCodecReader(data: data) + FirebaseAppInstallationsMessagesPigeonCodecReader(data: data) } override func writer(with data: NSMutableData) -> FlutterStandardWriter { - return FirebaseAppInstallationsMessagesPigeonCodecWriter(data: data) + FirebaseAppInstallationsMessagesPigeonCodecWriter(data: data) } } -class FirebaseAppInstallationsMessagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable { - static let shared = FirebaseAppInstallationsMessagesPigeonCodec(readerWriter: FirebaseAppInstallationsMessagesPigeonCodecReaderWriter()) +class FirebaseAppInstallationsMessagesPigeonCodec: FlutterStandardMessageCodec, + @unchecked Sendable { + static let shared = + FirebaseAppInstallationsMessagesPigeonCodec( + readerWriter: FirebaseAppInstallationsMessagesPigeonCodecReaderWriter() + ) } - /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol FirebaseAppInstallationsHostApi { - func initializeApp(app: AppInstallationsPigeonFirebaseApp, settings: AppInstallationsPigeonSettings, completion: @escaping (Result) -> Void) - func delete(app: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result) -> Void) - func getId(app: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result) -> Void) - func getToken(app: AppInstallationsPigeonFirebaseApp, forceRefresh: Bool, completion: @escaping (Result) -> Void) - func onIdChange(app: AppInstallationsPigeonFirebaseApp, newId: String, completion: @escaping (Result) -> Void) + func initializeApp(app: AppInstallationsPigeonFirebaseApp, + settings: AppInstallationsPigeonSettings, + completion: @escaping (Result) -> Void) + func delete(app: AppInstallationsPigeonFirebaseApp, + completion: @escaping (Result) -> Void) + func getId(app: AppInstallationsPigeonFirebaseApp, + completion: @escaping (Result) -> Void) + func getToken(app: AppInstallationsPigeonFirebaseApp, forceRefresh: Bool, + completion: @escaping (Result) -> Void) + func onIdChange(app: AppInstallationsPigeonFirebaseApp, newId: String, + completion: @escaping (Result) -> Void) } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class FirebaseAppInstallationsHostApiSetup { - static var codec: FlutterStandardMessageCodec { FirebaseAppInstallationsMessagesPigeonCodec.shared } - /// Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages through the `binaryMessenger`. - static func setUp(binaryMessenger: FlutterBinaryMessenger, api: FirebaseAppInstallationsHostApi?, messageChannelSuffix: String = "") { + static var codec: FlutterStandardMessageCodec { + FirebaseAppInstallationsMessagesPigeonCodec.shared + } + + /// Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages through the + /// `binaryMessenger`. + static func setUp(binaryMessenger: FlutterBinaryMessenger, api: FirebaseAppInstallationsHostApi?, + messageChannelSuffix: String = "") { let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : "" - let initializeAppChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let initializeAppChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp\(channelSuffix)", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { initializeAppChannel.setMessageHandler { message, reply in let args = message as! [Any?] let appArg = args[0] as! AppInstallationsPigeonFirebaseApp @@ -264,7 +294,7 @@ class FirebaseAppInstallationsHostApiSetup { switch result { case .success: reply(wrapResult(nil)) - case .failure(let error): + case let .failure(error): reply(wrapError(error)) } } @@ -272,8 +302,12 @@ class FirebaseAppInstallationsHostApiSetup { } else { initializeAppChannel.setMessageHandler(nil) } - let deleteChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let deleteChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete\(channelSuffix)", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { deleteChannel.setMessageHandler { message, reply in let args = message as! [Any?] let appArg = args[0] as! AppInstallationsPigeonFirebaseApp @@ -281,7 +315,7 @@ class FirebaseAppInstallationsHostApiSetup { switch result { case .success: reply(wrapResult(nil)) - case .failure(let error): + case let .failure(error): reply(wrapError(error)) } } @@ -289,16 +323,20 @@ class FirebaseAppInstallationsHostApiSetup { } else { deleteChannel.setMessageHandler(nil) } - let getIdChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let getIdChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId\(channelSuffix)", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { getIdChannel.setMessageHandler { message, reply in let args = message as! [Any?] let appArg = args[0] as! AppInstallationsPigeonFirebaseApp api.getId(app: appArg) { result in switch result { - case .success(let res): + case let .success(res): reply(wrapResult(res)) - case .failure(let error): + case let .failure(error): reply(wrapError(error)) } } @@ -306,17 +344,21 @@ class FirebaseAppInstallationsHostApiSetup { } else { getIdChannel.setMessageHandler(nil) } - let getTokenChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let getTokenChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken\(channelSuffix)", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { getTokenChannel.setMessageHandler { message, reply in let args = message as! [Any?] let appArg = args[0] as! AppInstallationsPigeonFirebaseApp let forceRefreshArg = args[1] as! Bool api.getToken(app: appArg, forceRefresh: forceRefreshArg) { result in switch result { - case .success(let res): + case let .success(res): reply(wrapResult(res)) - case .failure(let error): + case let .failure(error): reply(wrapError(error)) } } @@ -324,8 +366,12 @@ class FirebaseAppInstallationsHostApiSetup { } else { getTokenChannel.setMessageHandler(nil) } - let onIdChangeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let onIdChangeChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange\(channelSuffix)", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { onIdChangeChannel.setMessageHandler { message, reply in let args = message as! [Any?] let appArg = args[0] as! AppInstallationsPigeonFirebaseApp @@ -334,7 +380,7 @@ class FirebaseAppInstallationsHostApiSetup { switch result { case .success: reply(wrapResult(nil)) - case .failure(let error): + case let .failure(error): reply(wrapError(error)) } } @@ -344,10 +390,13 @@ class FirebaseAppInstallationsHostApiSetup { } } } + /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol FirebaseAppInstallationsFlutterApiProtocol { - func registerIdTokenListener(app appArg: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result) -> Void) + func registerIdTokenListener(app appArg: AppInstallationsPigeonFirebaseApp, + completion: @escaping (Result) -> Void) } + class FirebaseAppInstallationsFlutterApi: FirebaseAppInstallationsFlutterApiProtocol { private let binaryMessenger: FlutterBinaryMessenger private let messageChannelSuffix: String @@ -355,12 +404,19 @@ class FirebaseAppInstallationsFlutterApi: FirebaseAppInstallationsFlutterApiProt self.binaryMessenger = binaryMessenger self.messageChannelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : "" } + var codec: FirebaseAppInstallationsMessagesPigeonCodec { - return FirebaseAppInstallationsMessagesPigeonCodec.shared + FirebaseAppInstallationsMessagesPigeonCodec.shared } - func registerIdTokenListener(app appArg: AppInstallationsPigeonFirebaseApp, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener\(messageChannelSuffix)" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + + func registerIdTokenListener(app appArg: AppInstallationsPigeonFirebaseApp, + completion: @escaping (Result) -> Void) { + let channelName = "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener\(messageChannelSuffix)" + let channel = FlutterBasicMessageChannel( + name: channelName, + binaryMessenger: binaryMessenger, + codec: codec + ) channel.sendMessage([appArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) @@ -372,7 +428,11 @@ class FirebaseAppInstallationsFlutterApi: FirebaseAppInstallationsFlutterApiProt let details: String? = nilOrValue(listResponse[2]) completion(.failure(PigeonError(code: code, message: message, details: details))) } else if listResponse[0] == nil { - completion(.failure(PigeonError(code: "null-error", message: "Flutter api returned null value for non-null return value.", details: ""))) + completion(.failure(PigeonError( + code: "null-error", + message: "Flutter api returned null value for non-null return value.", + details: "" + ))) } else { let result = listResponse[0] as! String completion(.success(result)) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift index 5118fc4847f3..c133c3fd0413 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift @@ -135,23 +135,19 @@ public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, // MARK: - FirebaseAppInstallationsHostApi (Pigeon) - func initializeApp( - app: AppInstallationsPigeonFirebaseApp, - settings: AppInstallationsPigeonSettings, - completion: @escaping (Result) -> Void - ) { + func initializeApp(app: AppInstallationsPigeonFirebaseApp, + settings: AppInstallationsPigeonSettings, + completion: @escaping (Result) -> Void) { // Currently no per-app settings are applied on iOS; ensure the instance is created. _ = getInstallations(app: app) completion(.success(())) } - func delete( - app: AppInstallationsPigeonFirebaseApp, - completion: @escaping (Result) -> Void - ) { + func delete(app: AppInstallationsPigeonFirebaseApp, + completion: @escaping (Result) -> Void) { let instance = getInstallations(app: app) instance.delete { error in - if let error = error { + if let error { completion(.failure(error)) } else { completion(.success(())) @@ -159,32 +155,30 @@ public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, } } - func getId( - app: AppInstallationsPigeonFirebaseApp, - completion: @escaping (Result) -> Void - ) { + func getId(app: AppInstallationsPigeonFirebaseApp, + completion: @escaping (Result) -> Void) { let instance = getInstallations(app: app) instance.installationID { id, error in - if let error = error { + if let error { completion(.failure(error)) - } else if let id = id { + } else if let id { completion(.success(id)) } else { completion(.failure(NSError(domain: "firebase_app_installations", code: -1, - userInfo: [NSLocalizedDescriptionKey: "Installation ID is nil."]))) + userInfo: [ + NSLocalizedDescriptionKey: "Installation ID is nil.", + ]))) } } } - func getToken( - app: AppInstallationsPigeonFirebaseApp, - forceRefresh: Bool, - completion: @escaping (Result) -> Void - ) { + func getToken(app: AppInstallationsPigeonFirebaseApp, + forceRefresh: Bool, + completion: @escaping (Result) -> Void) { let instance = getInstallations(app: app) instance.authTokenForcingRefresh(forceRefresh) { tokenResult, error in - if let error = error { + if let error { completion(.failure(error)) } else if let token = tokenResult?.authToken { completion(.success(token)) @@ -196,11 +190,9 @@ public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, } } - func onIdChange( - app: AppInstallationsPigeonFirebaseApp, - newId: String, - completion: @escaping (Result) -> Void - ) { + func onIdChange(app: AppInstallationsPigeonFirebaseApp, + newId: String, + completion: @escaping (Result) -> Void) { // The Dart side currently uses an EventChannel-based listener, so this Pigeon hook // is a no-op placeholder to satisfy the interface. completion(.success(())) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h index 82fa063d3df0..6fb82f462208 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h @@ -1,7 +1,9 @@ +// Copyright 2025 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// // Umbrella header for the firebase_app_installations iOS pod. // Exposes the generated Pigeon APIs to Swift and ObjC consumers. #import - #import - diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart index b9e37385dd00..bf1eeb2d1912 100644 --- a/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart @@ -14,7 +14,9 @@ import 'utils/exception.dart'; class MethodChannelFirebaseAppInstallations extends FirebaseAppInstallationsPlatform { - final FirebaseAppInstallationsHostApi _api = FirebaseAppInstallationsHostApi(); + final FirebaseAppInstallationsHostApi _api = + FirebaseAppInstallationsHostApi(); + /// Returns a stub instance to allow the platform interface to access /// the class instance statically. static MethodChannelFirebaseAppInstallations get instance { diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart index 5f082a02172a..147f8f1ae2ce 100644 --- a/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart @@ -18,7 +18,8 @@ PlatformException _createConnectionError(String channelName) { ); } -List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { +List wrapResponse( + {Object? result, PlatformException? error, bool empty = false}) { if (empty) { return []; } @@ -27,21 +28,22 @@ List wrapResponse({Object? result, PlatformException? error, bool empty } return [error.code, error.message, error.details]; } + bool _deepEquals(Object? a, Object? b) { if (a is List && b is List) { return a.length == b.length && a.indexed - .every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1])); + .every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1])); } if (a is Map && b is Map) { - return a.length == b.length && a.entries.every((MapEntry entry) => - (b as Map).containsKey(entry.key) && - _deepEquals(entry.value, b[entry.key])); + return a.length == b.length && + a.entries.every((MapEntry entry) => + (b as Map).containsKey(entry.key) && + _deepEquals(entry.value, b[entry.key])); } return a == b; } - class AppInstallationsPigeonSettings { AppInstallationsPigeonSettings({ required this.persistenceEnabled, @@ -68,7 +70,8 @@ class AppInstallationsPigeonSettings { } Object encode() { - return _toList(); } + return _toList(); + } static AppInstallationsPigeonSettings decode(Object result) { result as List; @@ -83,7 +86,8 @@ class AppInstallationsPigeonSettings { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! AppInstallationsPigeonSettings || other.runtimeType != runtimeType) { + if (other is! AppInstallationsPigeonSettings || + other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -94,8 +98,7 @@ class AppInstallationsPigeonSettings { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } class AppInstallationsPigeonFirebaseApp { @@ -112,7 +115,8 @@ class AppInstallationsPigeonFirebaseApp { } Object encode() { - return _toList(); } + return _toList(); + } static AppInstallationsPigeonFirebaseApp decode(Object result) { result as List; @@ -124,7 +128,8 @@ class AppInstallationsPigeonFirebaseApp { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! AppInstallationsPigeonFirebaseApp || other.runtimeType != runtimeType) { + if (other is! AppInstallationsPigeonFirebaseApp || + other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -135,11 +140,9 @@ class AppInstallationsPigeonFirebaseApp { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } - class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -147,10 +150,10 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is AppInstallationsPigeonSettings) { + } else if (value is AppInstallationsPigeonSettings) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is AppInstallationsPigeonFirebaseApp) { + } else if (value is AppInstallationsPigeonFirebaseApp) { buffer.putUint8(130); writeValue(buffer, value.encode()); } else { @@ -161,9 +164,9 @@ class _PigeonCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 129: + case 129: return AppInstallationsPigeonSettings.decode(readValue(buffer)!); - case 130: + case 130: return AppInstallationsPigeonFirebaseApp.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -175,23 +178,29 @@ class FirebaseAppInstallationsHostApi { /// Constructor for [FirebaseAppInstallationsHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - FirebaseAppInstallationsHostApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + FirebaseAppInstallationsHostApi( + {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + pigeonVar_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); final String pigeonVar_messageChannelSuffix; - Future initializeApp(AppInstallationsPigeonFirebaseApp app, AppInstallationsPigeonSettings settings) async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + Future initializeApp(AppInstallationsPigeonFirebaseApp app, + AppInstallationsPigeonSettings settings) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([app, settings]); + final Future pigeonVar_sendFuture = + pigeonVar_channel.send([app, settings]); final List? pigeonVar_replyList = await pigeonVar_sendFuture as List?; if (pigeonVar_replyList == null) { @@ -208,13 +217,16 @@ class FirebaseAppInstallationsHostApi { } Future delete(AppInstallationsPigeonFirebaseApp app) async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([app]); + final Future pigeonVar_sendFuture = + pigeonVar_channel.send([app]); final List? pigeonVar_replyList = await pigeonVar_sendFuture as List?; if (pigeonVar_replyList == null) { @@ -231,13 +243,16 @@ class FirebaseAppInstallationsHostApi { } Future getId(AppInstallationsPigeonFirebaseApp app) async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([app]); + final Future pigeonVar_sendFuture = + pigeonVar_channel.send([app]); final List? pigeonVar_replyList = await pigeonVar_sendFuture as List?; if (pigeonVar_replyList == null) { @@ -258,14 +273,18 @@ class FirebaseAppInstallationsHostApi { } } - Future getToken(AppInstallationsPigeonFirebaseApp app, bool forceRefresh) async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + Future getToken( + AppInstallationsPigeonFirebaseApp app, bool forceRefresh) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([app, forceRefresh]); + final Future pigeonVar_sendFuture = + pigeonVar_channel.send([app, forceRefresh]); final List? pigeonVar_replyList = await pigeonVar_sendFuture as List?; if (pigeonVar_replyList == null) { @@ -286,14 +305,18 @@ class FirebaseAppInstallationsHostApi { } } - Future onIdChange(AppInstallationsPigeonFirebaseApp app, String newId) async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + Future onIdChange( + AppInstallationsPigeonFirebaseApp app, String newId) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([app, newId]); + final Future pigeonVar_sendFuture = + pigeonVar_channel.send([app, newId]); final List? pigeonVar_replyList = await pigeonVar_sendFuture as List?; if (pigeonVar_replyList == null) { @@ -315,20 +338,29 @@ abstract class FirebaseAppInstallationsFlutterApi { Future registerIdTokenListener(AppInstallationsPigeonFirebaseApp app); - static void setUp(FirebaseAppInstallationsFlutterApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { - messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + static void setUp( + FirebaseAppInstallationsFlutterApi? api, { + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) { + messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener was null.'); + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener was null.'); final List args = (message as List?)!; - final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + final AppInstallationsPigeonFirebaseApp? arg_app = + (args[0] as AppInstallationsPigeonFirebaseApp?); assert(arg_app != null, 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener was null, expected non-null AppInstallationsPigeonFirebaseApp.'); try { @@ -336,8 +368,9 @@ abstract class FirebaseAppInstallationsFlutterApi { return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart index 4e1f9378583d..a74c19438b1f 100644 --- a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart @@ -52,7 +52,8 @@ class AppInstallationsPigeonFirebaseApp { @HostApi(dartHostTestHandler: 'TestFirebaseAppInstallationsHostApi') abstract class FirebaseAppInstallationsHostApi { @async - void initializeApp(AppInstallationsPigeonFirebaseApp app, AppInstallationsPigeonSettings settings); + void initializeApp(AppInstallationsPigeonFirebaseApp app, + AppInstallationsPigeonSettings settings); @async void delete(AppInstallationsPigeonFirebaseApp app); diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/test/pigeon/test_api.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/test/pigeon/test_api.dart index fc63484a77a8..f0779078db24 100644 --- a/packages/firebase_app_installations/firebase_app_installations_platform_interface/test/pigeon/test_api.dart +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/test/pigeon/test_api.dart @@ -13,7 +13,6 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:firebase_app_installations_platform_interface/src/pigeon/messages.pigeon.dart'; - class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -21,10 +20,10 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is AppInstallationsPigeonSettings) { + } else if (value is AppInstallationsPigeonSettings) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is AppInstallationsPigeonFirebaseApp) { + } else if (value is AppInstallationsPigeonFirebaseApp) { buffer.putUint8(130); writeValue(buffer, value.encode()); } else { @@ -35,9 +34,9 @@ class _PigeonCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 129: + case 129: return AppInstallationsPigeonSettings.decode(readValue(buffer)!); - case 130: + case 130: return AppInstallationsPigeonFirebaseApp.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -46,36 +45,52 @@ class _PigeonCodec extends StandardMessageCodec { } abstract class TestFirebaseAppInstallationsHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); - Future initializeApp(AppInstallationsPigeonFirebaseApp app, AppInstallationsPigeonSettings settings); + Future initializeApp(AppInstallationsPigeonFirebaseApp app, + AppInstallationsPigeonSettings settings); Future delete(AppInstallationsPigeonFirebaseApp app); Future getId(AppInstallationsPigeonFirebaseApp app); - Future getToken(AppInstallationsPigeonFirebaseApp app, bool forceRefresh); + Future getToken( + AppInstallationsPigeonFirebaseApp app, bool forceRefresh); Future onIdChange(AppInstallationsPigeonFirebaseApp app, String newId); - static void setUp(TestFirebaseAppInstallationsHostApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { - messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + static void setUp( + TestFirebaseAppInstallationsHostApi? api, { + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) { + messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp was null.'); + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp was null.'); final List args = (message as List?)!; - final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + final AppInstallationsPigeonFirebaseApp? arg_app = + (args[0] as AppInstallationsPigeonFirebaseApp?); assert(arg_app != null, 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp was null, expected non-null AppInstallationsPigeonFirebaseApp.'); - final AppInstallationsPigeonSettings? arg_settings = (args[1] as AppInstallationsPigeonSettings?); + final AppInstallationsPigeonSettings? arg_settings = + (args[1] as AppInstallationsPigeonSettings?); assert(arg_settings != null, 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp was null, expected non-null AppInstallationsPigeonSettings.'); try { @@ -83,24 +98,32 @@ abstract class TestFirebaseAppInstallationsHostApi { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete was null.'); + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete was null.'); final List args = (message as List?)!; - final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + final AppInstallationsPigeonFirebaseApp? arg_app = + (args[0] as AppInstallationsPigeonFirebaseApp?); assert(arg_app != null, 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete was null, expected non-null AppInstallationsPigeonFirebaseApp.'); try { @@ -108,24 +131,32 @@ abstract class TestFirebaseAppInstallationsHostApi { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId was null.'); + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId was null.'); final List args = (message as List?)!; - final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + final AppInstallationsPigeonFirebaseApp? arg_app = + (args[0] as AppInstallationsPigeonFirebaseApp?); assert(arg_app != null, 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId was null, expected non-null AppInstallationsPigeonFirebaseApp.'); try { @@ -133,52 +164,69 @@ abstract class TestFirebaseAppInstallationsHostApi { return [output]; } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken was null.'); + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken was null.'); final List args = (message as List?)!; - final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + final AppInstallationsPigeonFirebaseApp? arg_app = + (args[0] as AppInstallationsPigeonFirebaseApp?); assert(arg_app != null, 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken was null, expected non-null AppInstallationsPigeonFirebaseApp.'); final bool? arg_forceRefresh = (args[1] as bool?); assert(arg_forceRefresh != null, 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken was null, expected non-null bool.'); try { - final String output = await api.getToken(arg_app!, arg_forceRefresh!); + final String output = + await api.getToken(arg_app!, arg_forceRefresh!); return [output]; } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange was null.'); + 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange was null.'); final List args = (message as List?)!; - final AppInstallationsPigeonFirebaseApp? arg_app = (args[0] as AppInstallationsPigeonFirebaseApp?); + final AppInstallationsPigeonFirebaseApp? arg_app = + (args[0] as AppInstallationsPigeonFirebaseApp?); assert(arg_app != null, 'Argument for dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange was null, expected non-null AppInstallationsPigeonFirebaseApp.'); final String? arg_newId = (args[1] as String?); @@ -189,8 +237,9 @@ abstract class TestFirebaseAppInstallationsHostApi { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } From 1771302f7f0f3bbcf3fcc3b352288c42c9294b49 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 12:14:53 +0000 Subject: [PATCH 12/25] chore: format --- ...eratedAndroidFirebaseAppInstallations.java | 46 +- .../firebase_app_installations_messages.g.h | 52 ++- .../firebase_app_installations_messages.g.m | 116 +++-- .../windows/messages.g.cpp | 435 +++++++++++------- .../windows/messages.g.h | 2 +- 5 files changed, 393 insertions(+), 258 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java index 3535e8dda82f..87727e920a0b 100644 --- a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java @@ -21,11 +21,6 @@ import java.lang.annotation.Target; import java.nio.ByteBuffer; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import java.util.Objects; /** Generated class from Pigeon. */ @@ -41,8 +36,7 @@ public static class FlutterError extends RuntimeException { /** The error details. Must be a datatype supported by the api codec. */ public final Object details; - public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) - { + public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) { super(message); this.code = code; this.details = details; @@ -61,14 +55,15 @@ protected static ArrayList wrapError(@NonNull Throwable exception) { errorList.add(exception.toString()); errorList.add(exception.getClass().getSimpleName()); errorList.add( - "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); } return errorList; } @NonNull protected static FlutterError createConnectionError(@NonNull String channelName) { - return new FlutterError("channel-error", "Unable to establish connection on channel: " + channelName + ".", ""); + return new FlutterError( + "channel-error", "Unable to establish connection on channel: " + channelName + ".", ""); } @Target(METHOD) @@ -134,15 +129,26 @@ public void setForceRefreshOnAppUpdate(@NonNull Boolean setterArg) { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } AppInstallationsPigeonSettings that = (AppInstallationsPigeonSettings) o; - return persistenceEnabled.equals(that.persistenceEnabled) && forceRefreshOnSignIn.equals(that.forceRefreshOnSignIn) && forceRefreshOnTokenChange.equals(that.forceRefreshOnTokenChange) && forceRefreshOnAppUpdate.equals(that.forceRefreshOnAppUpdate); + return persistenceEnabled.equals(that.persistenceEnabled) + && forceRefreshOnSignIn.equals(that.forceRefreshOnSignIn) + && forceRefreshOnTokenChange.equals(that.forceRefreshOnTokenChange) + && forceRefreshOnAppUpdate.equals(that.forceRefreshOnAppUpdate); } @Override public int hashCode() { - return Objects.hash(persistenceEnabled, forceRefreshOnSignIn, forceRefreshOnTokenChange, forceRefreshOnAppUpdate); + return Objects.hash( + persistenceEnabled, + forceRefreshOnSignIn, + forceRefreshOnTokenChange, + forceRefreshOnAppUpdate); } public static final class Builder { @@ -199,7 +205,8 @@ ArrayList toList() { return toListResult; } - static @NonNull AppInstallationsPigeonSettings fromList(@NonNull ArrayList pigeonVar_list) { + static @NonNull AppInstallationsPigeonSettings fromList( + @NonNull ArrayList pigeonVar_list) { AppInstallationsPigeonSettings pigeonResult = new AppInstallationsPigeonSettings(); Object persistenceEnabled = pigeonVar_list.get(0); pigeonResult.setPersistenceEnabled((Boolean) persistenceEnabled); @@ -233,8 +240,12 @@ public void setAppName(@NonNull String setterArg) { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } AppInstallationsPigeonFirebaseApp that = (AppInstallationsPigeonFirebaseApp) o; return appName.equals(that.appName); } @@ -268,7 +279,8 @@ ArrayList toList() { return toListResult; } - static @NonNull AppInstallationsPigeonFirebaseApp fromList(@NonNull ArrayList pigeonVar_list) { + static @NonNull AppInstallationsPigeonFirebaseApp fromList( + @NonNull ArrayList pigeonVar_list) { AppInstallationsPigeonFirebaseApp pigeonResult = new AppInstallationsPigeonFirebaseApp(); Object appName = pigeonVar_list.get(0); pigeonResult.setAppName((String) appName); diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h index 45f075ab07ad..122ba1ac93fe 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h @@ -19,43 +19,59 @@ NS_ASSUME_NONNULL_BEGIN @interface AppInstallationsPigeonSettings : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithPersistenceEnabled:(BOOL )persistenceEnabled - forceRefreshOnSignIn:(BOOL )forceRefreshOnSignIn - forceRefreshOnTokenChange:(BOOL )forceRefreshOnTokenChange - forceRefreshOnAppUpdate:(BOOL )forceRefreshOnAppUpdate; -@property(nonatomic, assign) BOOL persistenceEnabled; -@property(nonatomic, assign) BOOL forceRefreshOnSignIn; -@property(nonatomic, assign) BOOL forceRefreshOnTokenChange; -@property(nonatomic, assign) BOOL forceRefreshOnAppUpdate; ++ (instancetype)makeWithPersistenceEnabled:(BOOL)persistenceEnabled + forceRefreshOnSignIn:(BOOL)forceRefreshOnSignIn + forceRefreshOnTokenChange:(BOOL)forceRefreshOnTokenChange + forceRefreshOnAppUpdate:(BOOL)forceRefreshOnAppUpdate; +@property(nonatomic, assign) BOOL persistenceEnabled; +@property(nonatomic, assign) BOOL forceRefreshOnSignIn; +@property(nonatomic, assign) BOOL forceRefreshOnTokenChange; +@property(nonatomic, assign) BOOL forceRefreshOnAppUpdate; @end @interface AppInstallationsPigeonFirebaseApp : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithAppName:(NSString *)appName; -@property(nonatomic, copy) NSString * appName; +@property(nonatomic, copy) NSString *appName; @end /// The codec used by all APIs. NSObject *nullGetFirebaseAppInstallationsMessagesCodec(void); @protocol FirebaseAppInstallationsHostApi -- (void)initializeAppApp:(AppInstallationsPigeonFirebaseApp *)app settings:(AppInstallationsPigeonSettings *)settings completion:(void (^)(FlutterError *_Nullable))completion; -- (void)deleteApp:(AppInstallationsPigeonFirebaseApp *)app completion:(void (^)(FlutterError *_Nullable))completion; -- (void)getIdApp:(AppInstallationsPigeonFirebaseApp *)app completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; -- (void)getTokenApp:(AppInstallationsPigeonFirebaseApp *)app forceRefresh:(BOOL)forceRefresh completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; -- (void)onIdChangeApp:(AppInstallationsPigeonFirebaseApp *)app newId:(NSString *)newId completion:(void (^)(FlutterError *_Nullable))completion; +- (void)initializeAppApp:(AppInstallationsPigeonFirebaseApp *)app + settings:(AppInstallationsPigeonSettings *)settings + completion:(void (^)(FlutterError *_Nullable))completion; +- (void)deleteApp:(AppInstallationsPigeonFirebaseApp *)app + completion:(void (^)(FlutterError *_Nullable))completion; +- (void)getIdApp:(AppInstallationsPigeonFirebaseApp *)app + completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; +- (void)getTokenApp:(AppInstallationsPigeonFirebaseApp *)app + forceRefresh:(BOOL)forceRefresh + completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; +- (void)onIdChangeApp:(AppInstallationsPigeonFirebaseApp *)app + newId:(NSString *)newId + completion:(void (^)(FlutterError *_Nullable))completion; @end -extern void SetUpFirebaseAppInstallationsHostApi(id binaryMessenger, NSObject *_Nullable api); +extern void SetUpFirebaseAppInstallationsHostApi( + id binaryMessenger, + NSObject *_Nullable api); -extern void SetUpFirebaseAppInstallationsHostApiWithSuffix(id binaryMessenger, NSObject *_Nullable api, NSString *messageChannelSuffix); +extern void SetUpFirebaseAppInstallationsHostApiWithSuffix( + id binaryMessenger, + NSObject *_Nullable api, + NSString *messageChannelSuffix); @interface FirebaseAppInstallationsFlutterApi : NSObject - (instancetype)initWithBinaryMessenger:(id)binaryMessenger; -- (instancetype)initWithBinaryMessenger:(id)binaryMessenger messageChannelSuffix:(nullable NSString *)messageChannelSuffix; -- (void)registerIdTokenListenerApp:(AppInstallationsPigeonFirebaseApp *)app completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; +- (instancetype)initWithBinaryMessenger:(id)binaryMessenger + messageChannelSuffix:(nullable NSString *)messageChannelSuffix; +- (void)registerIdTokenListenerApp:(AppInstallationsPigeonFirebaseApp *)app + completion: + (void (^)(NSString *_Nullable, FlutterError *_Nullable))completion; @end NS_ASSUME_NONNULL_END diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m index 504ed4fef493..ab5fef840d12 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m @@ -151,18 +151,26 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { }); return sSharedObject; } -void SetUpFirebaseAppInstallationsHostApi(id binaryMessenger, NSObject *api) { +void SetUpFirebaseAppInstallationsHostApi(id binaryMessenger, + NSObject *api) { SetUpFirebaseAppInstallationsHostApiWithSuffix(binaryMessenger, api, @""); } -void SetUpFirebaseAppInstallationsHostApiWithSuffix(id binaryMessenger, NSObject *api, NSString *messageChannelSuffix) { - messageChannelSuffix = messageChannelSuffix.length > 0 ? [NSString stringWithFormat: @".%@", messageChannelSuffix] : @""; +void SetUpFirebaseAppInstallationsHostApiWithSuffix(id binaryMessenger, + NSObject *api, + NSString *messageChannelSuffix) { + messageChannelSuffix = messageChannelSuffix.length > 0 + ? [NSString stringWithFormat:@".%@", messageChannelSuffix] + : @""; { FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp", messageChannelSuffix] - binaryMessenger:binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat: + @"%@%@", + @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(initializeAppApp:settings:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(initializeAppApp:settings:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -179,10 +187,13 @@ void SetUpFirebaseAppInstallationsHostApiWithSuffix(id b } { FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete", messageChannelSuffix] - binaryMessenger:binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat: + @"%@%@", + @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(deleteApp:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(deleteApp:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -198,10 +209,13 @@ void SetUpFirebaseAppInstallationsHostApiWithSuffix(id b } { FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId", messageChannelSuffix] - binaryMessenger:binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat: + @"%@%@", + @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(getIdApp:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(getIdApp:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -217,10 +231,13 @@ void SetUpFirebaseAppInstallationsHostApiWithSuffix(id b } { FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken", messageChannelSuffix] - binaryMessenger:binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat: + @"%@%@", + @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(getTokenApp:forceRefresh:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(getTokenApp:forceRefresh:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -237,10 +254,13 @@ void SetUpFirebaseAppInstallationsHostApiWithSuffix(id b } { FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange", messageChannelSuffix] - binaryMessenger:binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat: + @"%@%@", + @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(onIdChangeApp:newId:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(onIdChangeApp:newId:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -266,33 +286,43 @@ @implementation FirebaseAppInstallationsFlutterApi - (instancetype)initWithBinaryMessenger:(NSObject *)binaryMessenger { return [self initWithBinaryMessenger:binaryMessenger messageChannelSuffix:@""]; } -- (instancetype)initWithBinaryMessenger:(NSObject *)binaryMessenger messageChannelSuffix:(nullable NSString*)messageChannelSuffix{ +- (instancetype)initWithBinaryMessenger:(NSObject *)binaryMessenger + messageChannelSuffix:(nullable NSString *)messageChannelSuffix { self = [self init]; if (self) { _binaryMessenger = binaryMessenger; - _messageChannelSuffix = [messageChannelSuffix length] == 0 ? @"" : [NSString stringWithFormat: @".%@", messageChannelSuffix]; + _messageChannelSuffix = [messageChannelSuffix length] == 0 + ? @"" + : [NSString stringWithFormat:@".%@", messageChannelSuffix]; } return self; } -- (void)registerIdTokenListenerApp:(AppInstallationsPigeonFirebaseApp *)arg_app completion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion { - NSString *channelName = [NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener", _messageChannelSuffix]; - FlutterBasicMessageChannel *channel = - [FlutterBasicMessageChannel +- (void)registerIdTokenListenerApp:(AppInstallationsPigeonFirebaseApp *)arg_app + completion: + (void (^)(NSString *_Nullable, FlutterError *_Nullable))completion { + NSString *channelName = [NSString + stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener", + _messageChannelSuffix]; + FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel messageChannelWithName:channelName - binaryMessenger:self.binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; - [channel sendMessage:@[arg_app ?: [NSNull null]] reply:^(NSArray *reply) { - if (reply != nil) { - if (reply.count > 1) { - completion(nil, [FlutterError errorWithCode:reply[0] message:reply[1] details:reply[2]]); - } else { - NSString *output = reply[0] == [NSNull null] ? nil : reply[0]; - completion(output, nil); - } - } else { - completion(nil, createConnectionError(channelName)); - } - }]; + binaryMessenger:self.binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + [channel sendMessage:@[ arg_app ?: [NSNull null] ] + reply:^(NSArray *reply) { + if (reply != nil) { + if (reply.count > 1) { + completion(nil, [FlutterError errorWithCode:reply[0] + message:reply[1] + details:reply[2]]); + } else { + NSString *output = reply[0] == [NSNull null] ? nil : reply[0]; + completion(output, nil); + } + } else { + completion(nil, createConnectionError(channelName)); + } + }]; } @end diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp index d9ee0205e5ec..d1f8b9a4c907 100644 --- a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp @@ -34,14 +34,14 @@ FlutterError CreateConnectionError(const std::string channel_name) { // AppInstallationsPigeonSettings AppInstallationsPigeonSettings::AppInstallationsPigeonSettings( - bool persistence_enabled, - bool force_refresh_on_sign_in, - bool force_refresh_on_token_change, - bool force_refresh_on_app_update) - : persistence_enabled_(persistence_enabled), - force_refresh_on_sign_in_(force_refresh_on_sign_in), - force_refresh_on_token_change_(force_refresh_on_token_change), - force_refresh_on_app_update_(force_refresh_on_app_update) {} + bool persistence_enabled, + bool force_refresh_on_sign_in, + bool force_refresh_on_token_change, + bool force_refresh_on_app_update) + : persistence_enabled_(persistence_enabled), + force_refresh_on_sign_in_(force_refresh_on_sign_in), + force_refresh_on_token_change_(force_refresh_on_token_change), + force_refresh_on_app_update_(force_refresh_on_app_update) {} bool AppInstallationsPigeonSettings::persistence_enabled() const { return persistence_enabled_; @@ -56,25 +56,26 @@ bool AppInstallationsPigeonSettings::force_refresh_on_sign_in() const { return force_refresh_on_sign_in_; } -void AppInstallationsPigeonSettings::set_force_refresh_on_sign_in(bool value_arg) { +void AppInstallationsPigeonSettings::set_force_refresh_on_sign_in( + bool value_arg) { force_refresh_on_sign_in_ = value_arg; } - bool AppInstallationsPigeonSettings::force_refresh_on_token_change() const { return force_refresh_on_token_change_; } -void AppInstallationsPigeonSettings::set_force_refresh_on_token_change(bool value_arg) { +void AppInstallationsPigeonSettings::set_force_refresh_on_token_change( + bool value_arg) { force_refresh_on_token_change_ = value_arg; } - bool AppInstallationsPigeonSettings::force_refresh_on_app_update() const { return force_refresh_on_app_update_; } -void AppInstallationsPigeonSettings::set_force_refresh_on_app_update(bool value_arg) { +void AppInstallationsPigeonSettings::set_force_refresh_on_app_update( + bool value_arg) { force_refresh_on_app_update_ = value_arg; } @@ -89,25 +90,27 @@ EncodableList AppInstallationsPigeonSettings::ToEncodableList() const { return list; } -AppInstallationsPigeonSettings AppInstallationsPigeonSettings::FromEncodableList(const EncodableList& list) { +AppInstallationsPigeonSettings +AppInstallationsPigeonSettings::FromEncodableList( + const EncodableList& list) { AppInstallationsPigeonSettings decoded( - std::get(list[0]), - std::get(list[1]), - std::get(list[2]), - std::get(list[3])); + std::get(list[0]), std::get(list[1]), + std::get(list[2]), std::get(list[3])); return decoded; } // AppInstallationsPigeonFirebaseApp -AppInstallationsPigeonFirebaseApp::AppInstallationsPigeonFirebaseApp(const std::string& app_name) - : app_name_(app_name) {} +AppInstallationsPigeonFirebaseApp::AppInstallationsPigeonFirebaseApp( + const std::string& app_name) + : app_name_(app_name) {} const std::string& AppInstallationsPigeonFirebaseApp::app_name() const { return app_name_; } -void AppInstallationsPigeonFirebaseApp::set_app_name(std::string_view value_arg) { +void AppInstallationsPigeonFirebaseApp::set_app_name( + std::string_view value_arg) { app_name_ = value_arg; } @@ -119,9 +122,10 @@ EncodableList AppInstallationsPigeonFirebaseApp::ToEncodableList() const { return list; } -AppInstallationsPigeonFirebaseApp AppInstallationsPigeonFirebaseApp::FromEncodableList(const EncodableList& list) { - AppInstallationsPigeonFirebaseApp decoded( - std::get(list[0])); +AppInstallationsPigeonFirebaseApp +AppInstallationsPigeonFirebaseApp::FromEncodableList( + const EncodableList& list) { + AppInstallationsPigeonFirebaseApp decoded(std::get(list[0])); return decoded; } @@ -129,32 +133,43 @@ AppInstallationsPigeonFirebaseApp AppInstallationsPigeonFirebaseApp::FromEncodab PigeonInternalCodecSerializer::PigeonInternalCodecSerializer() {} EncodableValue PigeonInternalCodecSerializer::ReadValueOfType( - uint8_t type, - flutter::ByteStreamReader* stream) const { + uint8_t type, flutter::ByteStreamReader* stream) const { switch (type) { case 129: { - return CustomEncodableValue(AppInstallationsPigeonSettings::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue( + AppInstallationsPigeonSettings::FromEncodableList( + std::get(ReadValue(stream)))); + } case 130: { - return CustomEncodableValue(AppInstallationsPigeonFirebaseApp::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue( + AppInstallationsPigeonFirebaseApp::FromEncodableList( + std::get(ReadValue(stream)))); + } default: return flutter::StandardCodecSerializer::ReadValueOfType(type, stream); } } void PigeonInternalCodecSerializer::WriteValue( - const EncodableValue& value, - flutter::ByteStreamWriter* stream) const { - if (const CustomEncodableValue* custom_value = std::get_if(&value)) { + const EncodableValue& value, + flutter::ByteStreamWriter* stream) const { + if (const CustomEncodableValue* custom_value = + std::get_if(&value)) { if (custom_value->type() == typeid(AppInstallationsPigeonSettings)) { stream->WriteByte(129); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue(EncodableValue(std::any_cast( + *custom_value) + .ToEncodableList()), + stream); return; } if (custom_value->type() == typeid(AppInstallationsPigeonFirebaseApp)) { stream->WriteByte(130); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue( + EncodableValue( + std::any_cast(*custom_value) + .ToEncodableList()), + stream); return; } } @@ -162,201 +177,263 @@ void PigeonInternalCodecSerializer::WriteValue( } /// The codec used by FirebaseAppInstallationsHostApi. -const flutter::StandardMessageCodec& FirebaseAppInstallationsHostApi::GetCodec() { - return flutter::StandardMessageCodec::GetInstance(&PigeonInternalCodecSerializer::GetInstance()); +const flutter::StandardMessageCodec& +FirebaseAppInstallationsHostApi::GetCodec() { + return flutter::StandardMessageCodec::GetInstance( + &PigeonInternalCodecSerializer::GetInstance()); } -// Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages through the `binary_messenger`. +// Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages +// through the `binary_messenger`. void FirebaseAppInstallationsHostApi::SetUp( - flutter::BinaryMessenger* binary_messenger, - FirebaseAppInstallationsHostApi* api) { + flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api) { FirebaseAppInstallationsHostApi::SetUp(binary_messenger, api, ""); } void FirebaseAppInstallationsHostApi::SetUp( - flutter::BinaryMessenger* binary_messenger, - FirebaseAppInstallationsHostApi* api, - const std::string& message_channel_suffix) { - const std::string prepended_suffix = message_channel_suffix.length() > 0 ? std::string(".") + message_channel_suffix : ""; + flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api, + const std::string& message_channel_suffix) { + const std::string prepended_suffix = + message_channel_suffix.length() > 0 + ? std::string(".") + message_channel_suffix + : ""; { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel( + binary_messenger, + "dev.flutter.pigeon.firebase_app_installations_platform_interface." + "FirebaseAppInstallationsHostApi.initializeApp" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } - const auto& app_arg = std::any_cast(std::get(encodable_app_arg)); - const auto& encodable_settings_arg = args.at(1); - if (encodable_settings_arg.IsNull()) { - reply(WrapError("settings_arg unexpectedly null.")); - return; - } - const auto& settings_arg = std::any_cast(std::get(encodable_settings_arg)); - api->InitializeApp(app_arg, settings_arg, [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; + channel.SetMessageHandler( + [api](const EncodableValue& message, + const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } + const auto& app_arg = + std::any_cast( + std::get(encodable_app_arg)); + const auto& encodable_settings_arg = args.at(1); + if (encodable_settings_arg.IsNull()) { + reply(WrapError("settings_arg unexpectedly null.")); + return; + } + const auto& settings_arg = + std::any_cast( + std::get(encodable_settings_arg)); + api->InitializeApp( + app_arg, settings_arg, + [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel( + binary_messenger, + "dev.flutter.pigeon.firebase_app_installations_platform_interface." + "FirebaseAppInstallationsHostApi.delete" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } - const auto& app_arg = std::any_cast(std::get(encodable_app_arg)); - api->Delete(app_arg, [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; + channel.SetMessageHandler( + [api](const EncodableValue& message, + const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } + const auto& app_arg = + std::any_cast( + std::get(encodable_app_arg)); + api->Delete(app_arg, + [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel( + binary_messenger, + "dev.flutter.pigeon.firebase_app_installations_platform_interface." + "FirebaseAppInstallationsHostApi.getId" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } - const auto& app_arg = std::any_cast(std::get(encodable_app_arg)); - api->GetId(app_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; + channel.SetMessageHandler( + [api](const EncodableValue& message, + const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } + const auto& app_arg = + std::any_cast( + std::get(encodable_app_arg)); + api->GetId(app_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back( + EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel( + binary_messenger, + "dev.flutter.pigeon.firebase_app_installations_platform_interface." + "FirebaseAppInstallationsHostApi.getToken" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } - const auto& app_arg = std::any_cast(std::get(encodable_app_arg)); - const auto& encodable_force_refresh_arg = args.at(1); - if (encodable_force_refresh_arg.IsNull()) { - reply(WrapError("force_refresh_arg unexpectedly null.")); - return; - } - const auto& force_refresh_arg = std::get(encodable_force_refresh_arg); - api->GetToken(app_arg, force_refresh_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; + channel.SetMessageHandler( + [api](const EncodableValue& message, + const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } + const auto& app_arg = + std::any_cast( + std::get(encodable_app_arg)); + const auto& encodable_force_refresh_arg = args.at(1); + if (encodable_force_refresh_arg.IsNull()) { + reply(WrapError("force_refresh_arg unexpectedly null.")); + return; + } + const auto& force_refresh_arg = + std::get(encodable_force_refresh_arg); + api->GetToken( + app_arg, force_refresh_arg, + [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue( + std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel( + binary_messenger, + "dev.flutter.pigeon.firebase_app_installations_platform_interface." + "FirebaseAppInstallationsHostApi.onIdChange" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } - const auto& app_arg = std::any_cast(std::get(encodable_app_arg)); - const auto& encodable_new_id_arg = args.at(1); - if (encodable_new_id_arg.IsNull()) { - reply(WrapError("new_id_arg unexpectedly null.")); - return; - } - const auto& new_id_arg = std::get(encodable_new_id_arg); - api->OnIdChange(app_arg, new_id_arg, [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; + channel.SetMessageHandler( + [api](const EncodableValue& message, + const flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } + const auto& app_arg = + std::any_cast( + std::get(encodable_app_arg)); + const auto& encodable_new_id_arg = args.at(1); + if (encodable_new_id_arg.IsNull()) { + reply(WrapError("new_id_arg unexpectedly null.")); + return; + } + const auto& new_id_arg = + std::get(encodable_new_id_arg); + api->OnIdChange( + app_arg, new_id_arg, + [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } } } -EncodableValue FirebaseAppInstallationsHostApi::WrapError(std::string_view error_message) { - return EncodableValue(EncodableList{ - EncodableValue(std::string(error_message)), - EncodableValue("Error"), - EncodableValue() - }); +EncodableValue FirebaseAppInstallationsHostApi::WrapError( + std::string_view error_message) { + return EncodableValue( + EncodableList{EncodableValue(std::string(error_message)), + EncodableValue("Error"), EncodableValue()}); } -EncodableValue FirebaseAppInstallationsHostApi::WrapError(const FlutterError& error) { - return EncodableValue(EncodableList{ - EncodableValue(error.code()), - EncodableValue(error.message()), - error.details() - }); +EncodableValue FirebaseAppInstallationsHostApi::WrapError( + const FlutterError& error) { + return EncodableValue(EncodableList{EncodableValue(error.code()), + EncodableValue(error.message()), + error.details()}); } // Generated class from Pigeon that represents Flutter messages that can be called from C++. diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h index a64ac343c764..28eb2f7a4974 100644 --- a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h @@ -39,7 +39,7 @@ class FlutterError { flutter::EncodableValue details_; }; -template class ErrorOr { +template class ErrorOr { public: ErrorOr(const T& rhs) : v_(rhs) {} ErrorOr(const T&& rhs) : v_(std::move(rhs)) {} From 76ce48be9b2c9cd72b46d2148f6ab4665edee3fd Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 12:19:35 +0000 Subject: [PATCH 13/25] feat: expose pigeons to macos --- .../FirebaseAppInstallationsMessages.g.swift | 1 + 1 file changed, 1 insertion(+) create mode 120000 packages/firebase_app_installations/firebase_app_installations/macos/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift diff --git a/packages/firebase_app_installations/firebase_app_installations/macos/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift b/packages/firebase_app_installations/firebase_app_installations/macos/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift new file mode 120000 index 000000000000..3992a0860aab --- /dev/null +++ b/packages/firebase_app_installations/firebase_app_installations/macos/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift @@ -0,0 +1 @@ +../../../../ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift \ No newline at end of file From 14d2c04420e5f16b8471652d0214b4e5c5a1b8d2 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 12:27:25 +0000 Subject: [PATCH 14/25] format: api --- ...eratedAndroidFirebaseAppInstallations.java | 101 +++++++++++++----- .../firebase_app_installations_messages.g.h | 3 +- .../firebase_app_installations_messages.g.m | 15 +-- .../windows/messages.g.cpp | 9 +- 4 files changed, 86 insertions(+), 42 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java index 87727e920a0b..bd74412b7a62 100644 --- a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java @@ -347,37 +347,60 @@ public interface VoidResult { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface FirebaseAppInstallationsHostApi { - void initializeApp(@NonNull AppInstallationsPigeonFirebaseApp app, @NonNull AppInstallationsPigeonSettings settings, @NonNull VoidResult result); + void initializeApp( + @NonNull AppInstallationsPigeonFirebaseApp app, + @NonNull AppInstallationsPigeonSettings settings, + @NonNull VoidResult result); void delete(@NonNull AppInstallationsPigeonFirebaseApp app, @NonNull VoidResult result); void getId(@NonNull AppInstallationsPigeonFirebaseApp app, @NonNull Result result); - void getToken(@NonNull AppInstallationsPigeonFirebaseApp app, @NonNull Boolean forceRefresh, @NonNull Result result); + void getToken( + @NonNull AppInstallationsPigeonFirebaseApp app, + @NonNull Boolean forceRefresh, + @NonNull Result result); - void onIdChange(@NonNull AppInstallationsPigeonFirebaseApp app, @NonNull String newId, @NonNull VoidResult result); + void onIdChange( + @NonNull AppInstallationsPigeonFirebaseApp app, + @NonNull String newId, + @NonNull VoidResult result); /** The codec used by FirebaseAppInstallationsHostApi. */ static @NonNull MessageCodec getCodec() { return PigeonCodec.INSTANCE; } - /**Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages through the `binaryMessenger`. */ - static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable FirebaseAppInstallationsHostApi api) { + + /** + * Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages through the + * `binaryMessenger`. + */ + static void setUp( + @NonNull BinaryMessenger binaryMessenger, @Nullable FirebaseAppInstallationsHostApi api) { setUp(binaryMessenger, "", api); } - static void setUp(@NonNull BinaryMessenger binaryMessenger, @NonNull String messageChannelSuffix, @Nullable FirebaseAppInstallationsHostApi api) { + + static void setUp( + @NonNull BinaryMessenger binaryMessenger, + @NonNull String messageChannelSuffix, + @Nullable FirebaseAppInstallationsHostApi api) { messageChannelSuffix = messageChannelSuffix.isEmpty() ? "" : "." + messageChannelSuffix; { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp" + messageChannelSuffix, getCodec()); + binaryMessenger, + "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp" + + messageChannelSuffix, + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; - AppInstallationsPigeonFirebaseApp appArg = (AppInstallationsPigeonFirebaseApp) args.get(0); - AppInstallationsPigeonSettings settingsArg = (AppInstallationsPigeonSettings) args.get(1); + AppInstallationsPigeonFirebaseApp appArg = + (AppInstallationsPigeonFirebaseApp) args.get(0); + AppInstallationsPigeonSettings settingsArg = + (AppInstallationsPigeonSettings) args.get(1); VoidResult resultCallback = new VoidResult() { public void success() { @@ -400,13 +423,17 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete" + messageChannelSuffix, getCodec()); + binaryMessenger, + "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete" + + messageChannelSuffix, + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; - AppInstallationsPigeonFirebaseApp appArg = (AppInstallationsPigeonFirebaseApp) args.get(0); + AppInstallationsPigeonFirebaseApp appArg = + (AppInstallationsPigeonFirebaseApp) args.get(0); VoidResult resultCallback = new VoidResult() { public void success() { @@ -429,13 +456,17 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId" + messageChannelSuffix, getCodec()); + binaryMessenger, + "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId" + + messageChannelSuffix, + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; - AppInstallationsPigeonFirebaseApp appArg = (AppInstallationsPigeonFirebaseApp) args.get(0); + AppInstallationsPigeonFirebaseApp appArg = + (AppInstallationsPigeonFirebaseApp) args.get(0); Result resultCallback = new Result() { public void success(String result) { @@ -458,13 +489,17 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken" + messageChannelSuffix, getCodec()); + binaryMessenger, + "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken" + + messageChannelSuffix, + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; - AppInstallationsPigeonFirebaseApp appArg = (AppInstallationsPigeonFirebaseApp) args.get(0); + AppInstallationsPigeonFirebaseApp appArg = + (AppInstallationsPigeonFirebaseApp) args.get(0); Boolean forceRefreshArg = (Boolean) args.get(1); Result resultCallback = new Result() { @@ -488,13 +523,17 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange" + messageChannelSuffix, getCodec()); + binaryMessenger, + "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange" + + messageChannelSuffix, + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { ArrayList wrapped = new ArrayList<>(); ArrayList args = (ArrayList) message; - AppInstallationsPigeonFirebaseApp appArg = (AppInstallationsPigeonFirebaseApp) args.get(0); + AppInstallationsPigeonFirebaseApp appArg = + (AppInstallationsPigeonFirebaseApp) args.get(0); String newIdArg = (String) args.get(1); VoidResult resultCallback = new VoidResult() { @@ -525,32 +564,38 @@ public static class FirebaseAppInstallationsFlutterApi { public FirebaseAppInstallationsFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this(argBinaryMessenger, ""); } - public FirebaseAppInstallationsFlutterApi(@NonNull BinaryMessenger argBinaryMessenger, @NonNull String messageChannelSuffix) { + public FirebaseAppInstallationsFlutterApi( + @NonNull BinaryMessenger argBinaryMessenger, @NonNull String messageChannelSuffix) { this.binaryMessenger = argBinaryMessenger; this.messageChannelSuffix = messageChannelSuffix.isEmpty() ? "" : "." + messageChannelSuffix; } - /** - * Public interface for sending reply. - * The codec used by FirebaseAppInstallationsFlutterApi. - */ + /** Public interface for sending reply. The codec used by FirebaseAppInstallationsFlutterApi. */ static @NonNull MessageCodec getCodec() { return PigeonCodec.INSTANCE; } - public void registerIdTokenListener(@NonNull AppInstallationsPigeonFirebaseApp appArg, @NonNull Result result) { - final String channelName = "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener" + messageChannelSuffix; + public void registerIdTokenListener( + @NonNull AppInstallationsPigeonFirebaseApp appArg, @NonNull Result result) { + final String channelName = + "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener" + + messageChannelSuffix; BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, channelName, getCodec()); + new BasicMessageChannel<>(binaryMessenger, channelName, getCodec()); channel.send( new ArrayList<>(Collections.singletonList(appArg)), channelReply -> { if (channelReply instanceof List) { List listReply = (List) channelReply; if (listReply.size() > 1) { - result.error(new FlutterError((String) listReply.get(0), (String) listReply.get(1), listReply.get(2))); + result.error( + new FlutterError( + (String) listReply.get(0), (String) listReply.get(1), listReply.get(2))); } else if (listReply.get(0) == null) { - result.error(new FlutterError("null-error", "Flutter api returned null value for non-null return value.", "")); + result.error( + new FlutterError( + "null-error", + "Flutter api returned null value for non-null return value.", + "")); } else { @SuppressWarnings("ConstantConditions") String output = (String) listReply.get(0); diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h index 122ba1ac93fe..4904832ecc8d 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h @@ -61,8 +61,7 @@ extern void SetUpFirebaseAppInstallationsHostApi( extern void SetUpFirebaseAppInstallationsHostApiWithSuffix( id binaryMessenger, - NSObject *_Nullable api, - NSString *messageChannelSuffix); + NSObject *_Nullable api, NSString *messageChannelSuffix); @interface FirebaseAppInstallationsFlutterApi : NSObject diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m index ab5fef840d12..07d48b93793c 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m @@ -26,7 +26,10 @@ } static FlutterError *createConnectionError(NSString *channelName) { - return [FlutterError errorWithCode:@"channel-error" message:[NSString stringWithFormat:@"%@/%@/%@", @"Unable to establish connection on channel: '", channelName, @"'."] details:@""]; + return [FlutterError + errorWithCode:@"channel-error" + message:[NSString stringWithFormat:@"%@/%@/%@", @"Unable to establish connection on channel: '", channelName, @"'."] + details:@""]; } static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { @@ -47,11 +50,11 @@ + (nullable AppInstallationsPigeonFirebaseApp *)nullableFromList:(NSArray *) @end @implementation AppInstallationsPigeonSettings -+ (instancetype)makeWithPersistenceEnabled:(BOOL )persistenceEnabled - forceRefreshOnSignIn:(BOOL )forceRefreshOnSignIn - forceRefreshOnTokenChange:(BOOL )forceRefreshOnTokenChange - forceRefreshOnAppUpdate:(BOOL )forceRefreshOnAppUpdate { - AppInstallationsPigeonSettings* pigeonResult = [[AppInstallationsPigeonSettings alloc] init]; ++ (instancetype)makeWithPersistenceEnabled:(BOOL)persistenceEnabled + forceRefreshOnSignIn:(BOOL)forceRefreshOnSignIn + forceRefreshOnTokenChange:(BOOL)forceRefreshOnTokenChange + forceRefreshOnAppUpdate:(BOOL)forceRefreshOnAppUpdate { + AppInstallationsPigeonSettings *pigeonResult = [[AppInstallationsPigeonSettings alloc] init]; pigeonResult.persistenceEnabled = persistenceEnabled; pigeonResult.forceRefreshOnSignIn = forceRefreshOnSignIn; pigeonResult.forceRefreshOnTokenChange = forceRefreshOnTokenChange; diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp index d1f8b9a4c907..e044069a7c2a 100644 --- a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp @@ -34,10 +34,8 @@ FlutterError CreateConnectionError(const std::string channel_name) { // AppInstallationsPigeonSettings AppInstallationsPigeonSettings::AppInstallationsPigeonSettings( - bool persistence_enabled, - bool force_refresh_on_sign_in, - bool force_refresh_on_token_change, - bool force_refresh_on_app_update) + bool persistence_enabled, bool force_refresh_on_sign_in, + bool force_refresh_on_token_change, bool force_refresh_on_app_update) : persistence_enabled_(persistence_enabled), force_refresh_on_sign_in_(force_refresh_on_sign_in), force_refresh_on_token_change_(force_refresh_on_token_change), @@ -90,8 +88,7 @@ EncodableList AppInstallationsPigeonSettings::ToEncodableList() const { return list; } -AppInstallationsPigeonSettings -AppInstallationsPigeonSettings::FromEncodableList( +AppInstallationsPigeonSettings AppInstallationsPigeonSettings::FromEncodableList( const EncodableList& list) { AppInstallationsPigeonSettings decoded( std::get(list[0]), std::get(list[1]), From a7687e2adfad9bc9e73d561fe9d8662b8f5138ff Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 12:37:49 +0000 Subject: [PATCH 15/25] format: ci --- .../GeneratedAndroidFirebaseAppInstallations.java | 4 ++-- .../firebase_app_installations_messages.g.h | 2 -- .../firebase_app_installations_messages.g.m | 10 +++++++--- .../firebase_app_installations/windows/messages.g.cpp | 7 +++---- .../firebase_app_installations/windows/messages.g.h | 3 ++- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java index bd74412b7a62..e822fe077bc2 100644 --- a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java @@ -601,9 +601,9 @@ public void registerIdTokenListener( String output = (String) listReply.get(0); result.success(output); } - } else { + } else { result.error(createConnectionError(channelName)); - } + } }); } } diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h index 4904832ecc8d..98699e2acb70 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h @@ -62,8 +62,6 @@ extern void SetUpFirebaseAppInstallationsHostApi( extern void SetUpFirebaseAppInstallationsHostApiWithSuffix( id binaryMessenger, NSObject *_Nullable api, NSString *messageChannelSuffix); - - @interface FirebaseAppInstallationsFlutterApi : NSObject - (instancetype)initWithBinaryMessenger:(id)binaryMessenger; - (instancetype)initWithBinaryMessenger:(id)binaryMessenger diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m index 07d48b93793c..74ebf834b143 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m @@ -28,7 +28,9 @@ static FlutterError *createConnectionError(NSString *channelName) { return [FlutterError errorWithCode:@"channel-error" - message:[NSString stringWithFormat:@"%@/%@/%@", @"Unable to establish connection on channel: '", channelName, @"'."] + message:[NSString stringWithFormat:@"%@/%@/%@", + @"Unable to establish connection on channel: '", + channelName, @"'."] details:@""]; } @@ -84,12 +86,14 @@ + (nullable AppInstallationsPigeonSettings *)nullableFromList:(NSArray *)lis @implementation AppInstallationsPigeonFirebaseApp + (instancetype)makeWithAppName:(NSString *)appName { - AppInstallationsPigeonFirebaseApp* pigeonResult = [[AppInstallationsPigeonFirebaseApp alloc] init]; + AppInstallationsPigeonFirebaseApp *pigeonResult = + [[AppInstallationsPigeonFirebaseApp alloc] init]; pigeonResult.appName = appName; return pigeonResult; } + (AppInstallationsPigeonFirebaseApp *)fromList:(NSArray *)list { - AppInstallationsPigeonFirebaseApp *pigeonResult = [[AppInstallationsPigeonFirebaseApp alloc] init]; + AppInstallationsPigeonFirebaseApp *pigeonResult = + [[AppInstallationsPigeonFirebaseApp alloc] init]; pigeonResult.appName = GetNullableObjectAtIndex(list, 0); return pigeonResult; } diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp index e044069a7c2a..e0196615ad02 100644 --- a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp @@ -88,8 +88,8 @@ EncodableList AppInstallationsPigeonSettings::ToEncodableList() const { return list; } -AppInstallationsPigeonSettings AppInstallationsPigeonSettings::FromEncodableList( - const EncodableList& list) { +AppInstallationsPigeonSettings +AppInstallationsPigeonSettings::FromEncodableList(const EncodableList& list) { AppInstallationsPigeonSettings decoded( std::get(list[0]), std::get(list[1]), std::get(list[2]), std::get(list[3])); @@ -148,8 +148,7 @@ EncodableValue PigeonInternalCodecSerializer::ReadValueOfType( } void PigeonInternalCodecSerializer::WriteValue( - const EncodableValue& value, - flutter::ByteStreamWriter* stream) const { + const EncodableValue& value, flutter::ByteStreamWriter* stream) const { if (const CustomEncodableValue* custom_value = std::get_if(&value)) { if (custom_value->type() == typeid(AppInstallationsPigeonSettings)) { diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h index 28eb2f7a4974..87a0bb2df28f 100644 --- a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h @@ -39,7 +39,8 @@ class FlutterError { flutter::EncodableValue details_; }; -template class ErrorOr { +template +class ErrorOr { public: ErrorOr(const T& rhs) : v_(rhs) {} ErrorOr(const T&& rhs) : v_(std::move(rhs)) {} From c488806941bbf957f050cc61371d25619b340cda Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 12:40:02 +0000 Subject: [PATCH 16/25] chore: ignore objc for swift integ for now --- .../ios/firebase_app_installations/Package.swift | 8 ++++++++ .../macos/firebase_app_installations/Package.swift | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Package.swift b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Package.swift index 5f11fa8d659a..41e6d40eedbc 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Package.swift +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Package.swift @@ -98,6 +98,14 @@ let package = Package( // Wrapper dependency .product(name: "firebase-core-shared", package: "flutterfire"), ], + // Exclude Objective-C sources that are used only for CocoaPods integration. + // The Swift Package Manager target is pure Swift and uses the Swift Pigeon + // types defined in FirebaseAppInstallationsMessages.g.swift instead. + exclude: [ + "Sources/firebase_app_installations/firebase_app_installations.h", + "Sources/firebase_app_installations/firebase_app_installations_messages.g.h", + "Sources/firebase_app_installations/firebase_app_installations_messages.g.m", + ], resources: [ .process("Resources"), ] diff --git a/packages/firebase_app_installations/firebase_app_installations/macos/firebase_app_installations/Package.swift b/packages/firebase_app_installations/firebase_app_installations/macos/firebase_app_installations/Package.swift index 751edd05f9c4..75ebb249f6b4 100644 --- a/packages/firebase_app_installations/firebase_app_installations/macos/firebase_app_installations/Package.swift +++ b/packages/firebase_app_installations/firebase_app_installations/macos/firebase_app_installations/Package.swift @@ -100,6 +100,14 @@ let package = Package( // Wrapper dependency .product(name: "firebase-core-shared", package: "flutterfire"), ], + // Exclude Objective-C sources that are used only for CocoaPods/iOS integration. + // The macOS Swift Package target is pure Swift and uses the Swift Pigeon + // types defined in FirebaseAppInstallationsMessages.g.swift instead. + exclude: [ + "Sources/firebase_app_installations/firebase_app_installations.h", + "Sources/firebase_app_installations/firebase_app_installations_messages.g.h", + "Sources/firebase_app_installations/firebase_app_installations_messages.g.m", + ], resources: [ .process("Resources"), ] From 259ab297781744bdff911698ee2220c28977c2c0 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 12:47:44 +0000 Subject: [PATCH 17/25] chore: format --- ...eratedAndroidFirebaseAppInstallations.java | 1 - .../firebase_app_installations_messages.g.m | 7 +- .../windows/messages.g.cpp | 228 +++++++++--------- 3 files changed, 118 insertions(+), 118 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java index e822fe077bc2..aab89abdb14f 100644 --- a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java @@ -319,7 +319,6 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { } } - /** Asynchronous error handling return type for non-nullable API method returns. */ public interface Result { /** Success case callback method for handling returns. */ diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m index 74ebf834b143..ec08752da1e6 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m @@ -112,9 +112,9 @@ @interface nullFirebaseAppInstallationsMessagesPigeonCodecReader : FlutterStanda @implementation nullFirebaseAppInstallationsMessagesPigeonCodecReader - (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 129: + case 129: return [AppInstallationsPigeonSettings fromList:[self readValue]]; - case 130: + case 130: return [AppInstallationsPigeonFirebaseApp fromList:[self readValue]]; default: return [super readValueOfType:type]; @@ -153,7 +153,8 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static FlutterStandardMessageCodec *sSharedObject = nil; static dispatch_once_t sPred = 0; dispatch_once(&sPred, ^{ - nullFirebaseAppInstallationsMessagesPigeonCodecReaderWriter *readerWriter = [[nullFirebaseAppInstallationsMessagesPigeonCodecReaderWriter alloc] init]; + nullFirebaseAppInstallationsMessagesPigeonCodecReaderWriter *readerWriter = + [[nullFirebaseAppInstallationsMessagesPigeonCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp index e0196615ad02..3900cc0fff6a 100644 --- a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp @@ -36,10 +36,10 @@ FlutterError CreateConnectionError(const std::string channel_name) { AppInstallationsPigeonSettings::AppInstallationsPigeonSettings( bool persistence_enabled, bool force_refresh_on_sign_in, bool force_refresh_on_token_change, bool force_refresh_on_app_update) - : persistence_enabled_(persistence_enabled), - force_refresh_on_sign_in_(force_refresh_on_sign_in), - force_refresh_on_token_change_(force_refresh_on_token_change), - force_refresh_on_app_update_(force_refresh_on_app_update) {} + : persistence_enabled_(persistence_enabled), + force_refresh_on_sign_in_(force_refresh_on_sign_in), + force_refresh_on_token_change_(force_refresh_on_token_change), + force_refresh_on_app_update_(force_refresh_on_app_update) {} bool AppInstallationsPigeonSettings::persistence_enabled() const { return persistence_enabled_; @@ -100,7 +100,7 @@ AppInstallationsPigeonSettings::FromEncodableList(const EncodableList& list) { AppInstallationsPigeonFirebaseApp::AppInstallationsPigeonFirebaseApp( const std::string& app_name) - : app_name_(app_name) {} + : app_name_(app_name) {} const std::string& AppInstallationsPigeonFirebaseApp::app_name() const { return app_name_; @@ -136,12 +136,12 @@ EncodableValue PigeonInternalCodecSerializer::ReadValueOfType( return CustomEncodableValue( AppInstallationsPigeonSettings::FromEncodableList( std::get(ReadValue(stream)))); - } + } case 130: { return CustomEncodableValue( AppInstallationsPigeonFirebaseApp::FromEncodableList( std::get(ReadValue(stream)))); - } + } default: return flutter::StandardCodecSerializer::ReadValueOfType(type, stream); } @@ -182,15 +182,15 @@ FirebaseAppInstallationsHostApi::GetCodec() { // Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages // through the `binary_messenger`. void FirebaseAppInstallationsHostApi::SetUp( - flutter::BinaryMessenger* binary_messenger, - FirebaseAppInstallationsHostApi* api) { + flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api) { FirebaseAppInstallationsHostApi::SetUp(binary_messenger, api, ""); } void FirebaseAppInstallationsHostApi::SetUp( - flutter::BinaryMessenger* binary_messenger, - FirebaseAppInstallationsHostApi* api, - const std::string& message_channel_suffix) { + flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api, + const std::string& message_channel_suffix) { const std::string prepended_suffix = message_channel_suffix.length() > 0 ? std::string(".") + message_channel_suffix @@ -206,39 +206,39 @@ void FirebaseAppInstallationsHostApi::SetUp( channel.SetMessageHandler( [api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } const auto& app_arg = std::any_cast( std::get(encodable_app_arg)); - const auto& encodable_settings_arg = args.at(1); - if (encodable_settings_arg.IsNull()) { - reply(WrapError("settings_arg unexpectedly null.")); - return; - } + const auto& encodable_settings_arg = args.at(1); + if (encodable_settings_arg.IsNull()) { + reply(WrapError("settings_arg unexpectedly null.")); + return; + } const auto& settings_arg = std::any_cast( std::get(encodable_settings_arg)); api->InitializeApp( app_arg, settings_arg, [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + if (output.has_value()) { + reply(WrapError(output.value())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } @@ -254,30 +254,30 @@ void FirebaseAppInstallationsHostApi::SetUp( channel.SetMessageHandler( [api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } const auto& app_arg = std::any_cast( std::get(encodable_app_arg)); api->Delete(app_arg, [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + if (output.has_value()) { + reply(WrapError(output.value())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } @@ -293,30 +293,30 @@ void FirebaseAppInstallationsHostApi::SetUp( channel.SetMessageHandler( [api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } const auto& app_arg = std::any_cast( std::get(encodable_app_arg)); - api->GetId(app_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; + api->GetId(app_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; wrapped.push_back( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } @@ -332,39 +332,39 @@ void FirebaseAppInstallationsHostApi::SetUp( channel.SetMessageHandler( [api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } const auto& app_arg = std::any_cast( std::get(encodable_app_arg)); - const auto& encodable_force_refresh_arg = args.at(1); - if (encodable_force_refresh_arg.IsNull()) { - reply(WrapError("force_refresh_arg unexpectedly null.")); - return; - } + const auto& encodable_force_refresh_arg = args.at(1); + if (encodable_force_refresh_arg.IsNull()) { + reply(WrapError("force_refresh_arg unexpectedly null.")); + return; + } const auto& force_refresh_arg = std::get(encodable_force_refresh_arg); api->GetToken( app_arg, force_refresh_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; wrapped.push_back(EncodableValue( std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } @@ -380,38 +380,38 @@ void FirebaseAppInstallationsHostApi::SetUp( channel.SetMessageHandler( [api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } const auto& app_arg = std::any_cast( std::get(encodable_app_arg)); - const auto& encodable_new_id_arg = args.at(1); - if (encodable_new_id_arg.IsNull()) { - reply(WrapError("new_id_arg unexpectedly null.")); - return; - } + const auto& encodable_new_id_arg = args.at(1); + if (encodable_new_id_arg.IsNull()) { + reply(WrapError("new_id_arg unexpectedly null.")); + return; + } const auto& new_id_arg = std::get(encodable_new_id_arg); api->OnIdChange( app_arg, new_id_arg, [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + if (output.has_value()) { + reply(WrapError(output.value())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } @@ -428,7 +428,7 @@ EncodableValue FirebaseAppInstallationsHostApi::WrapError( EncodableValue FirebaseAppInstallationsHostApi::WrapError( const FlutterError& error) { return EncodableValue(EncodableList{EncodableValue(error.code()), - EncodableValue(error.message()), + EncodableValue(error.message()), error.details()}); } From b8fbdc30a8905050cf18b93695b4dfd17b552b81 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 13:01:26 +0000 Subject: [PATCH 18/25] fix: imports android generated api --- .../installations/GeneratedAndroidFirebaseAppInstallations.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java index aab89abdb14f..c32954da6b3e 100644 --- a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java @@ -21,6 +21,8 @@ import java.lang.annotation.Target; import java.nio.ByteBuffer; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.Objects; /** Generated class from Pigeon. */ From d2bfafd244e76458106331442bf05ebc5520789f Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 13:11:09 +0000 Subject: [PATCH 19/25] chore: melos run format --- ...eratedAndroidFirebaseAppInstallations.java | 2 + .../firebase_app_installations_messages.g.m | 151 ++++---- .../windows/messages.g.cpp | 332 +++++++++--------- .../windows/messages.g.h | 104 +++--- 4 files changed, 311 insertions(+), 278 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java index c32954da6b3e..1a8a0e3f83da 100644 --- a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java @@ -565,6 +565,7 @@ public static class FirebaseAppInstallationsFlutterApi { public FirebaseAppInstallationsFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this(argBinaryMessenger, ""); } + public FirebaseAppInstallationsFlutterApi( @NonNull BinaryMessenger argBinaryMessenger, @NonNull String messageChannelSuffix) { this.binaryMessenger = argBinaryMessenger; @@ -575,6 +576,7 @@ public FirebaseAppInstallationsFlutterApi( static @NonNull MessageCodec getCodec() { return PigeonCodec.INSTANCE; } + public void registerIdTokenListener( @NonNull AppInstallationsPigeonFirebaseApp appArg, @NonNull Result result) { final String channelName = diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m index ec08752da1e6..2ffd4f9f7bad 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m @@ -171,113 +171,136 @@ void SetUpFirebaseAppInstallationsHostApiWithSuffix(id b ? [NSString stringWithFormat:@".%@", messageChannelSuffix] : @""; { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat: - @"%@%@", - @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.initializeApp", - messageChannelSuffix] - binaryMessenger:binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat: + @"%@%@", + @"dev.flutter.pigeon.firebase_app_installations_platform_" + @"interface.FirebaseAppInstallationsHostApi.initializeApp", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(initializeAppApp:settings:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(initializeAppApp:settings:completion:)", api); + NSCAssert([api respondsToSelector:@selector(initializeAppApp:settings:completion:)], + @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to " + @"@selector(initializeAppApp:settings:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; AppInstallationsPigeonFirebaseApp *arg_app = GetNullableObjectAtIndex(args, 0); AppInstallationsPigeonSettings *arg_settings = GetNullableObjectAtIndex(args, 1); - [api initializeAppApp:arg_app settings:arg_settings completion:^(FlutterError *_Nullable error) { - callback(wrapResult(nil, error)); - }]; + [api initializeAppApp:arg_app + settings:arg_settings + completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; }]; } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat: - @"%@%@", - @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.delete", - messageChannelSuffix] - binaryMessenger:binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + [NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.firebase_app_installations_platform_" + @"interface.FirebaseAppInstallationsHostApi.delete", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(deleteApp:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(deleteApp:completion:)", api); + NSCAssert([api respondsToSelector:@selector(deleteApp:completion:)], + @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to " + @"@selector(deleteApp:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; AppInstallationsPigeonFirebaseApp *arg_app = GetNullableObjectAtIndex(args, 0); - [api deleteApp:arg_app completion:^(FlutterError *_Nullable error) { - callback(wrapResult(nil, error)); - }]; + [api deleteApp:arg_app + completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; }]; } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat: - @"%@%@", - @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getId", - messageChannelSuffix] - binaryMessenger:binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + [NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.firebase_app_installations_platform_" + @"interface.FirebaseAppInstallationsHostApi.getId", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(getIdApp:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(getIdApp:completion:)", api); + NSCAssert([api respondsToSelector:@selector(getIdApp:completion:)], + @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to " + @"@selector(getIdApp:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; AppInstallationsPigeonFirebaseApp *arg_app = GetNullableObjectAtIndex(args, 0); - [api getIdApp:arg_app completion:^(NSString *_Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api getIdApp:arg_app + completion:^(NSString *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat: - @"%@%@", - @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.getToken", - messageChannelSuffix] - binaryMessenger:binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + [NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.firebase_app_installations_platform_" + @"interface.FirebaseAppInstallationsHostApi.getToken", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(getTokenApp:forceRefresh:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(getTokenApp:forceRefresh:completion:)", api); + NSCAssert([api respondsToSelector:@selector(getTokenApp:forceRefresh:completion:)], + @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to " + @"@selector(getTokenApp:forceRefresh:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; AppInstallationsPigeonFirebaseApp *arg_app = GetNullableObjectAtIndex(args, 0); BOOL arg_forceRefresh = [GetNullableObjectAtIndex(args, 1) boolValue]; - [api getTokenApp:arg_app forceRefresh:arg_forceRefresh completion:^(NSString *_Nullable output, FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api getTokenApp:arg_app + forceRefresh:arg_forceRefresh + completion:^(NSString *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat: - @"%@%@", - @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.onIdChange", - messageChannelSuffix] - binaryMessenger:binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName: + [NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.firebase_app_installations_platform_" + @"interface.FirebaseAppInstallationsHostApi.onIdChange", + messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(onIdChangeApp:newId:completion:)], @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to @selector(onIdChangeApp:newId:completion:)", api); + NSCAssert([api respondsToSelector:@selector(onIdChangeApp:newId:completion:)], + @"FirebaseAppInstallationsHostApi api (%@) doesn't respond to " + @"@selector(onIdChangeApp:newId:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; AppInstallationsPigeonFirebaseApp *arg_app = GetNullableObjectAtIndex(args, 0); NSString *arg_newId = GetNullableObjectAtIndex(args, 1); - [api onIdChangeApp:arg_app newId:arg_newId completion:^(FlutterError *_Nullable error) { - callback(wrapResult(nil, error)); - }]; + [api onIdChangeApp:arg_app + newId:arg_newId + completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; }]; } else { [channel setMessageHandler:nil]; @@ -310,12 +333,13 @@ - (void)registerIdTokenListenerApp:(AppInstallationsPigeonFirebaseApp *)arg_app (void (^)(NSString *_Nullable, FlutterError *_Nullable))completion { NSString *channelName = [NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener", + @"dev.flutter.pigeon.firebase_app_installations_platform_interface." + @"FirebaseAppInstallationsFlutterApi.registerIdTokenListener", _messageChannelSuffix]; FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel messageChannelWithName:channelName - binaryMessenger:self.binaryMessenger - codec:nullGetFirebaseAppInstallationsMessagesCodec()]; + binaryMessenger:self.binaryMessenger + codec:nullGetFirebaseAppInstallationsMessagesCodec()]; [channel sendMessage:@[ arg_app ?: [NSNull null] ] reply:^(NSArray *reply) { if (reply != nil) { @@ -333,4 +357,3 @@ - (void)registerIdTokenListenerApp:(AppInstallationsPigeonFirebaseApp *)arg_app }]; } @end - diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp index 3900cc0fff6a..5fe216d496af 100644 --- a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp @@ -36,10 +36,10 @@ FlutterError CreateConnectionError(const std::string channel_name) { AppInstallationsPigeonSettings::AppInstallationsPigeonSettings( bool persistence_enabled, bool force_refresh_on_sign_in, bool force_refresh_on_token_change, bool force_refresh_on_app_update) - : persistence_enabled_(persistence_enabled), - force_refresh_on_sign_in_(force_refresh_on_sign_in), - force_refresh_on_token_change_(force_refresh_on_token_change), - force_refresh_on_app_update_(force_refresh_on_app_update) {} + : persistence_enabled_(persistence_enabled), + force_refresh_on_sign_in_(force_refresh_on_sign_in), + force_refresh_on_token_change_(force_refresh_on_token_change), + force_refresh_on_app_update_(force_refresh_on_app_update) {} bool AppInstallationsPigeonSettings::persistence_enabled() const { return persistence_enabled_; @@ -49,7 +49,6 @@ void AppInstallationsPigeonSettings::set_persistence_enabled(bool value_arg) { persistence_enabled_ = value_arg; } - bool AppInstallationsPigeonSettings::force_refresh_on_sign_in() const { return force_refresh_on_sign_in_; } @@ -77,7 +76,6 @@ void AppInstallationsPigeonSettings::set_force_refresh_on_app_update( force_refresh_on_app_update_ = value_arg; } - EncodableList AppInstallationsPigeonSettings::ToEncodableList() const { EncodableList list; list.reserve(4); @@ -91,8 +89,8 @@ EncodableList AppInstallationsPigeonSettings::ToEncodableList() const { AppInstallationsPigeonSettings AppInstallationsPigeonSettings::FromEncodableList(const EncodableList& list) { AppInstallationsPigeonSettings decoded( - std::get(list[0]), std::get(list[1]), - std::get(list[2]), std::get(list[3])); + std::get(list[0]), std::get(list[1]), std::get(list[2]), + std::get(list[3])); return decoded; } @@ -100,7 +98,7 @@ AppInstallationsPigeonSettings::FromEncodableList(const EncodableList& list) { AppInstallationsPigeonFirebaseApp::AppInstallationsPigeonFirebaseApp( const std::string& app_name) - : app_name_(app_name) {} + : app_name_(app_name) {} const std::string& AppInstallationsPigeonFirebaseApp::app_name() const { return app_name_; @@ -111,7 +109,6 @@ void AppInstallationsPigeonFirebaseApp::set_app_name( app_name_ = value_arg; } - EncodableList AppInstallationsPigeonFirebaseApp::ToEncodableList() const { EncodableList list; list.reserve(1); @@ -126,7 +123,6 @@ AppInstallationsPigeonFirebaseApp::FromEncodableList( return decoded; } - PigeonInternalCodecSerializer::PigeonInternalCodecSerializer() {} EncodableValue PigeonInternalCodecSerializer::ReadValueOfType( @@ -136,15 +132,15 @@ EncodableValue PigeonInternalCodecSerializer::ReadValueOfType( return CustomEncodableValue( AppInstallationsPigeonSettings::FromEncodableList( std::get(ReadValue(stream)))); - } + } case 130: { return CustomEncodableValue( AppInstallationsPigeonFirebaseApp::FromEncodableList( std::get(ReadValue(stream)))); - } + } default: return flutter::StandardCodecSerializer::ReadValueOfType(type, stream); - } + } } void PigeonInternalCodecSerializer::WriteValue( @@ -182,15 +178,15 @@ FirebaseAppInstallationsHostApi::GetCodec() { // Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages // through the `binary_messenger`. void FirebaseAppInstallationsHostApi::SetUp( - flutter::BinaryMessenger* binary_messenger, - FirebaseAppInstallationsHostApi* api) { + flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api) { FirebaseAppInstallationsHostApi::SetUp(binary_messenger, api, ""); } void FirebaseAppInstallationsHostApi::SetUp( - flutter::BinaryMessenger* binary_messenger, - FirebaseAppInstallationsHostApi* api, - const std::string& message_channel_suffix) { + flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api, + const std::string& message_channel_suffix) { const std::string prepended_suffix = message_channel_suffix.length() > 0 ? std::string(".") + message_channel_suffix @@ -206,39 +202,38 @@ void FirebaseAppInstallationsHostApi::SetUp( channel.SetMessageHandler( [api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } const auto& app_arg = std::any_cast( std::get(encodable_app_arg)); - const auto& encodable_settings_arg = args.at(1); - if (encodable_settings_arg.IsNull()) { - reply(WrapError("settings_arg unexpectedly null.")); - return; - } + const auto& encodable_settings_arg = args.at(1); + if (encodable_settings_arg.IsNull()) { + reply(WrapError("settings_arg unexpectedly null.")); + return; + } const auto& settings_arg = std::any_cast( std::get(encodable_settings_arg)); - api->InitializeApp( - app_arg, settings_arg, - [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; + api->InitializeApp(app_arg, settings_arg, + [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } @@ -254,30 +249,30 @@ void FirebaseAppInstallationsHostApi::SetUp( channel.SetMessageHandler( [api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } const auto& app_arg = std::any_cast( std::get(encodable_app_arg)); api->Delete(app_arg, [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } @@ -293,30 +288,30 @@ void FirebaseAppInstallationsHostApi::SetUp( channel.SetMessageHandler( [api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } const auto& app_arg = std::any_cast( std::get(encodable_app_arg)); - api->GetId(app_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; + api->GetId(app_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; wrapped.push_back( EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } @@ -332,39 +327,38 @@ void FirebaseAppInstallationsHostApi::SetUp( channel.SetMessageHandler( [api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } const auto& app_arg = std::any_cast( std::get(encodable_app_arg)); - const auto& encodable_force_refresh_arg = args.at(1); - if (encodable_force_refresh_arg.IsNull()) { - reply(WrapError("force_refresh_arg unexpectedly null.")); - return; - } + const auto& encodable_force_refresh_arg = args.at(1); + if (encodable_force_refresh_arg.IsNull()) { + reply(WrapError("force_refresh_arg unexpectedly null.")); + return; + } const auto& force_refresh_arg = std::get(encodable_force_refresh_arg); - api->GetToken( - app_arg, force_refresh_arg, - [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; + api->GetToken(app_arg, force_refresh_arg, + [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue( + std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(EncodableValue( - std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } @@ -380,38 +374,37 @@ void FirebaseAppInstallationsHostApi::SetUp( channel.SetMessageHandler( [api](const EncodableValue& message, const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_app_arg = args.at(0); - if (encodable_app_arg.IsNull()) { - reply(WrapError("app_arg unexpectedly null.")); - return; - } + try { + const auto& args = std::get(message); + const auto& encodable_app_arg = args.at(0); + if (encodable_app_arg.IsNull()) { + reply(WrapError("app_arg unexpectedly null.")); + return; + } const auto& app_arg = std::any_cast( std::get(encodable_app_arg)); - const auto& encodable_new_id_arg = args.at(1); - if (encodable_new_id_arg.IsNull()) { - reply(WrapError("new_id_arg unexpectedly null.")); - return; - } + const auto& encodable_new_id_arg = args.at(1); + if (encodable_new_id_arg.IsNull()) { + reply(WrapError("new_id_arg unexpectedly null.")); + return; + } const auto& new_id_arg = std::get(encodable_new_id_arg); - api->OnIdChange( - app_arg, new_id_arg, - [reply](std::optional&& output) { - if (output.has_value()) { - reply(WrapError(output.value())); - return; + api->OnIdChange(app_arg, new_id_arg, + [reply](std::optional&& output) { + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(EncodableValue()); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } @@ -428,49 +421,66 @@ EncodableValue FirebaseAppInstallationsHostApi::WrapError( EncodableValue FirebaseAppInstallationsHostApi::WrapError( const FlutterError& error) { return EncodableValue(EncodableList{EncodableValue(error.code()), - EncodableValue(error.message()), + EncodableValue(error.message()), error.details()}); } -// Generated class from Pigeon that represents Flutter messages that can be called from C++. -FirebaseAppInstallationsFlutterApi::FirebaseAppInstallationsFlutterApi(flutter::BinaryMessenger* binary_messenger) - : binary_messenger_(binary_messenger), - message_channel_suffix_("") {} +// Generated class from Pigeon that represents Flutter messages that can be +// called from C++. +FirebaseAppInstallationsFlutterApi::FirebaseAppInstallationsFlutterApi( + flutter::BinaryMessenger* binary_messenger) + : binary_messenger_(binary_messenger), message_channel_suffix_("") {} FirebaseAppInstallationsFlutterApi::FirebaseAppInstallationsFlutterApi( - flutter::BinaryMessenger* binary_messenger, - const std::string& message_channel_suffix) - : binary_messenger_(binary_messenger), - message_channel_suffix_(message_channel_suffix.length() > 0 ? std::string(".") + message_channel_suffix : "") {} + flutter::BinaryMessenger* binary_messenger, + const std::string& message_channel_suffix) + : binary_messenger_(binary_messenger), + message_channel_suffix_(message_channel_suffix.length() > 0 + ? std::string(".") + message_channel_suffix + : "") {} -const flutter::StandardMessageCodec& FirebaseAppInstallationsFlutterApi::GetCodec() { - return flutter::StandardMessageCodec::GetInstance(&PigeonInternalCodecSerializer::GetInstance()); +const flutter::StandardMessageCodec& +FirebaseAppInstallationsFlutterApi::GetCodec() { + return flutter::StandardMessageCodec::GetInstance( + &PigeonInternalCodecSerializer::GetInstance()); } void FirebaseAppInstallationsFlutterApi::RegisterIdTokenListener( - const AppInstallationsPigeonFirebaseApp& app_arg, - std::function&& on_success, - std::function&& on_error) { - const std::string channel_name = "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsFlutterApi.registerIdTokenListener" + message_channel_suffix_; + const AppInstallationsPigeonFirebaseApp& app_arg, + std::function&& on_success, + std::function&& on_error) { + const std::string channel_name = + "dev.flutter.pigeon.firebase_app_installations_platform_interface." + "FirebaseAppInstallationsFlutterApi.registerIdTokenListener" + + message_channel_suffix_; BasicMessageChannel<> channel(binary_messenger_, channel_name, &GetCodec()); EncodableValue encoded_api_arguments = EncodableValue(EncodableList{ - CustomEncodableValue(app_arg), - }); - channel.Send(encoded_api_arguments, [channel_name, on_success = std::move(on_success), on_error = std::move(on_error)](const uint8_t* reply, size_t reply_size) { - std::unique_ptr response = GetCodec().DecodeMessage(reply, reply_size); - const auto& encodable_return_value = *response; - const auto* list_return_value = std::get_if(&encodable_return_value); - if (list_return_value) { - if (list_return_value->size() > 1) { - on_error(FlutterError(std::get(list_return_value->at(0)), std::get(list_return_value->at(1)), list_return_value->at(2))); - } else { - const auto& return_value = std::get(list_return_value->at(0)); - on_success(return_value); - } - } else { - on_error(CreateConnectionError(channel_name)); - } + CustomEncodableValue(app_arg), }); + channel.Send( + encoded_api_arguments, [channel_name, on_success = std::move(on_success), + on_error = std::move(on_error)]( + const uint8_t* reply, size_t reply_size) { + std::unique_ptr response = + GetCodec().DecodeMessage(reply, reply_size); + const auto& encodable_return_value = *response; + const auto* list_return_value = + std::get_if(&encodable_return_value); + if (list_return_value) { + if (list_return_value->size() > 1) { + on_error( + FlutterError(std::get(list_return_value->at(0)), + std::get(list_return_value->at(1)), + list_return_value->at(2))); + } else { + const auto& return_value = + std::get(list_return_value->at(0)); + on_success(return_value); + } + } else { + on_error(CreateConnectionError(channel_name)); + } + }); } } // namespace firebase_app_installations_windows diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h index 87a0bb2df28f..2a82b019b80d 100644 --- a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h @@ -17,17 +17,16 @@ namespace firebase_app_installations_windows { - // Generated class from Pigeon. class FlutterError { public: - explicit FlutterError(const std::string& code) - : code_(code) {} + explicit FlutterError(const std::string& code) : code_(code) {} explicit FlutterError(const std::string& code, const std::string& message) - : code_(code), message_(message) {} - explicit FlutterError(const std::string& code, const std::string& message, const flutter::EncodableValue& details) - : code_(code), message_(message), details_(details) {} + : code_(code), message_(message) {} + explicit FlutterError(const std::string& code, const std::string& message, + const flutter::EncodableValue& details) + : code_(code), message_(message), details_(details) {} const std::string& code() const { return code_; } const std::string& message() const { return message_; } @@ -60,17 +59,14 @@ class ErrorOr { std::variant v_; }; - - // Generated class from Pigeon that represents data sent in messages. class AppInstallationsPigeonSettings { public: // Constructs an object setting all fields. - explicit AppInstallationsPigeonSettings( - bool persistence_enabled, - bool force_refresh_on_sign_in, - bool force_refresh_on_token_change, - bool force_refresh_on_app_update); + explicit AppInstallationsPigeonSettings(bool persistence_enabled, + bool force_refresh_on_sign_in, + bool force_refresh_on_token_change, + bool force_refresh_on_app_update); bool persistence_enabled() const; void set_persistence_enabled(bool value_arg); @@ -85,7 +81,8 @@ class AppInstallationsPigeonSettings { void set_force_refresh_on_app_update(bool value_arg); private: - static AppInstallationsPigeonSettings FromEncodableList(const flutter::EncodableList& list); + static AppInstallationsPigeonSettings FromEncodableList( + const flutter::EncodableList& list); flutter::EncodableList ToEncodableList() const; friend class FirebaseAppInstallationsHostApi; friend class FirebaseAppInstallationsFlutterApi; @@ -96,7 +93,6 @@ class AppInstallationsPigeonSettings { bool force_refresh_on_app_update_; }; - // Generated class from Pigeon that represents data sent in messages. class AppInstallationsPigeonFirebaseApp { public: @@ -107,7 +103,8 @@ class AppInstallationsPigeonFirebaseApp { void set_app_name(std::string_view value_arg); private: - static AppInstallationsPigeonFirebaseApp FromEncodableList(const flutter::EncodableList& list); + static AppInstallationsPigeonFirebaseApp FromEncodableList( + const flutter::EncodableList& list); flutter::EncodableList ToEncodableList() const; friend class FirebaseAppInstallationsHostApi; friend class FirebaseAppInstallationsFlutterApi; @@ -115,7 +112,6 @@ class AppInstallationsPigeonFirebaseApp { std::string app_name_; }; - class PigeonInternalCodecSerializer : public flutter::StandardCodecSerializer { public: PigeonInternalCodecSerializer(); @@ -124,67 +120,69 @@ class PigeonInternalCodecSerializer : public flutter::StandardCodecSerializer { return sInstance; } - void WriteValue( - const flutter::EncodableValue& value, - flutter::ByteStreamWriter* stream) const override; + void WriteValue(const flutter::EncodableValue& value, + flutter::ByteStreamWriter* stream) const override; + protected: flutter::EncodableValue ReadValueOfType( - uint8_t type, - flutter::ByteStreamReader* stream) const override; + uint8_t type, flutter::ByteStreamReader* stream) const override; }; -// Generated interface from Pigeon that represents a handler of messages from Flutter. +// Generated interface from Pigeon that represents a handler of messages from +// Flutter. class FirebaseAppInstallationsHostApi { public: - FirebaseAppInstallationsHostApi(const FirebaseAppInstallationsHostApi&) = delete; - FirebaseAppInstallationsHostApi& operator=(const FirebaseAppInstallationsHostApi&) = delete; + FirebaseAppInstallationsHostApi(const FirebaseAppInstallationsHostApi&) = + delete; + FirebaseAppInstallationsHostApi& operator=( + const FirebaseAppInstallationsHostApi&) = delete; virtual ~FirebaseAppInstallationsHostApi() {} virtual void InitializeApp( - const AppInstallationsPigeonFirebaseApp& app, - const AppInstallationsPigeonSettings& settings, - std::function reply)> result) = 0; + const AppInstallationsPigeonFirebaseApp& app, + const AppInstallationsPigeonSettings& settings, + std::function reply)> result) = 0; virtual void Delete( - const AppInstallationsPigeonFirebaseApp& app, - std::function reply)> result) = 0; + const AppInstallationsPigeonFirebaseApp& app, + std::function reply)> result) = 0; virtual void GetId( - const AppInstallationsPigeonFirebaseApp& app, - std::function reply)> result) = 0; + const AppInstallationsPigeonFirebaseApp& app, + std::function reply)> result) = 0; virtual void GetToken( - const AppInstallationsPigeonFirebaseApp& app, - bool force_refresh, - std::function reply)> result) = 0; + const AppInstallationsPigeonFirebaseApp& app, bool force_refresh, + std::function reply)> result) = 0; virtual void OnIdChange( - const AppInstallationsPigeonFirebaseApp& app, - const std::string& new_id, - std::function reply)> result) = 0; + const AppInstallationsPigeonFirebaseApp& app, const std::string& new_id, + std::function reply)> result) = 0; // The codec used by FirebaseAppInstallationsHostApi. static const flutter::StandardMessageCodec& GetCodec(); - // Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages through the `binary_messenger`. - static void SetUp( - flutter::BinaryMessenger* binary_messenger, - FirebaseAppInstallationsHostApi* api); - static void SetUp( - flutter::BinaryMessenger* binary_messenger, - FirebaseAppInstallationsHostApi* api, - const std::string& message_channel_suffix); + // Sets up an instance of `FirebaseAppInstallationsHostApi` to handle messages + // through the `binary_messenger`. + static void SetUp(flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api); + static void SetUp(flutter::BinaryMessenger* binary_messenger, + FirebaseAppInstallationsHostApi* api, + const std::string& message_channel_suffix); static flutter::EncodableValue WrapError(std::string_view error_message); static flutter::EncodableValue WrapError(const FlutterError& error); + protected: FirebaseAppInstallationsHostApi() = default; }; -// Generated class from Pigeon that represents Flutter messages that can be called from C++. +// Generated class from Pigeon that represents Flutter messages that can be +// called from C++. class FirebaseAppInstallationsFlutterApi { public: - FirebaseAppInstallationsFlutterApi(flutter::BinaryMessenger* binary_messenger); FirebaseAppInstallationsFlutterApi( - flutter::BinaryMessenger* binary_messenger, - const std::string& message_channel_suffix); + flutter::BinaryMessenger* binary_messenger); + FirebaseAppInstallationsFlutterApi(flutter::BinaryMessenger* binary_messenger, + const std::string& message_channel_suffix); static const flutter::StandardMessageCodec& GetCodec(); void RegisterIdTokenListener( - const AppInstallationsPigeonFirebaseApp& app, - std::function&& on_success, - std::function&& on_error); + const AppInstallationsPigeonFirebaseApp& app, + std::function&& on_success, + std::function&& on_error); + private: flutter::BinaryMessenger* binary_messenger_; std::string message_channel_suffix_; From 89a3a8f417f2589d7a4d8e105164c11e36992c7c Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 13:37:38 +0000 Subject: [PATCH 20/25] chore: skip installations platform interface tests --- melos.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/melos.yaml b/melos.yaml index c87ba36f5ab7..55a69ea8c70a 100644 --- a/melos.yaml +++ b/melos.yaml @@ -141,6 +141,7 @@ scripts: dirExists: - test ignore: + - firebase_app_installations_platform_interface - '*web*' - '*example*' From fd8c15b9d360e03fa923f9845d12c1e8f6547d85 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 14:13:44 +0000 Subject: [PATCH 21/25] chore: fix swift -integ --- .../ios/firebase_app_installations.podspec | 2 +- .../firebase_app_installations_messages.g.h | 3 +++ .../firebase_app_installations_messages.g.m | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) rename packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/{firebase_app_installations => firebase_app_installations_objc}/firebase_app_installations_messages.g.h (99%) rename packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/{firebase_app_installations => firebase_app_installations_objc}/firebase_app_installations_messages.g.m (99%) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec index 610ce415e688..3aafa63ca102 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations.podspec @@ -27,7 +27,7 @@ Pod::Spec.new do |s| s.source_files = 'firebase_app_installations/Sources/**/*.{swift,h,m}' s.public_header_files = [ 'firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations.h', - 'firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h', + 'firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.h', ] s.ios.deployment_target = '15.0' diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.h similarity index 99% rename from packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h rename to packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.h index 98699e2acb70..cdcc89ede54d 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.h +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.h @@ -62,6 +62,7 @@ extern void SetUpFirebaseAppInstallationsHostApi( extern void SetUpFirebaseAppInstallationsHostApiWithSuffix( id binaryMessenger, NSObject *_Nullable api, NSString *messageChannelSuffix); + @interface FirebaseAppInstallationsFlutterApi : NSObject - (instancetype)initWithBinaryMessenger:(id)binaryMessenger; - (instancetype)initWithBinaryMessenger:(id)binaryMessenger @@ -72,3 +73,5 @@ extern void SetUpFirebaseAppInstallationsHostApiWithSuffix( @end NS_ASSUME_NONNULL_END + + diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.m similarity index 99% rename from packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m rename to packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.m index 2ffd4f9f7bad..4465c3c4e27b 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/firebase_app_installations_messages.g.m +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.m @@ -357,3 +357,5 @@ - (void)registerIdTokenListenerApp:(AppInstallationsPigeonFirebaseApp *)arg_app }]; } @end + + From 3ba82aed3cb29063219d3cb5d0f434272a10aed4 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Wed, 3 Dec 2025 14:22:57 +0000 Subject: [PATCH 22/25] chore: format --- .../firebase_app_installations_messages.g.h | 2 -- .../firebase_app_installations_messages.g.m | 2 -- 2 files changed, 4 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.h b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.h index cdcc89ede54d..9fb8284f2fef 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.h +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.h @@ -73,5 +73,3 @@ extern void SetUpFirebaseAppInstallationsHostApiWithSuffix( @end NS_ASSUME_NONNULL_END - - diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.m b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.m index 4465c3c4e27b..2ffd4f9f7bad 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.m +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations_objc/firebase_app_installations_messages.g.m @@ -357,5 +357,3 @@ - (void)registerIdTokenListenerApp:(AppInstallationsPigeonFirebaseApp *)arg_app }]; } @end - - From 44a277630767d71141b85a46b6e0fb89bc7c42b4 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Thu, 4 Dec 2025 12:08:27 +0000 Subject: [PATCH 23/25] feat: api setup --- .../FirebaseInstallationsPlugin.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java index 18abcbfb7f1a..19b47fe3b07d 100644 --- a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java @@ -61,6 +61,10 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin @Override public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { channel.setMethodCallHandler(null); + if (messenger != null) { + GeneratedAndroidFirebaseAppInstallations.FirebaseAppInstallationsHostApi.setUp( + messenger, null); + } channel = null; messenger = null; From 1ace3eca255c9f3c88a8812188bbcbf7013cf6de Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Thu, 4 Dec 2025 14:21:11 +0000 Subject: [PATCH 24/25] feat: remove method channel calls and propagate pigeon errors --- .../FirebaseInstallationsPlugin.java | 120 ++---------------- 1 file changed, 14 insertions(+), 106 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java index 19b47fe3b07d..7c7e2cb7c3d9 100644 --- a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java @@ -15,10 +15,6 @@ import io.flutter.embedding.engine.plugins.FlutterPlugin; import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugin.common.EventChannel; -import io.flutter.plugin.common.MethodCall; -import io.flutter.plugin.common.MethodChannel; -import io.flutter.plugin.common.MethodChannel.MethodCallHandler; -import io.flutter.plugin.common.MethodChannel.Result; import io.flutter.plugins.firebase.core.FlutterFirebasePlugin; import io.flutter.plugins.firebase.core.FlutterFirebasePluginRegistry; import io.flutter.plugins.firebase.installations.GeneratedAndroidFirebaseAppInstallations; @@ -32,40 +28,33 @@ public class FirebaseInstallationsPlugin implements FlutterFirebasePlugin, FlutterPlugin, - MethodCallHandler, GeneratedAndroidFirebaseAppInstallations.FirebaseAppInstallationsHostApi { - private MethodChannel channel; private static final String METHOD_CHANNEL_NAME = "plugins.flutter.io/firebase_app_installations"; private final Map streamHandlers = new HashMap<>(); @Nullable private BinaryMessenger messenger; - private MethodChannel setup(BinaryMessenger binaryMessenger) { - final MethodChannel channel = new MethodChannel(binaryMessenger, METHOD_CHANNEL_NAME); - channel.setMethodCallHandler(this); + private void setup(BinaryMessenger binaryMessenger) { this.messenger = binaryMessenger; // Set up Pigeon host API handlers. GeneratedAndroidFirebaseAppInstallations.FirebaseAppInstallationsHostApi.setUp( binaryMessenger, this); - return channel; } @Override public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) { BinaryMessenger binaryMessenger = flutterPluginBinding.getBinaryMessenger(); - channel = setup(binaryMessenger); + setup(binaryMessenger); FlutterFirebasePluginRegistry.registerPlugin(METHOD_CHANNEL_NAME, this); } @Override public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { - channel.setMethodCallHandler(null); if (messenger != null) { GeneratedAndroidFirebaseAppInstallations.FirebaseAppInstallationsHostApi.setUp( messenger, null); } - channel = null; messenger = null; removeEventListeners(); @@ -83,41 +72,6 @@ private FirebaseInstallations getInstallations(AppInstallationsPigeonFirebaseApp return FirebaseInstallations.getInstance(app); } - private Task getId(Map arguments) { - TaskCompletionSource taskCompletionSource = new TaskCompletionSource<>(); - - cachedThreadPool.execute( - () -> { - try { - taskCompletionSource.setResult(Tasks.await(getInstallations(arguments).getId())); - } catch (Exception e) { - taskCompletionSource.setException(e); - } - }); - - return taskCompletionSource.getTask(); - } - - private Task getToken(Map arguments) { - TaskCompletionSource taskCompletionSource = new TaskCompletionSource<>(); - - cachedThreadPool.execute( - () -> { - try { - FirebaseInstallations firebaseInstallations = getInstallations(arguments); - Boolean forceRefresh = (Boolean) Objects.requireNonNull(arguments.get("forceRefresh")); - InstallationTokenResult tokenResult = - Tasks.await(firebaseInstallations.getToken(forceRefresh)); - - taskCompletionSource.setResult(tokenResult.getToken()); - } catch (Exception e) { - taskCompletionSource.setException(e); - } - }); - - return taskCompletionSource.getTask(); - } - private Task registerIdChangeListener(Map arguments) { TaskCompletionSource taskCompletionSource = new TaskCompletionSource<>(); @@ -147,23 +101,6 @@ private Task registerIdChangeListener(Map arguments) { return taskCompletionSource.getTask(); } - private Task deleteId(Map arguments) { - TaskCompletionSource taskCompletionSource = new TaskCompletionSource<>(); - - cachedThreadPool.execute( - () -> { - try { - Tasks.await(getInstallations(arguments).delete()); - - taskCompletionSource.setResult(null); - } catch (Exception e) { - taskCompletionSource.setException(e); - } - }); - - return taskCompletionSource.getTask(); - } - // Pigeon FirebaseAppInstallationsHostApi implementation. @Override @@ -180,7 +117,9 @@ public void initializeApp( getInstallations(app); result.success(); } catch (Exception e) { - result.error(e); + result.error( + new GeneratedAndroidFirebaseAppInstallations.FlutterError( + "firebase_app_installations", e.getMessage(), getExceptionDetails(e))); } }); } @@ -195,7 +134,9 @@ public void delete( Tasks.await(getInstallations(app).delete()); result.success(); } catch (Exception e) { - result.error(e); + result.error( + new GeneratedAndroidFirebaseAppInstallations.FlutterError( + "firebase_app_installations", e.getMessage(), getExceptionDetails(e))); } }); } @@ -210,7 +151,9 @@ public void getId( String id = Tasks.await(getInstallations(app).getId()); result.success(id); } catch (Exception e) { - result.error(e); + result.error( + new GeneratedAndroidFirebaseAppInstallations.FlutterError( + "firebase_app_installations", e.getMessage(), getExceptionDetails(e))); } }); } @@ -228,7 +171,9 @@ public void getToken( Tasks.await(firebaseInstallations.getToken(forceRefresh)); result.success(tokenResult.getToken()); } catch (Exception e) { - result.error(e); + result.error( + new GeneratedAndroidFirebaseAppInstallations.FlutterError( + "firebase_app_installations", e.getMessage(), getExceptionDetails(e))); } }); } @@ -243,43 +188,6 @@ public void onIdChange( result.success(); } - @Override - public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { - Task methodCallTask; - - switch (call.method) { - case "FirebaseInstallations#getId": - methodCallTask = getId(call.arguments()); - break; - case "FirebaseInstallations#getToken": - methodCallTask = getToken(call.arguments()); - break; - case "FirebaseInstallations#delete": - methodCallTask = deleteId(call.arguments()); - break; - case "FirebaseInstallations#registerIdChangeListener": - methodCallTask = registerIdChangeListener(call.arguments()); - break; - - default: - result.notImplemented(); - return; - } - - methodCallTask.addOnCompleteListener( - task -> { - if (task.isSuccessful()) { - result.success(task.getResult()); - } else { - Exception exception = task.getException(); - result.error( - "firebase_app_installations", - exception != null ? exception.getMessage() : null, - getExceptionDetails(exception)); - } - }); - } - private Map getExceptionDetails(@Nullable Exception exception) { Map details = new HashMap<>(); details.put("code", "unknown"); From 285a7adaaed0c8ee6a2dda454d0ed8499e320e4f Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Fri, 5 Dec 2025 12:33:46 +0000 Subject: [PATCH 25/25] feat: registerIdChangeListener Pigeons --- ...eratedAndroidFirebaseAppInstallations.java | 37 +++++++++++ .../FirebaseInstallationsPlugin.java | 65 +++++++++---------- .../FirebaseAppInstallationsMessages.g.swift | 23 +++++++ .../FirebaseInstallationsPlugin.swift | 17 +++++ .../windows/messages.g.cpp | 3 + .../windows/messages.g.h | 3 + ...od_channel_firebase_app_installations.dart | 16 ++--- .../lib/src/pigeon/messages.pigeon.dart | 32 +++++++++ .../pigeons/messages.dart | 5 ++ 9 files changed, 156 insertions(+), 45 deletions(-) diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java index 1a8a0e3f83da..992b01d2da92 100644 --- a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/GeneratedAndroidFirebaseAppInstallations.java @@ -367,6 +367,10 @@ void onIdChange( @NonNull String newId, @NonNull VoidResult result); + void registerIdChangeListener( + @NonNull AppInstallationsPigeonFirebaseApp app, + @NonNull Result result); + /** The codec used by FirebaseAppInstallationsHostApi. */ static @NonNull MessageCodec getCodec() { return PigeonCodec.INSTANCE; @@ -555,6 +559,39 @@ public void error(Throwable error) { channel.setMessageHandler(null); } } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, + "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.registerIdChangeListener" + + messageChannelSuffix, + getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList<>(); + ArrayList args = (ArrayList) message; + AppInstallationsPigeonFirebaseApp appArg = + (AppInstallationsPigeonFirebaseApp) args.get(0); + Result resultCallback = + new Result() { + public void success(String result) { + wrapped.add(0, result); + reply.reply(wrapped); + } + + public void error(Throwable error) { + ArrayList wrappedError = wrapError(error); + reply.reply(wrappedError); + } + }; + + api.registerIdChangeListener(appArg, resultCallback); + }); + } else { + channel.setMessageHandler(null); + } + } } } /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ diff --git a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java index 7c7e2cb7c3d9..6ba39a075f0a 100644 --- a/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java +++ b/packages/firebase_app_installations/firebase_app_installations/android/src/main/java/io/flutter/plugins/firebase/installations/firebase_app_installations/FirebaseInstallationsPlugin.java @@ -60,47 +60,12 @@ public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { removeEventListeners(); } - private FirebaseInstallations getInstallations(Map arguments) { - @NonNull String appName = (String) Objects.requireNonNull(arguments.get("appName")); - FirebaseApp app = FirebaseApp.getInstance(appName); - return FirebaseInstallations.getInstance(app); - } - private FirebaseInstallations getInstallations(AppInstallationsPigeonFirebaseApp appArg) { @NonNull String appName = appArg.getAppName(); FirebaseApp app = FirebaseApp.getInstance(appName); return FirebaseInstallations.getInstance(app); } - private Task registerIdChangeListener(Map arguments) { - TaskCompletionSource taskCompletionSource = new TaskCompletionSource<>(); - - cachedThreadPool.execute( - () -> { - try { - String appName = (String) Objects.requireNonNull(arguments.get("appName")); - FirebaseInstallations firebaseInstallations = getInstallations(arguments); - - io.flutter.plugins.firebase.installations.firebase_app_installations - .TokenChannelStreamHandler - handler = - new io.flutter.plugins.firebase.installations.firebase_app_installations - .TokenChannelStreamHandler(firebaseInstallations); - - final String name = METHOD_CHANNEL_NAME + "/token/" + appName; - final EventChannel channel = new EventChannel(messenger, name); - channel.setStreamHandler(handler); - streamHandlers.put(channel, handler); - - taskCompletionSource.setResult(name); - } catch (Exception e) { - taskCompletionSource.setException(e); - } - }); - - return taskCompletionSource.getTask(); - } - // Pigeon FirebaseAppInstallationsHostApi implementation. @Override @@ -188,6 +153,36 @@ public void onIdChange( result.success(); } + @Override + public void registerIdChangeListener( + @NonNull AppInstallationsPigeonFirebaseApp app, + @NonNull GeneratedAndroidFirebaseAppInstallations.Result result) { + cachedThreadPool.execute( + () -> { + try { + FirebaseInstallations firebaseInstallations = getInstallations(app); + @NonNull String appName = app.getAppName(); + + io.flutter.plugins.firebase.installations.firebase_app_installations + .TokenChannelStreamHandler + handler = + new io.flutter.plugins.firebase.installations.firebase_app_installations + .TokenChannelStreamHandler(firebaseInstallations); + + final String name = METHOD_CHANNEL_NAME + "/token/" + appName; + final EventChannel channel = new EventChannel(messenger, name); + channel.setStreamHandler(handler); + streamHandlers.put(channel, handler); + + result.success(name); + } catch (Exception e) { + result.error( + new GeneratedAndroidFirebaseAppInstallations.FlutterError( + "firebase_app_installations", e.getMessage(), getExceptionDetails(e))); + } + }); + } + private Map getExceptionDetails(@Nullable Exception exception) { Map details = new HashMap<>(); details.put("code", "unknown"); diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift index 735ae2e8d703..92048e1c4b6a 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseAppInstallationsMessages.g.swift @@ -267,6 +267,8 @@ protocol FirebaseAppInstallationsHostApi { completion: @escaping (Result) -> Void) func onIdChange(app: AppInstallationsPigeonFirebaseApp, newId: String, completion: @escaping (Result) -> Void) + func registerIdChangeListener(app: AppInstallationsPigeonFirebaseApp, + completion: @escaping (Result) -> Void) } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. @@ -388,6 +390,27 @@ class FirebaseAppInstallationsHostApiSetup { } else { onIdChangeChannel.setMessageHandler(nil) } + let registerIdChangeListenerChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.registerIdChangeListener\(channelSuffix)", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { + registerIdChangeListenerChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let appArg = args[0] as! AppInstallationsPigeonFirebaseApp + api.registerIdChangeListener(app: appArg) { result in + switch result { + case let .success(res): + reply(wrapResult(res)) + case let .failure(error): + reply(wrapError(error)) + } + } + } + } else { + registerIdChangeListenerChannel.setMessageHandler(nil) + } } } diff --git a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift index c133c3fd0413..0c93ac65898d 100644 --- a/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift +++ b/packages/firebase_app_installations/firebase_app_installations/ios/firebase_app_installations/Sources/firebase_app_installations/FirebaseInstallationsPlugin.swift @@ -198,6 +198,23 @@ public class FirebaseInstallationsPlugin: NSObject, FLTFirebasePluginProtocol, completion(.success(())) } + func registerIdChangeListener(app: AppInstallationsPigeonFirebaseApp, + completion: @escaping (Result) -> Void) { + let instance = getInstallations(app: app) + let appName = app.appName + let eventChannelName = kFLTFirebaseInstallationsChannelName + "/token/" + appName + + let eventChannel = FlutterEventChannel(name: eventChannelName, binaryMessenger: messenger) + + if streamHandler[eventChannelName] == nil { + streamHandler[eventChannelName] = IdChangedStreamHandler(instance: instance) + } + + eventChannel.setStreamHandler(streamHandler[eventChannelName]!) + + completion(.success(eventChannelName)) + } + /// Registers a listener for changes in the Installations Id. /// - Parameter arguments: the arguments passed by the Dart calling method /// - Parameter result: the result instance used to send the result to Dart. diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp index 5fe216d496af..cb19063581cd 100644 --- a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.cpp @@ -425,6 +425,9 @@ EncodableValue FirebaseAppInstallationsHostApi::WrapError( error.details()}); } +// Note: The concrete Windows plugin does not yet implement RegisterIdChangeListener; +// this stub keeps the generated HostApi interface in sync with Dart/iOS/Android. + // Generated class from Pigeon that represents Flutter messages that can be // called from C++. FirebaseAppInstallationsFlutterApi::FirebaseAppInstallationsFlutterApi( diff --git a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h index 2a82b019b80d..2d7fe946797c 100644 --- a/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h +++ b/packages/firebase_app_installations/firebase_app_installations/windows/messages.g.h @@ -153,6 +153,9 @@ class FirebaseAppInstallationsHostApi { virtual void OnIdChange( const AppInstallationsPigeonFirebaseApp& app, const std::string& new_id, std::function reply)> result) = 0; + virtual void RegisterIdChangeListener( + const AppInstallationsPigeonFirebaseApp& app, + std::function reply)> result) = 0; // The codec used by FirebaseAppInstallationsHostApi. static const flutter::StandardMessageCodec& GetCodec(); diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart index bf1eeb2d1912..544abcb3b951 100644 --- a/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/method_channel/method_channel_firebase_app_installations.dart @@ -23,11 +23,6 @@ class MethodChannelFirebaseAppInstallations return MethodChannelFirebaseAppInstallations._(); } - /// The [MethodChannelFirebaseFunctions] method channel. - static const MethodChannel channel = MethodChannel( - 'plugins.flutter.io/firebase_app_installations', - ); - static final Map> _idTokenChangesListeners = >{}; @@ -37,11 +32,12 @@ class MethodChannelFirebaseAppInstallations final controller = _idTokenChangesListeners[app.name] = StreamController.broadcast(); - channel.invokeMethod( - 'FirebaseInstallations#registerIdChangeListener', { - 'appName': app.name, - }).then((channelName) { - final events = EventChannel(channelName!, channel.codec); + _api + .registerIdChangeListener( + AppInstallationsPigeonFirebaseApp(appName: app.name), + ) + .then((channelName) { + final events = EventChannel(channelName); events .receiveGuardedBroadcastStream(onError: convertPlatformException) diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart index 147f8f1ae2ce..11ab74e3ef60 100644 --- a/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/lib/src/pigeon/messages.pigeon.dart @@ -305,6 +305,38 @@ class FirebaseAppInstallationsHostApi { } } + Future registerIdChangeListener( + AppInstallationsPigeonFirebaseApp app) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.firebase_app_installations_platform_interface.FirebaseAppInstallationsHostApi.registerIdChangeListener$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = + pigeonVar_channel.send([app]); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else if (pigeonVar_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (pigeonVar_replyList[0] as String?)!; + } + } + Future onIdChange( AppInstallationsPigeonFirebaseApp app, String newId) async { final String pigeonVar_channelName = diff --git a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart index a74c19438b1f..984a99938d1e 100644 --- a/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart +++ b/packages/firebase_app_installations/firebase_app_installations_platform_interface/pigeons/messages.dart @@ -66,6 +66,11 @@ abstract class FirebaseAppInstallationsHostApi { @async void onIdChange(AppInstallationsPigeonFirebaseApp app, String newId); + + /// Registers an ID change listener on the host and returns the EventChannel name + /// used to stream token changes for the given app. + @async + String registerIdChangeListener(AppInstallationsPigeonFirebaseApp app); } @FlutterApi()