Comments (4)
Closed as v4.0.0 is out.
from react-native-permissions.
This indeed makes no sense, as denied
is returned when the status is ATTrackingManagerAuthorizationStatusNotDetermined
, and it should not be possible after a request.
from react-native-permissions.
My colleague has patched this, which seems to bring our analytics back in line with what we'd expect. After this patch we are now back to only getting blocked
or granted
returned from request
, at the ratio we would expect. I'm not entirely how this fixed it, but sharing their code below...
diff --git a/node_modules/react-native-permissions/ios/AppTrackingTransparency/RNPermissionHandlerAppTrackingTransparency.m b/node_modules/react-native-permissions/ios/AppTrackingTransparency/RNPermissionHandlerAppTrackingTransparency.m
index c492b3f..46f3e8b 100644
--- a/node_modules/react-native-permissions/ios/AppTrackingTransparency/RNPermissionHandlerAppTrackingTransparency.m
+++ b/node_modules/react-native-permissions/ios/AppTrackingTransparency/RNPermissionHandlerAppTrackingTransparency.m
@@ -50,13 +50,22 @@ - (void)requestWithResolver:(void (^ _Nonnull)(RNPermissionStatus))resolve
}
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive) {
- [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(__unused ATTrackingManagerAuthorizationStatus status) {
- [self checkWithResolver:resolve rejecter:reject];
+
+ [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
+ switch (status) {
+ case ATTrackingManagerAuthorizationStatusNotDetermined:
+ return resolve(RNPermissionStatusNotDetermined);
+ case ATTrackingManagerAuthorizationStatusRestricted:
+ return resolve(RNPermissionStatusRestricted);
+ case ATTrackingManagerAuthorizationStatusDenied:
+ return resolve(RNPermissionStatusDenied);
+ case ATTrackingManagerAuthorizationStatusAuthorized:
+ return resolve(RNPermissionStatusAuthorized);
+ }
}];
} else {
_resolve = resolve;
_reject = reject;
-
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onApplicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
@@ -71,10 +80,18 @@ - (void)onApplicationDidBecomeActive:(__unused NSNotification *)notification {
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIApplicationDidBecomeActiveNotification
object:nil];
-
if (@available(iOS 14.0, *)) {
- [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(__unused ATTrackingManagerAuthorizationStatus status) {
- [self checkWithResolver:self->_resolve rejecter:self->_reject];
+ [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
+ switch (status) {
+ case ATTrackingManagerAuthorizationStatusNotDetermined:
+ return self->_resolve(RNPermissionStatusNotDetermined);
+ case ATTrackingManagerAuthorizationStatusRestricted:
+ return self->_resolve(RNPermissionStatusRestricted);
+ case ATTrackingManagerAuthorizationStatusDenied:
+ return self->_resolve(RNPermissionStatusDenied);
+ case ATTrackingManagerAuthorizationStatusAuthorized:
+ return self->_resolve(RNPermissionStatusAuthorized);
+ }
}];
}
}
from react-native-permissions.
For that patch to be effective, either the "ios14 is not available" branch is taken in checkWithResolver
resulting in nothing but authorized or denied:
or the ios14-is-available branch is taken and the dynamic call for tracking status is somehow returning something different then the status sent in via the callback sent in with the request?
Here's the dynamic callback:
...because the result of that callback is doing the same switch you've effectively inlined in the callback definition
It would be very interesting to know which of the ios14-is-available conditional branches were used and to know if the dynamic call for status was somehow different then the status provided as a parameter to the callback.
You have a working solution which you likely don't want to mess with and possibly cause a regression, but it could be possible to maybe call check
instead of request
in addition to see what check says - emulating the dynamic call. Is it safe to assume ios14-is-available is returning the correct value? I think so
That all seems unexpected though, I'm pretty confused how this is happening, doesn't seem like it should unless the request status vs the dynamic check status is racy somehow in ios17 with check providing a stale value for some unknown amount of time while the callback status is fresh 🤷
from react-native-permissions.
Related Issues (20)
- Expo plugin not working on Expo SDK 50 HOT 2
- config plugin is malform HOT 1
- 'RNPermissionsModule' could not be found HOT 4
- Unregister for remote notifications method HOT 3
- IOS Podfile Problem HOT 3
- iOS microphone permission pop up not appearing on simulator HOT 6
- [Android]: Failed to build gradle in monorepo. Unable to resolve react-native location in node_modules HOT 3
- iOS Build failed HOT 2
- After user change setting permission to None. Check permission PERMISSIONS.IOS.PHOTO_LIBRARY / MEDIA_LIBRARY got UNAVAILABLE not DENIED HOT 2
- iOS: check location permission returns 'blocked' when permission is granted but location services are disabled HOT 6
- Cannot read properties of undefined (reading 'iosPermissions')
- Syntax Error in Setup? HOT 5
- [Android] App crashed totally after call `request()` function when `minifyEnabled` is `true` HOT 3
- [Android 13-14] App crash at requestNotifications(['alert', 'sound']) HOT 1
- Request APP_TRACKING_TRANSPARENCY always return 'blocked' before user accept request HOT 6
- Notification Permission In Android HOT 3
- I encountered an error message stating 'ENOENT: no such file or directory HOT 4
- AVAudioApplication build fail HOT 3
- Invalid `Podfile` file: undefined method `prepare_react_native_project!' HOT 1
- jest testing: waitForNextUdpate times out on checkPermissions HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-permissions.