New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@capacitor-firebase/remote-config

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor-firebase/remote-config

Capacitor plugin for Firebase Remote Config.

  • 6.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.8K
decreased by-31.72%
Maintainers
0
Weekly downloads
 
Created
Source

@capacitor-firebase/remote-config

Unofficial Capacitor plugin for Firebase Remote Config.1

Installation

npm install @capacitor-firebase/remote-config firebase
npx cap sync

Add Firebase to your project if you haven't already (Android / iOS / Web).

Android

Google Analytics is required for the conditional targeting of app instances to user properties and audiences. Make sure that you install the Capacitor Firebase Analytics plugin in your project.

Variables

This plugin will use the following project variables (defined in your app’s variables.gradle file):

  • $firebaseConfigVersion version of com.google.firebase:firebase-config (default: 21.3.0)

Configuration

No configuration required for this plugin.

Demo

A working example can be found here: robingenz/capacitor-firebase-plugin-demo

Starter templates

The following starter templates are available:

Usage

import { FirebaseRemoteConfig } from '@capacitor-firebase/remote-config';

const activate = async () => {
  await FirebaseRemoteConfig.activate();
};

const fetchAndActivate = async () => {
  await FirebaseRemoteConfig.fetchAndActivate();
};

const fetchConfig = async () => {
  await FirebaseRemoteConfig.fetchConfig({
    minimumFetchIntervalInSeconds: 1200,
  });
};

const getBoolean = async () => {
  const { value } = await FirebaseRemoteConfig.getBoolean({
    key: 'is_sale',
  });
  return value;
};

const getNumber = async () => {
  const { value } = await FirebaseRemoteConfig.getNumber({
    key: 'upcoming_maintenance',
  });
  return value;
};

const getString = async () => {
  const { value } = await FirebaseRemoteConfig.getString({
    key: 'license_key',
  });
  return value;
};

const setSettings = async () => {
  await FirebaseRemoteConfig.setSettings({
    fetchTimeoutInSeconds: 10,
    minimumFetchIntervalInSeconds: 0,
  });
};

const addConfigUpdateListener = async () => {
  const callbackId = await FirebaseRemoteConfig.addConfigUpdateListener(
    (event, error) => {
      if (error) {
        console.error(error);
      } else {
        console.log(event);
      }
    }
  );
  return callbackId;
};

const removeConfigUpdateListener = async (callbackId: string) => {
  await FirebaseRemoteConfig.removeConfigUpdateListener({
    callbackId,
  });
};

const removeAllListeners = async () => {
  await FirebaseRemoteConfig.removeAllListeners();
};

API

activate()

activate() => Promise<void>

Make the last fetched configuration available to the getters.

Since: 1.3.0


fetchAndActivate()

fetchAndActivate() => Promise<void>

Perform fetch and activate operations.

Since: 1.3.0


fetchConfig(...)

fetchConfig(options?: FetchConfigOptions | undefined) => Promise<void>

Fetch and cache configuration from the Remote Config service.

ParamType
optionsFetchConfigOptions

Since: 1.3.0


getBoolean(...)

getBoolean(options: GetBooleanOptions) => Promise<GetBooleanResult>

Get the value for the given key as a boolean.

ParamType
optionsGetOptions

Returns: Promise<GetBooleanResult>

Since: 1.3.0


getNumber(...)

getNumber(options: GetNumberOptions) => Promise<GetNumberResult>

Get the value for the given key as a number.

ParamType
optionsGetOptions

Returns: Promise<GetNumberResult>

Since: 1.3.0


getString(...)

getString(options: GetStringOptions) => Promise<GetStringResult>

Get the value for the given key as a string.

ParamType
optionsGetOptions

Returns: Promise<GetStringResult>

Since: 1.3.0


setMinimumFetchInterval(...)

setMinimumFetchInterval(options: SetMinimumFetchIntervalOptions) => Promise<void>

Set the minimum fetch interval.

Only available for Web.

ParamType
optionsSetMinimumFetchIntervalOptions

Since: 1.3.0


setSettings(...)

setSettings(options: SetSettingsOptions) => Promise<void>

Set the remote config settings.

On Android, the settings values are persisted in SharedPreferences.

ParamType
optionsSetSettingsOptions

Since: 6.2.0


addConfigUpdateListener(...)

addConfigUpdateListener(callback: AddConfigUpdateListenerOptionsCallback) => Promise<CallbackId>

Add a listener for the config update event.

Only available for Android and iOS.

ParamType
callbackAddConfigUpdateListenerOptionsCallback

Returns: Promise<string>

Since: 5.4.0


removeConfigUpdateListener(...)

removeConfigUpdateListener(options: RemoveConfigUpdateListenerOptions) => Promise<void>

Remove a listener for the config update event.

Only available for Android and iOS.

ParamType
optionsRemoveConfigUpdateListenerOptions

Since: 5.4.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Since: 5.4.0


Interfaces

FetchConfigOptions
PropTypeDescriptionDefaultSince
minimumFetchIntervalInSecondsnumberDefine 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.432001.3.0
GetBooleanResult
PropTypeDescriptionSince
valuebooleanThe value for the given key as a boolean.1.3.0
sourceGetValueSourceIndicates at which source this value came from. Only available for Android and iOS.1.3.0
GetOptions
PropTypeDescriptionSince
keystringThe key of the value to get.1.3.0
GetNumberResult
PropTypeDescriptionSince
valuenumberThe value for the given key as a number.1.3.0
sourceGetValueSourceIndicates at which source this value came from. Only available for Android and iOS.1.3.0
GetStringResult
PropTypeDescriptionSince
valuestringThe value for the given key as a string.1.3.0
sourceGetValueSourceIndicates at which source this value came from. Only available for Android and iOS.1.3.0
SetMinimumFetchIntervalOptions
PropTypeDescriptionDefaultSince
minimumFetchIntervalInSecondsnumberDefine 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.432001.3.0
SetSettingsOptions
PropTypeDescriptionDefaultSince
fetchTimeoutInSecondsnumberDefines the maximum amount of milliseconds to wait for a response when fetching configuration from the Remote Config server.606.2.0
minimumFetchIntervalInSecondsnumberDefine 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.432006.2.0
AddConfigUpdateListenerOptionsCallbackEvent
PropTypeDescriptionSince
updatedKeysstring[]Parameter keys whose values have been updated from the currently activated values.5.4.0
RemoveConfigUpdateListenerOptions
PropTypeDescriptionSince
idCallbackIdThe id of the listener to remove.5.4.0

Type Aliases

GetBooleanOptions

GetOptions

GetNumberOptions

GetOptions

GetStringOptions

GetOptions

AddConfigUpdateListenerOptionsCallback

(event: AddConfigUpdateListenerOptionsCallbackEvent | null, error: any): void

CallbackId

string

Enums

GetValueSource
MembersValueDescriptionSince
Static0Indicates that the value returned is the static default value.1.3.0
Default1Indicates that the value returned was retrieved from the defaults set by the client.1.3.0
Remote2Indicates that the value returned was retrieved from the Firebase Remote Config Server.1.3.0

Changelog

See CHANGELOG.md.

License

See LICENSE.

Footnotes

  1. This project is not affiliated with, endorsed by, sponsored by, or approved by Google LLC or any of their affiliates or subsidiaries.

Keywords

FAQs

Package last updated on 16 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc