Skip to content

Commit b98bdf0

Browse files
committed
Move ATT doc
1 parent b1e6cd9 commit b98bdf0

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,6 @@ pre_install do |installer|
146146
end
147147
```
148148

149-
#### Workaround for "App Tracking Transparency not requestable on mount, starting at iOS 15.0" issue:
150-
151-
On iOS 15.0+ requesting App Tracking Transparency does not seem to work on mount (see [#648](https://github.com/zoontek/react-native-permissions/issues/648)). We can work around this by listening for app state change, and then requesting it when the app becomes `'active'`:
152-
153-
```js
154-
useEffect(() => {
155-
const listener = AppState.addEventListener("change", (status) => {
156-
if (Platform.OS === "ios" && status === "active") {
157-
request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY)
158-
.then((result) => console.log(result))
159-
.catch((error) => console.log(error));
160-
}
161-
});
162-
163-
return listener.remove;
164-
}, []);
165-
```
166-
167149
### Android
168150

169151
Add all wanted permissions to your app `android/app/src/main/AndroidManifest.xml` file:
@@ -490,7 +472,6 @@ PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE;
490472
PERMISSIONS.ANDROID.BLUETOOTH_CONNECT;
491473
PERMISSIONS.ANDROID.BLUETOOTH_SCAN;
492474
PERMISSIONS.ANDROID.BLUETOOTH_ADVERTISE;
493-
494475
```
495476

496477
</details>
@@ -949,7 +930,7 @@ requestLocationAccuracy({purposeKey: 'YOUR-PURPOSE-KEY'})
949930
.catch(() => console.warn('Cannot request location accuracy'));
950931
```
951932

952-
### About iOS LOCATION_ALWAYS permission
933+
### About iOS `LOCATION_ALWAYS` permission
953934

954935
If you are requesting `PERMISSIONS.IOS.LOCATION_ALWAYS`, there won't be a `Always Allow` button in the system dialog. Only `Allow Once`, `Allow While Using App` and `Don't Allow`. This is expected behaviour, check the [Apple Developer Docs](https://developer.apple.com/documentation/corelocation/cllocationmanager/1620551-requestalwaysauthorization#3578736).
955936

@@ -959,6 +940,24 @@ When requesting `PERMISSIONS.IOS.LOCATION_ALWAYS`, if the user choose `Allow Whi
959940

960941
Subsequently, if you are requesting `LOCATION_ALWAYS` permission, there is no need to request `LOCATION_WHEN_IN_USE`. If the user accepts, `LOCATION_WHEN_IN_USE` will be granted too. If the user denies, `LOCATION_WHEN_IN_USE` will be denied too.
961942

943+
### How to request "App Tracking Transparency" permission on iOS
944+
945+
Since iOS 15.0, it's impossible to request this this permission if the app isn't `active` (see [#648](https://github.com/zoontek/react-native-permissions/issues/648)). A good solution is to use `AppState` to make sure this is the case:
946+
947+
```js
948+
useEffect(() => {
949+
const listener = AppState.addEventListener('change', (status) => {
950+
if (Platform.OS === 'ios' && status === 'active') {
951+
request(PERMISSIONS.IOS.APP_TRACKING_TRANSPARENCY)
952+
.then((result) => console.log(result))
953+
.catch((error) => console.log(error));
954+
}
955+
});
956+
957+
return listener.remove;
958+
}, []);
959+
```
960+
962961
### Testing with Jest
963962

964963
If you don't already have a Jest setup file configured, please add the following to your Jest configuration file and create the new `jest.setup.js` file in project root:

0 commit comments

Comments
 (0)