sparrowcode / PermissionsKit

Universal API for request permission and get its statuses.
https://x.com/sparrowcode_ios
MIT License
5.64k stars 462 forks source link

SPPermission.isAllow changes only after app restart. #82

Closed mcg95 closed 5 years ago

mcg95 commented 5 years ago

Hi,

I am trying to make sure that the Permission Request only comes up if the permissions required are set to false. But even after I provide the permissions, the SPPermission.isAllow for each respective permission is still false. Only if I restart the app it becomes true.

Any clue as to why I have to restart for the SPPermission.isAllow changes its bool value from false to true?

Thanks.

ivanvorobei commented 5 years ago

What permissions is the problem for? For all?

mcg95 commented 5 years ago

All of them. I am currently using it to allow Camera, Location and Notification. SPPermission.isAllow returns false for all three of them. I tested this by adding a print statement in the didAllow function in the SPPermissionDialogDelegate. All three returned false after tapping on the Allow button for all three. The buttons are also showing allowed. Once I restart the app, they are all true like they should be. Allowing notifications permission also retrieves my APNS token. So I think they work, but the bool value does not update.

ivanvorobei commented 5 years ago

@mcg95 I am added print func to example project and all work correctly.

func didAllow(permission: SPPermissionType) {

        if SPPermission.isAllow(permission) {
            print("all work")
        }
 }
mcg95 commented 5 years ago

Got it working. I assigned the bool value to my own variable to check if it was true or not. That did not work. But I just used SPPermission.isAllow(.camera) to check if its allowed or not and it worked. Thanks for your help! Looking forward to the update which will allow change colours of the buttons and UI.