nickoneill / PermissionScope

Intelligent iOS permissions UI and unified API
MIT License
4.84k stars 506 forks source link

Bug with user disallowing permission #186

Closed pjebs closed 8 years ago

pjebs commented 8 years ago

I have 2 permissions set up: Camera and Notifications.

Camera has permissions. Notifications does not yet. The screen is presented. Say the user clicks on notifications button and rejects permissions.

Say next time, the screen is again presented. The user clicks on notifications button and alert is shown. The user clicks to go to settings.

If the user now disables camera permission and then returns to app, the app crashes.

bre7 commented 8 years ago

Dupe #160 ?

nickoneill commented 8 years ago

I really need to add this to the readme!

This is normal system behavior. If you toggle permissions from the settings screen, apps that have been approved or denied for this permission will be killed by the OS.

bre7 commented 8 years ago

New item in "Known bugs" and maybe add it to the issue template

Update: Done

pjebs commented 8 years ago

There seems to be some inconsistencies: I had denied camera in the past. When the popup comes up, I get taken to the Settings. I allow Camera and go back to app.

The app doesn't crash - BUT it doesn't detect that camera is now allowed. Even if I close popup and open it up again (NB: the app is never terminated), the popup still thinks Camera is denied. When I check settings app, Camera is definitely allowed.

If I restart the app, it correctly recognises that Camera is allowed.

I'm using iOS 9

bre7 commented 8 years ago

Have you printed the return values ? Might be an issue related to the UI instead (check #150 just in case)

pjebs commented 8 years ago

Printed them out from callback:

[Camera Unauthorized, Notifications Unauthorized]

I checked Settings app again - Camera definitely allowed

And also app didn't crash when it got sent back.

When I restarted app, it recognised Camera allowed.

bre7 commented 8 years ago

Try returning the raw value then: AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo)

pjebs commented 8 years ago

By the way, it worked perfectly with Notifications permissions being allowed from settings app and the returning to App.

I think it only crashes if permissions that app already had are denied from permissions app. That also makes more sense from a design perspective.

pjebs commented 8 years ago

AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) returns denied despite settings app showing Authorized.

So it's not the fault of PermissionScope. Perhaps AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) is not the best function to call to test camera permissions?

bre7 commented 8 years ago

AVCaptureDevice.authorizationStatusForMediaType() is the recommended way as far as I remember.

Just to be certain, you are using a device right ? Not the simulator.

pjebs commented 8 years ago

I'm using device. I double checked it. It is the recommended way - it seems to not get changed immediately for the app. Bug with Apple.

Either way, the readme's known bugs section should be changed to reflect that app only crashes when a user reduces the permissions of app from what it already had.

pjebs commented 8 years ago

Here's a twist: All statements above were from tests on a iPhone 6 running iOS 9. The app doesn't crash when the permissions scope is increased.

I tested on iPad running iOS8.3. The app crashes when any permissions are changed, even if permissions are unambiguously expanded. So for camera permissions it is a moot point whether the app accurately detects the authorization when it returns.