Skip to content

Commit 494bcdb

Browse files
authored
Update README.md
1 parent 0ff933c commit 494bcdb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,14 +981,16 @@ Since iOS 15.0, it's impossible to request this this permission if the app isn't
981981

982982
```js
983983
useEffect(() => {
984-
const listener = AppState.addEventListener('change', (status) => {
985-
if (Platform.OS === 'ios' && status === 'active') {
984+
const callback = (status: AppStateStatus) => {
985+
if (status === "active") {
986986
request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY)
987987
.then((result) => console.log(result))
988988
.catch((error) => console.log(error));
989989
}
990-
});
990+
};
991991

992+
callback(AppState.currentState); // initial call
993+
const listener = AppState.addEventListener("change", callback);
992994
return listener.remove;
993995
}, []);
994996
```

0 commit comments

Comments
 (0)