Zum Inhalt springen

Getting Started

GitHub

Sie können unsere AI-gestützte Einrichtung verwenden, um das Plugin zu installieren. Fügen Sie die Capgo-Fähigkeiten Ihrem AI-Tool mit der folgenden Befehlszeile hinzu:

Terminalfenster
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

Verwenden Sie dann die folgende Anfrage:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-firebase-remote-config` plugin in my project.

Wenn Sie eine manuelle Einrichtung bevorzugen, installieren Sie das Plugin, indem Sie die folgenden Befehle ausführen und die darunter angegebenen Plattform-spezifischen Anweisungen befolgen.

Terminalfenster
bun add @capgo/capacitor-firebase-remote-config
npx cap sync
import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.activate();
import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.fetchAndActivate();
import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.fetchConfig();
  • run: run npx cap sync nach Plugin-Updates.
  • Wahrheitsquelle: Vertrauen src/definitions.ts im GitHub-Repository.

Stellen Sie die letzte abgerufene Konfiguration den Gettern zur Verfügung.

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.activate();

Sektion mit dem Titel „fetchAndActivate“

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.fetchAndActivate();

Konfiguration aus dem Remote Config-Dienst abrufen und in einem Cache speichern.

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.fetchConfig();

Wert für die angegebene Schlüssel als Boolesch abrufen.

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
const result = await FirebaseRemoteConfig.getBoolean({ key: 'key-123' });
console.log(result);

Wert für die angegebene Schlüssel als Zahl abrufen.

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
const result = await FirebaseRemoteConfig.getNumber({ key: 'key-123' });
console.log(result);

Wert für die angegebene Schlüssel als Zeichenkette abrufen.

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
const result = await FirebaseRemoteConfig.getString({ key: 'key-123' });
console.log(result);

Erfahren Sie Informationen über die letzte Abrufoperation.

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
const result = await FirebaseRemoteConfig.getInfo();
console.log(result);

Setzen Sie den minimalen Abrufinterval.

Nur für Web verfügbar.

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.setMinimumFetchInterval({ minimumFetchIntervalInSeconds: 43200 });

Setzen Sie die Remote-Config-Einstellungen.

Auf Android werden die Einstellungswerte in SharedPreferences gespeichert.

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.setSettings({
fetchTimeoutInSeconds: 60,
minimumFetchIntervalInSeconds: 43200,
});

Hinzufügen eines Hörers für das Konfigurationsupdateereignis.

Nur für Android und iOS verfügbar.

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
const result = await FirebaseRemoteConfig.addConfigUpdateListener((event, error) => {
console.log(event);
});
console.log(result);

Ein Listener für die Konfigurationsaktualisierungsereignis entfernen.

Nur für Android und iOS verfügbar.

import { FirebaseRemoteConfig } from '@capgo/capacitor-firebase-remote-config';
await FirebaseRemoteConfig.removeConfigUpdateListener({ id: 'id-123' });
export interface FetchConfigOptions {
/**
* Define the maximum age in seconds of an entry in the config cache before it is considered stale.
* During development, it's recommended to set a relatively low minimum fetch interval.
*
* Only available for Android and iOS.
*
* @since 1.3.0
* @default 43200
* @see https://firebase.google.com/docs/reference/js/firebase.remoteconfig.RemoteConfigSettings#minimumfetchintervalmillis
*/
minimumFetchIntervalInSeconds?: number;
}
export type GetBooleanOptions = GetOptions;
export interface GetBooleanResult {
/**
* The value for the given key as a boolean.
*
* @since 1.3.0
*/
value: boolean;
/**
* Indicates at which source this value came from.
*
* Only available for Android and iOS.
*
* @since 1.3.0
*/
source?: GetValueSource;
}
export type GetNumberOptions = GetOptions;
export interface GetNumberResult {
/**
* The value for the given key as a number.
*
* @since 1.3.0
*/
value: number;
/**
* Indicates at which source this value came from.
*
* Only available for Android and iOS.
*
* @since 1.3.0
*/
source?: GetValueSource;
}
export type GetStringOptions = GetOptions;
export interface GetStringResult {
/**
* The value for the given key as a string.
*
* @since 1.3.0
*/
value: string;
/**
* Indicates at which source this value came from.
*
* Only available for Android and iOS.
*
* @since 1.3.0
*/
source?: GetValueSource;
}
export interface GetInfoResult {
/**
* The Unix timestamp in milliseconds of the last successful fetch, or -1 if no fetch has occurred or initialization is incomplete.
* @since 7.5.0
* @example 1762864760
*/
lastFetchTime: number;
/**
* The status of the last fetch attempt.
* @since 7.5.0
* @example 1
*/
lastFetchStatus: LastFetchStatus;
}
export interface SetMinimumFetchIntervalOptions {
/**
* Define the maximum age in seconds of an entry in the config cache before it is considered stale.
* During development, it's recommended to set a relatively low minimum fetch interval.
*
* @since 1.3.0
* @default 43200
* @see https://firebase.google.com/docs/reference/js/remote-config.remoteconfigsettings#remoteconfigsettingsminimumfetchintervalmillis
*/
minimumFetchIntervalInSeconds: number;
}
export interface SetSettingsOptions {
/**
* Defines the maximum amount of milliseconds to wait for a response when fetching configuration from the Remote Config server.
*
* @since 6.2.0
* @default 60
* @see https://firebase.google.com/docs/reference/js/remote-config.remoteconfigsettings#remoteconfigsettingsfetchtimeoutmillis
*/
fetchTimeoutInSeconds?: number;
/**
* Define the maximum age in seconds of an entry in the config cache before it is considered stale.
* During development, it's recommended to set a relatively low minimum fetch interval.
*
* @since 6.2.0
* @default 43200
* @see https://firebase.google.com/docs/reference/js/remote-config.remoteconfigsettings#remoteconfigsettingsminimumfetchintervalmillis
*/
minimumFetchIntervalInSeconds?: number;
}
export type AddConfigUpdateListenerOptionsCallback = (
event: AddConfigUpdateListenerOptionsCallbackEvent | null,
error: any,
) => void;
export type CallbackId = string;

Diese Seite wurde aus dem Plugin generiert src/definitions.tsRe-run die Synchronisation, wenn die öffentliche API upstream geändert wird.

Wenn Sie Firebase Remote Config verwenden Getting Started" zum Planen von Dashboard und API-Operationen verwenden, verbinden Sie es mit API-Übersicht für die Implementierungsdetails in API-Übersicht Einführung für die Implementierungsdetails in Einführung API-Schlüssel für die Implementierungsdetails in API-Schlüssel Geräte zur Implementierungsdetail in Geräte, und Pakete zur Implementierungsdetail in Pakete.