or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

app-management.mdconfiguration.mdindex.mdnative-integration.mdutils.md

native-integration.mddocs/

0

# Native Integration

1

2

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

3

4

## Capabilities

5

6

### Meta Data Access

7

8

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

9

10

```typescript { .api }

11

/**

12

* Gets react-native-firebase specific "meta" data from native Info.plist / AndroidManifest.xml

13

* @returns Promise resolving to map of key/value pairs containing native meta data

14

*/

15

function metaGetAll(): Promise<{[key: string]: string | boolean}>;

16

```

17

18

**Usage Examples:**

19

20

```typescript

21

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

22

23

// Get all native metadata

24

const metadata = await metaGetAll();

25

console.log('Native metadata:', metadata);

26

27

// Access specific metadata values

28

if (metadata.firebase_analytics_auto_collection_enabled === false) {

29

console.log('Analytics auto-collection is disabled');

30

}

31

```

32

33

### Firebase JSON Configuration

34

35

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

36

37

```typescript { .api }

38

/**

39

* Gets react-native-firebase specific "firebase.json" data

40

* @returns Promise resolving to map of key/value pairs containing native firebase.json constants

41

*/

42

function jsonGetAll(): Promise<{[key: string]: string | boolean}>;

43

```

44

45

**Usage Examples:**

46

47

```typescript

48

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

49

50

// Get Firebase JSON configuration

51

const firebaseConfig = await jsonGetAll();

52

console.log('Firebase config:', firebaseConfig);

53

54

// Check specific configuration values

55

if (firebaseConfig.react_native_firebase_analytics_auto_collection_enabled) {

56

console.log('Analytics is configured to auto-collect');

57

}

58

```

59

60

### Preferences Management

61

62

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

63

64

```typescript { .api }

65

/**

66

* Gets react-native-firebase specific native preferences

67

* @returns Promise resolving to map of key/value pairs containing native preferences data

68

*/

69

function preferencesGetAll(): Promise<{[key: string]: string | boolean}>;

70

71

/**

72

* Clears react-native-firebase specific native preferences

73

* @returns Promise that resolves when preferences are cleared

74

*/

75

function preferencesClearAll(): Promise<void>;

76

77

/**

78

* Sets react-native-firebase specific native boolean preference

79

* @param key - The name of the native preference to set

80

* @param value - The boolean value of the native preference to set

81

* @returns Promise that resolves when preference is set

82

*/

83

function preferencesSetBool(key: string, value: boolean): Promise<void>;

84

85

/**

86

* Sets react-native-firebase specific native string preference

87

* @param key - The name of the native preference to set

88

* @param value - The string value of the native preference to set

89

* @returns Promise that resolves when preference is set

90

*/

91

function preferencesSetString(key: string, value: string): Promise<void>;

92

```

93

94

**Usage Examples:**

95

96

```typescript

97

import {

98

preferencesGetAll,

99

preferencesSetBool,

100

preferencesSetString,

101

preferencesClearAll

102

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

103

104

// Get all current preferences

105

const preferences = await preferencesGetAll();

106

console.log('Current preferences:', preferences);

107

108

// Set boolean preference

109

await preferencesSetBool('analytics_enabled', true);

110

await preferencesSetBool('crashlytics_enabled', false);

111

112

// Set string preference

113

await preferencesSetString('user_segment', 'premium');

114

await preferencesSetString('app_version', '1.2.3');

115

116

// Verify preferences were set

117

const updatedPrefs = await preferencesGetAll();

118

console.log('Updated preferences:', updatedPrefs);

119

120

// Clear all preferences

121

await preferencesClearAll();

122

console.log('All preferences cleared');

123

```

124

125

## Data Types

126

127

All native integration functions return or accept simple data types:

128

129

- **String values**: Used for configuration keys, preference values, and text-based metadata

130

- **Boolean values**: Used for feature flags, enabled/disabled states

131

- **Key-value objects**: All getter functions return objects with string keys and string/boolean values

132

133

## Platform Considerations

134

135

### iOS Specific

136

- Metadata comes from Info.plist file

137

- Preferences stored in NSUserDefaults

138

- Some Firebase configuration may be iOS-specific

139

140

### Android Specific

141

- Metadata comes from AndroidManifest.xml file

142

- Preferences stored in SharedPreferences

143

- Some Firebase configuration may be Android-specific

144

145

### Cross-Platform Usage

146

```typescript

147

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

148

import { Platform } from 'react-native';

149

150

// Platform-aware configuration

151

const metadata = await metaGetAll();

152

153

if (Platform.OS === 'ios') {

154

// iOS-specific handling

155

const iosSpecificKey = metadata.ios_specific_config;

156

} else if (Platform.OS === 'android') {

157

// Android-specific handling

158

const androidSpecificKey = metadata.android_specific_config;

159

}

160

161

// Set platform-appropriate preferences

162

await preferencesSetBool(`${Platform.OS}_feature_enabled`, true);

163

```

164

165

## Common Use Cases

166

167

### Feature Flag Management

168

```typescript

169

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

170

171

// Check if feature is enabled

172

const prefs = await preferencesGetAll();

173

const featureEnabled = prefs.new_feature_enabled === true;

174

175

if (featureEnabled) {

176

// Enable new feature

177

} else {

178

// Use legacy implementation

179

}

180

181

// Enable feature after user opts in

182

await preferencesSetBool('new_feature_enabled', true);

183

```

184

185

### Configuration Storage

186

```typescript

187

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

188

189

// Store user configuration

190

await preferencesSetString('api_endpoint', 'https://api.example.com');

191

await preferencesSetString('environment', 'production');

192

193

// Retrieve configuration later

194

const prefs = await preferencesGetAll();

195

const apiEndpoint = prefs.api_endpoint;

196

const environment = prefs.environment;

197

```

198

199

### Debug Configuration Access

200

```typescript

201

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

202

203

// Get debug information

204

const firebaseConfig = await jsonGetAll();

205

const nativeMetadata = await metaGetAll();

206

207

console.log('Firebase Configuration:');

208

console.log(JSON.stringify(firebaseConfig, null, 2));

209

210

console.log('Native Metadata:');

211

console.log(JSON.stringify(nativeMetadata, null, 2));

212

```