Skip to content

Commit e51ebfb

Browse files
docs(app-check, ios): note iOS SDK has no onTokenChanged so is no-op (#8765)
* docs(app-check, iOS): onTokenChanged --------- Co-authored-by: Mike Hardy <[email protected]>
1 parent 1ee744c commit e51ebfb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/app-check/usage/index.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,22 @@ try {
226226
}
227227
```
228228

229+
### Listening for token changes
230+
231+
On Android, you can subscribe to App Check token updates with `onTokenChanged`. On iOS this listener is not implemented yet – subscribing will no-op and log a warning. If you need to react to token changes on iOS, prefer polling `getToken` on demand or rely on automatic refresh.
232+
233+
```javascript
234+
import { onTokenChanged, getToken } from '@react-native-firebase/app-check';
235+
236+
// Android: receives updates. iOS: no-op (native API does not exist on the SDK).
237+
const unsubscribe = onTokenChanged(appCheckInstance, async ({ token }) => {
238+
console.log('App Check token updated:', token);
239+
});
240+
241+
// iOS-friendly approach: request a fresh token when needed
242+
const { token } = await appCheckInstance.getToken(true);
243+
```
244+
229245
## Automatic Data Collection
230246

231247
App Check has an "tokenAutoRefreshEnabled" setting. This may cause App Check to attempt a remote App Check token fetch prior to user consent. In certain scenarios, like those that exist in GDPR-compliant apps running for the first time, this may be unwanted.

0 commit comments

Comments
 (0)