CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-react-native-firebase--app

Core React Native Firebase implementation providing foundation for all Firebase services across iOS and Android platforms

Pending
Overview
Eval results
Files

native-integration.mddocs/

Native Integration

React Native Firebase platform integration functions for accessing native platform data, Firebase configuration, and managing platform-specific preferences.

Capabilities

Meta Data Access

Retrieves Firebase-specific metadata from native platform configuration files (Info.plist on iOS, AndroidManifest.xml on Android).

/**
 * Gets react-native-firebase specific "meta" data from native Info.plist / AndroidManifest.xml
 * @returns Promise resolving to map of key/value pairs containing native meta data
 */
function metaGetAll(): Promise<{[key: string]: string | boolean}>;

Usage Examples:

import { metaGetAll } from '@react-native-firebase/app';

// Get all native metadata
const metadata = await metaGetAll();
console.log('Native metadata:', metadata);

// Access specific metadata values
if (metadata.firebase_analytics_auto_collection_enabled === false) {
  console.log('Analytics auto-collection is disabled');
}

Firebase JSON Configuration

Accesses Firebase configuration data stored in the native firebase.json file.

/**
 * Gets react-native-firebase specific "firebase.json" data
 * @returns Promise resolving to map of key/value pairs containing native firebase.json constants
 */
function jsonGetAll(): Promise<{[key: string]: string | boolean}>;

Usage Examples:

import { jsonGetAll } from '@react-native-firebase/app';

// Get Firebase JSON configuration
const firebaseConfig = await jsonGetAll();
console.log('Firebase config:', firebaseConfig);

// Check specific configuration values
if (firebaseConfig.react_native_firebase_analytics_auto_collection_enabled) {
  console.log('Analytics is configured to auto-collect');
}

Preferences Management

Manages React Native Firebase-specific native preferences for storing key-value data persistently on the device.

/**
 * Gets react-native-firebase specific native preferences
 * @returns Promise resolving to map of key/value pairs containing native preferences data
 */
function preferencesGetAll(): Promise<{[key: string]: string | boolean}>;

/**
 * Clears react-native-firebase specific native preferences
 * @returns Promise that resolves when preferences are cleared
 */
function preferencesClearAll(): Promise<void>;

/**
 * Sets react-native-firebase specific native boolean preference
 * @param key - The name of the native preference to set
 * @param value - The boolean value of the native preference to set
 * @returns Promise that resolves when preference is set
 */
function preferencesSetBool(key: string, value: boolean): Promise<void>;

/**
 * Sets react-native-firebase specific native string preference
 * @param key - The name of the native preference to set
 * @param value - The string value of the native preference to set
 * @returns Promise that resolves when preference is set
 */
function preferencesSetString(key: string, value: string): Promise<void>;

Usage Examples:

import { 
  preferencesGetAll, 
  preferencesSetBool, 
  preferencesSetString,
  preferencesClearAll 
} from '@react-native-firebase/app';

// Get all current preferences
const preferences = await preferencesGetAll();
console.log('Current preferences:', preferences);

// Set boolean preference
await preferencesSetBool('analytics_enabled', true);
await preferencesSetBool('crashlytics_enabled', false);

// Set string preference
await preferencesSetString('user_segment', 'premium');
await preferencesSetString('app_version', '1.2.3');

// Verify preferences were set
const updatedPrefs = await preferencesGetAll();
console.log('Updated preferences:', updatedPrefs);

// Clear all preferences
await preferencesClearAll();
console.log('All preferences cleared');

Data Types

All native integration functions return or accept simple data types:

  • String values: Used for configuration keys, preference values, and text-based metadata
  • Boolean values: Used for feature flags, enabled/disabled states
  • Key-value objects: All getter functions return objects with string keys and string/boolean values

Platform Considerations

iOS Specific

  • Metadata comes from Info.plist file
  • Preferences stored in NSUserDefaults
  • Some Firebase configuration may be iOS-specific

Android Specific

  • Metadata comes from AndroidManifest.xml file
  • Preferences stored in SharedPreferences
  • Some Firebase configuration may be Android-specific

Cross-Platform Usage

import { metaGetAll, preferencesSetBool } from '@react-native-firebase/app';
import { Platform } from 'react-native';

// Platform-aware configuration
const metadata = await metaGetAll();

if (Platform.OS === 'ios') {
  // iOS-specific handling
  const iosSpecificKey = metadata.ios_specific_config;
} else if (Platform.OS === 'android') {
  // Android-specific handling  
  const androidSpecificKey = metadata.android_specific_config;
}

// Set platform-appropriate preferences
await preferencesSetBool(`${Platform.OS}_feature_enabled`, true);

Common Use Cases

Feature Flag Management

import { preferencesGetAll, preferencesSetBool } from '@react-native-firebase/app';

// Check if feature is enabled
const prefs = await preferencesGetAll();
const featureEnabled = prefs.new_feature_enabled === true;

if (featureEnabled) {
  // Enable new feature
} else {
  // Use legacy implementation
}

// Enable feature after user opts in
await preferencesSetBool('new_feature_enabled', true);

Configuration Storage

import { preferencesSetString, preferencesGetAll } from '@react-native-firebase/app';

// Store user configuration
await preferencesSetString('api_endpoint', 'https://api.example.com');
await preferencesSetString('environment', 'production');

// Retrieve configuration later
const prefs = await preferencesGetAll();
const apiEndpoint = prefs.api_endpoint;
const environment = prefs.environment;

Debug Configuration Access

import { jsonGetAll, metaGetAll } from '@react-native-firebase/app';

// Get debug information
const firebaseConfig = await jsonGetAll();
const nativeMetadata = await metaGetAll();

console.log('Firebase Configuration:');
console.log(JSON.stringify(firebaseConfig, null, 2));

console.log('Native Metadata:');
console.log(JSON.stringify(nativeMetadata, null, 2));

Install with Tessl CLI

npx tessl i tessl/npm-react-native-firebase--app

docs

app-management.md

configuration.md

index.md

native-integration.md

utils.md

tile.json