Hacker News new | ask | show | jobs
by JimDabell 1082 days ago
> on iOS, you cannot distinguish if you were granted a permission or not.

This isn’t correct. For instance, accessing location services provides CLAuthorizationStatus:

https://developer.apple.com/documentation/corelocation/claut...

…and push notifications have UNAuthorizationStatus:

https://developer.apple.com/documentation/usernotifications/...

…and health data has HKAuthorizationStatus:

https://developer.apple.com/documentation/healthkit/hkauthor...

…and contacts has CNAuthorizationStatus:

https://developer.apple.com/documentation/contacts/cnauthori...

…and photos has PHAuthorizationStatus:

https://developer.apple.com/documentation/photokit/phauthori...

Photos is a special case because the user has the option of denying access, giving limited access, or giving full access. You can determine if the user has denied access, but you cannot distinguish between limited access and full access.

2 comments

> but you cannot distinguish between limited access and full access

I believe you can check whether you received limited photos access: https://developer.apple.com/documentation/photokit/phauthori...

Sorry, you’re correct. I was thinking of the case where older applications receive PHAuthorizationStatus.authorized when the user has selected restricted. There are newer APIs to handle the restricted access changes.
I recently tried using Sony's (frustrating) Imaging Edge app to transfer photos from a camera to an iPad and gave it limited access and it refused to transfer images! When I changed the permissions to full access it worked. So there must be some difference, maybe not an obvious one.
Not sure how they do that, but I’d say that on most iPhones in the wild, having the API return <25 images is probably a pretty good indicator that that’s not all pictures.