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

configuration.mddocs/

Configuration

Firebase SDK configuration, logging control, and React Native-specific settings management functionality.

Capabilities

Set Log Level

Controls the log level across all Firebase SDKs. Currently only applies to iOS, has no effect on Android.

/**
 * Sets the log level across all Firebase SDKs
 * @param logLevel - The log level to set ('debug', 'verbose', 'info', 'warn', 'error', 'silent')
 * Note: iOS only - Android is not affected
 * Note: 'verbose' maps to 'debug' on iOS, 'silent' returns error if used
 * Note: Apps from AppStore never log above 'info' regardless of setting
 */
function setLogLevel(logLevel: LogLevelString): void;

Usage Examples:

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

// Set log level to debug (most verbose)
setLogLevel('debug');

// Set log level to error (least verbose)  
setLogLevel('error');

// Production setting
setLogLevel('warn');

Set AsyncStorage

Configures the AsyncStorage implementation to use for persisting data on non-native platforms.

/**
 * Sets the AsyncStorage implementation to use for persisting data on 'Other' platforms
 * If not specified, in memory persistence is used
 * This is required if you want to persist things like Auth sessions, Analytics device IDs, etc.
 * @param asyncStorage - The AsyncStorage implementation to use
 */
function setReactNativeAsyncStorage(asyncStorage: ReactNativeAsyncStorage): void;

Usage Examples:

import { setReactNativeAsyncStorage } from '@react-native-firebase/app';
import AsyncStorage from '@react-native-async-storage/async-storage';

// Set AsyncStorage for persistence
setReactNativeAsyncStorage(AsyncStorage);

// Custom AsyncStorage implementation
const customStorage = {
  setItem: async (key: string, value: string) => {
    // Custom implementation
    console.log(`Setting ${key} = ${value}`);
  },
  getItem: async (key: string) => {
    // Custom implementation  
    console.log(`Getting ${key}`);
    return null;
  },
  removeItem: async (key: string) => {
    // Custom implementation
    console.log(`Removing ${key}`);
  }
};

setReactNativeAsyncStorage(customStorage);

Log Handler

Sets a custom log handler for Firebase SDKs. Currently only supported for VertexAI module.

/**
 * Sets log handler for Firebase SDKs (currently only VertexAI)
 * @param logCallback - The callback function to handle logs
 * @param options - Optional settings for log handling
 */
function onLog(logCallback: (params: LogCallbackParams) => void, options?: any): void;

Usage Examples:

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

// Set up custom log handler
onLog((params) => {
  console.log(`[${params.level}] ${params.message}`, params.args);
  
  // Custom logging logic
  if (params.level === 'error') {
    // Send error to crash reporting
    crashlytics().recordError(new Error(params.message));
  }
});

// Advanced log handling with filtering
onLog((params) => {
  // Only log warnings and errors in production
  if (__DEV__ || ['warn', 'error'].includes(params.level)) {
    console.log(`${params.type}: ${params.message}`);
  }
}, { 
  // Options object (structure depends on implementation)
  captureLevel: 'warn'
});

Traditional Firebase API

Configuration functions are also available through the traditional Firebase API:

import firebase from '@react-native-firebase/app';

// Set log level (traditional style)
firebase.setLogLevel('debug');

// Set AsyncStorage (traditional style)
firebase.setReactNativeAsyncStorage(AsyncStorage);

Types

type LogLevelString = 'debug' | 'verbose' | 'info' | 'warn' | 'error' | 'silent';

interface LogCallbackParams {
  level: LogLevelString;
  message: string;
  args: unknown[];
  type: string;
}

interface ReactNativeAsyncStorage {
  setItem: Function;
  getItem: Function;
  removeItem: Function;
  [key: string]: any;
}

Platform Considerations

  • Log Levels: Only effective on iOS. Android logging is controlled through native configuration.
  • AsyncStorage: Required for data persistence on web and other non-native platforms. Native platforms have built-in persistence.
  • Log Handler: Currently only supported for VertexAI module. Other modules may add support in future versions.

Best Practices

import { setLogLevel, setReactNativeAsyncStorage, onLog } from '@react-native-firebase/app';
import AsyncStorage from '@react-native-async-storage/async-storage';

// Configure Firebase at app startup
export function initializeFirebaseConfig() {
  // Set appropriate log level
  if (__DEV__) {
    setLogLevel('debug');
  } else {
    setLogLevel('warn');
  }
  
  // Configure AsyncStorage for persistence
  setReactNativeAsyncStorage(AsyncStorage);
  
  // Set up error logging
  onLog((params) => {
    if (params.level === 'error') {
      // Log to crash reporting service
      console.error('Firebase Error:', params.message, params.args);
    }
  });
}

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