Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Activadores de Firebase Remote Config
Cloud Run Functions se puede activar en respuesta a cambios en Firebase Remote Config en el mismo proyecto de Google Cloud en el que se encuentra la función. Esto permite cambiar el comportamiento y la apariencia de tu aplicación sin publicar una actualización.
Tipos de eventos
Firebase Remote Config puede activar funciones como respuesta al evento remoteconfig.update.
Tipo de evento
Activador
remoteconfig.update
Se activa cuando se actualiza la plantilla de Remote Config.
Estructura de eventos
Los datos de eventos se proporcionan como un objeto remoteConfig transformado.
/** * Background Function triggered by a change to a Firebase Remote Config value. * * @param {object} event The Cloud Functions event. */exports.helloRemoteConfig=event=>{console.log(`Update type: ${event.updateType}`);console.log(`Origin: ${event.updateOrigin}`);console.log(`Version: ${event.versionNumber}`);};
Python
defhello_remote_config(data,context):"""Triggered by a change to a Firebase Remote Config value. Args: data (dict): The event payload. context (google.cloud.functions.Context): Metadata for the event. """print(f'Update type: {data["updateType"]}')print(f'Origin: {data["updateOrigin"]}')print(f'Version: {data["versionNumber"]}')
Go
// Package helloworld provides a set of Cloud Functions samples.packagehelloworldimport("context""log")// A RemoteConfigEvent is an event triggered by Firebase Remote Config.typeRemoteConfigEventstruct{UpdateOriginstring`json:"updateOrigin"`UpdateTypestring`json:"updateType"`UpdateUserstruct{Emailstring`json:"email"`ImageURLstring`json:"imageUrl"`Namestring`json:"name"`}`json:"updateUser"`VersionNumberstring`json:"versionNumber"`}// HelloRemoteConfig handles Firebase Remote Config events.funcHelloRemoteConfig(ctxcontext.Context,eRemoteConfigEvent)error{log.Printf("Update type: %v",e.UpdateType)log.Printf("Origin: %v",e.UpdateOrigin)log.Printf("Version: %v",e.VersionNumber)returnnil}
Java
importcom.google.cloud.functions.Context;importcom.google.cloud.functions.RawBackgroundFunction;importcom.google.gson.Gson;importcom.google.gson.JsonObject;importjava.util.logging.Logger;publicclassFirebaseRemoteConfigimplementsRawBackgroundFunction{privatestaticfinalLoggerlogger=Logger.getLogger(FirebaseRemoteConfig.class.getName());// Use GSON (https://github.com/google/gson) to parse JSON content.privatestaticfinalGsongson=newGson();@Overridepublicvoidaccept(Stringjson,Contextcontext){JsonObjectbody=gson.fromJson(json,JsonObject.class);if(body!=null){if(body.has("updateType")){logger.info("Update type: "+body.get("updateType").getAsString());}if(body.has("updateOrigin")){logger.info("Origin: "+body.get("updateOrigin").getAsString());}if(body.has("versionNumber")){logger.info("Version: "+body.get("versionNumber").getAsString());}}}}
C#
usingCloudNative.CloudEvents;usingGoogle.Cloud.Functions.Framework;usingGoogle.Events.Protobuf.Firebase.RemoteConfig.V1;usingMicrosoft.Extensions.Logging;usingSystem.Threading;usingSystem.Threading.Tasks;namespaceFirebaseRemoteConfig;publicclassFunction:ICloudEventFunction<RemoteConfigEventData>{privatereadonlyILogger_logger;publicFunction(ILogger<Function>logger)=>
_logger=logger;publicTaskHandleAsync(CloudEventcloudEvent,RemoteConfigEventDatadata,CancellationTokencancellationToken){_logger.LogInformation("Update type: {origin}",data.UpdateType);_logger.LogInformation("Update origin: {origin}",data.UpdateOrigin);_logger.LogInformation("Version number: {version}",data.VersionNumber);// In this example, we don't need to perform any asynchronous operations, so the// method doesn't need to be declared async.returnTask.CompletedTask;}}
Ruby
require"functions_framework"# Triggered by a change to a Firebase Remote Config valueFunctionsFramework.cloud_event"hello_remote_config"do|event|# Event-triggered Ruby functions receive a CloudEvents::Event::V1 object.# See https://cloudevents.github.io/sdk-ruby/latest/CloudEvents/Event/V1.html# The Firebase event payload can be obtained from the event data.payload=event.datalogger.info"Update type: #{payload['updateType']}"logger.info"Origin: #{payload['updateOrigin']}"logger.info"Version: #{payload['versionNumber']}"end
El nombre registrado de la función de Cloud Run Functions que estás implementando.
Puede ser el nombre de una función en tu código fuente o una string arbitraria. Si FUNCTION_NAME es una string arbitraria, debes incluir la marca --entry-point.
--entry-point ENTRY_POINT
El nombre de una función o clase en tu código fuente. Opcional, a menos que no hayas usado FUNCTION_NAME para especificar la función en tu código fuente que se ejecutará durante la implementación. En ese caso, debes usar --entry-point para proporcionar el nombre de la función ejecutable.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-01-31 (UTC)"],[],[]]