Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Gatilhos da Configuração remota do Firebase
As funções do Cloud Run podem ser acionadas em resposta a alterações na
Configuração remota do Firebase no
mesmo projeto do Google Cloud que a função. Isso possibilita alterar o
comportamento e a aparência do seu aplicativo sem publicar uma atualização dele.
Tipos de evento
A Configuração remota do Firebase pode acionar funções em resposta ao evento remoteconfig.update.
Tipo de evento
Gatilho
remoteconfig.update
Acionado quando o modelo de configuração remota é atualizado.
/** * 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
O nome registrado da função do Cloud Run que você está implantando.
Pode ser o nome de uma função no código-fonte ou uma string arbitrária. Se FUNCTION_NAME for uma string arbitrária, você precisará incluir a sinalização --entry-point.
--entry-point ENTRY_POINT
O nome de uma função ou classe no código-fonte. Opcional, a menos que
você não tenha usado FUNCTION_NAME
para especificar a
função no código-fonte a ser executada durante a implantação. Nesse caso, use --entry-point para fornecer o nome da função executável.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-01-31 UTC."],[],[]]