Skip to content

Commit 9874235

Browse files
committed
docs(app-check): change docs to modular API
1 parent f7de375 commit 9874235

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

docs/app-check/usage/index.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ So AppCheck module initialization is done in two steps in react-native-firebase
149149
To configure the react-native-firebase custom provider, first obtain one, then configure it according to the providers you want to use on each platform.
150150

151151
```javascript
152-
rnfbProvider = firebase.appCheck().newReactNativeFirebaseAppCheckProvider();
152+
import { ReactNativeFirebaseAppCheckProvider } from `@react-native-firebase/app-check`;
153+
154+
rnfbProvider = new ReactNativeFirebaseAppCheckProvider();
153155
rnfbProvider.configure({
154156
android: {
155157
provider: __DEV__ ? 'debug' : 'playIntegrity',
@@ -168,19 +170,24 @@ rnfbProvider.configure({
168170

169171
### Install the Custom Provider
170172

171-
Once you have the custom provider configured, install it in app-check using the firebase-js-sdk compatible API:
173+
Once you have the custom provider configured, install it in app-check using the firebase-js-sdk compatible API, while saving the returned instance for usage:
172174

173175
```javascript
174-
firebase.appCheck().initializeAppCheck({ provider: rnfbProvider, isTokenAutoRefreshEnabled: true });
176+
import { initializeAppCheck } from `@react-native-firebase/app-check`;
177+
178+
const appCheck = initializeAppCheck({ provider: rnfbProvider, isTokenAutoRefreshEnabled: true });
175179
```
176180

177181
### Verify AppCheck was initialized correctly
178182

179183
After initializing the custom provider, you can verify AppCheck is working by logging a response from the token server:
180184

181185
```javascript
186+
import { getToken } from `@react-native-firebase/app-check`;
187+
182188
try {
183-
const { token } = await firebase.appCheck().getToken(true);
189+
// `appCheckInstance` is the saved return value from initializeAppCheck
190+
const { token } = await appCheckInstance.getToken( true);
184191

185192
if (token.length > 0) {
186193
console.log('AppCheck verification passed');

0 commit comments

Comments
 (0)