nickoneill / PermissionScope

Intelligent iOS permissions UI and unified API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call .show 's callback immediately.

pjebs opened this issue · comments

commented

My app required 2 permission (Camera, Microphone).
The app is has a login screen (password etc) and the app has no value without camera and microphone permissions.

For this reason, I show PermissionScope after logging on but before the main screen. I checked the callback: pscope.show({(finished, results) -> Void in and if finished == true, I proceeded to the next screen. If not, I stay on the PermissionScope dialog until either cancellation (back to login) or full permissions are given..

You have told me in the past that you designed the dialog box more as an "optional" gate so if user cancels, they should be able to proceed to next screen. For me camera and microphone is required.

Apple has allowed this for me. Your library worked well in this scenario.

....

Now I require notification permission too. Under the guidelines: (Design - 4.5.4 - Push notifications must be optional) there is a complication.

        pscope.addPermission(NotificationsPermission(notificationCategories: nil), message: NSLocalizedString("A (suggested)", comment: ""))
        pscope.addPermission(CameraPermission(), message: NSLocalizedString("B (required)", comment: ""))
        pscope.addPermission(MicrophonePermission(), message: NSLocalizedString("C (required)", comment: ""))
        pscope.show({ [unowned self] (finished, results) -> Void in
            //Allow customer to proceed if Camera and Microphone permission given. Notifications Permission is optional.
            if (results[1].status == .Authorized && results[2].status == .Authorized) {
                pscope.hide()
                if results[0].status == .Authorized {
                   ///Do extra setup for notifications setup
                }

                   //Now perform code to show next screen since Camera and Microphone is approved
           }
commented

The issue is I can't use the finished value because Notifications must be optional.
I want to keep the Notifications permission in menu so if user grants it, it's a nice bonus. But if they don't, but they grant Camera and Microphone, I can then proceed.

The problem is after the show method, your library doesn't immediately call the callback. It waits for a change in authorization EXCEPT in the SPECIAL CASE that authorization is given to all and hence finished = true.

My suggestion is that it immediately calls the callback. That way if user has granted camera and microphone, at least I can immediately test for it and proceed. I feel the special case is ad hoc

I'm not sure if there are any backward incompatibilities but it does provide this extra use-case.

Thanks for the note @pjebs. I usually encourage people to ask for notifications permission in the context of asking a user if they want feedback (i.e. after they post a comment "do you want to be notified of replies?") rather than entirely upfront. There's no great way for us to show a permissionscope dialog where just one permission is optional and users don't like being asked for notification permissions upfront either.