Giter VIP home page Giter VIP logo

rsattar / clusterprepermissions Goto Github PK

View Code? Open in Web Editor NEW
1.2K 27.0 109.0 88 KB

Cluster's reusable pre-permissions utility that lets developers ask the users on their own dialog for photos or contacts access, before making the system-based request. This is based on the Medium post by Cluster describing the different ways to ask for iOS permissions (https://medium.com/p/96fa4eb54f2c).

License: MIT License

Objective-C 91.79% Ruby 8.21%

clusterprepermissions's Introduction

ClusterPrePermissions

Cluster's reusable pre-permissions utility that lets developers ask the users on their own dialog for photos or contacts access, before making the system-based request. This is based on Cluster's post The Right Way to Ask Users for iOS Permissions.

Supported permissions:
  • Photo Library
  • Camera
  • Microphone
  • Contacts List
  • Events
  • Location

Update

With Apple's new review guidelines, you'll need to include usage descriptions for each of the frameworks that ClusterPrePermissions supports, whether or not you're actually using them. See Issue #34 for more info.

Why use Pre-Permissions?

On iOS, when your code tries to access the Camera Roll or the Address Book, the system automatically shows an alert to the user.

If the user says "Don't Allow" to this alert, you have burned your one-and-only chance to get that access. The user will have to jump through a 5-step process outside of your app to re-enable access, which they will rarely, if ever, do.

Often the user wasn't event expecting the access alert, and by habit will tap "Don't Allow". This is a lose-lose scenario for both you and your user.

At Cluster, we’ve had a lot of success asking for permissions using our own UI before popping the iOS dialogs.

For photos alone, 46% of people who denied access in a pre-permissions dialog ended up granting access when asked at a better time later.

How Pre-Permissions Works

This utility simply wraps your code with a "pre-permission" alert, if needed. When you need to ask for photo access, for example, this utility essentially just asks them twice.

image

Even though it seems annoying to ask twice, at Cluster we almost completely eliminated the possibility of a user tapping “Don’t Allow”, leaving the door open for us to win them back in the future. And for what it’s worth, in live user tests, not a single test subject hesitated (or expressed confusion) when the second dialog appeared.

Adding ClusterPrePermissions to your project

CocoaPods

CocoaPods is the recommended way to add ClusterPrePermissions to your project.

  1. Add a pod entry for ClusterPrePermissions to your Podfile pod 'ClusterPrePermissions', '~> 0.1'
  2. Install the pod(s) by running pod install
  3. Include ClusterPrePermissions wherever you need it with #import <ClusterPrePermissions/ClusterPrePermissions.h>

Source Files

Add ClusterPrePermissions.h and ClusterPrePermissions.m into your project.

  1. Download the latest code, using git clone.
  2. Open your project in Xcode, then drag and drop ClusterPrePermissions.h and ClusterPrePermissions.monto your project (Make sure to select Copy items when asked if you extracted the code archive outside of your project.)
  3. In your classes where you need ClusterPrePermissions, add it with #import "ClusterPrePermissions.h"

Usage

CLPermissions checks the authorization status of photos and contacts, and, given a block callback, will return with the result. If authorization status is "not determined", the utility will show a configurable UIAlertView that asks for "pre-permission" before making the actual system request.

If the authorization status already unchangeable, your block will just be called back. You can check the userDialogResult and systemDialogResult to see what happened. If both are ClusterDialogResultNoActionTaken, then it means the access was already denied or granted by the system.

ClusterPrePermissions *permissions = [ClusterPrePermissions sharedPermissions];
[permissions showPhotoPermissionsWithTitle:@"Access your photos?"
                                   message:@"Your message here"
                           denyButtonTitle:@"Not Now"
                          grantButtonTitle:@"Give Access"
                         completionHandler:^(BOOL hasPermission,
                                             ClusterDialogResult userDialogResult,
                                             ClusterDialogResult systemDialogResult) {
                             if (hasPermission) {
                                 // Continue with your code here
                             } else {
                             	  // Handle access not being available
                             }
                         }];

clusterprepermissions's People

Contributors

asifmujteba avatar bryant1410 avatar confile avatar dmorrow avatar esqarrouth avatar hossamghareeb avatar maml avatar podkovyrin avatar readmecritic avatar rsattar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clusterprepermissions's Issues

kCLAuthorizationStatusAuthorized deprecated in 8.0 SDK

locationAuthorizationStatusPermitsAccess: is referencing a deprecated constant (kCLAuthorizationStatusAuthorized) which causes a compiler warning. Would be nice if this could be fixed (with a check for __IPHONE_8_0 etc.).

Microphone permission not working

It appears that the microphone permission is not working. To reproduce this, I simply modified the PermissionsTestViewController.m file and changed the [permissions showPhotoPermissionsWithTitle...] call to [permissions showMicrophonePermissionsWithTitle...]

No other changes. Now, the UIAlert fires. But no matter which option I select -- 'Not Now' or 'Give Access' -- user action is always denied and system action is always 'no action taken'. And hasPermission is, therefore, always NO.

Any ideas?

Result block is never called when permission was granted or denied before

Here is what I did:

var permissions = ClusterPrePermissions.sharedPermissions()
      permissions.showPhotoPermissionsWithTitle("1Access your photos?", message: "1Your message here", denyButtonTitle: "Not Now", grantButtonTitle: "Give Access") { (hasPermission:Bool, userDialogResult:ClusterDialogResult, systemDialogResult:ClusterDialogResult) -> Void in

        println("result block")

        if hasPermission {
          println("hasPermission")
          // Continue with your code here
        }
        else {
          // Handle access not being available
          println(" no Permission")
        }

      }

The Result block is never called when permission was granted or denied before.

Carthage

Can this be installed via Carthage (in an Objective-C app)?

showPushNotificationPermissions second time is always False

I am using showPushNotificationPermissionsWithType method for a pre-validation of the push notifications.
The first time the method is executed works fine. But if I request again the permission check then, the result is always false.

I changed the
completionHandler((status == ClusterAuthorizationStatusUnDetermined),
to
completionHandler((status == ClusterAuthorizationStatusAuthorized),

and worked for me.

Cluster.Co app update

hello, not sure if I'm in the right place but I use Cluster often.... I noticed there's no update and there hasn't been in 2 years. can we please get an update?

location access still not work?

Hi I have updated ClusterPrePermissions to 0.2 but still got no response while trying to get location access on iOS 8.0.0, it seems that showLocationPermissionsForAuthorizationType does not exist in the cocoapods version.
Anyone else getting this problem?

Deprecation warnings in 9.0?

In my project running 9.0, I imported ClusterPrePermissions, but I got dozens of warnings of deprecations (UIAlertView, ALAuthorizationStatus, ALAssetsLibrary, etc.). I'm not sure how open source code is supposed to deal with OS version changes, so what is the best way to deal with this, and does this warrant an issue in the future? Thanks.

Open Settings if previously denied

If user denies access in system dialog and then tries to use the function that requires permission. ClisterPermissions will not show dialog and return a negative result without interaction.

It is logical in this situation to show the pre-permission dialog and if user tap "Give access" open Settings (UIApplicationOpenSettingsURLString)?
Developer won't have to implement whole opening of UIApplicationOpenSettingsURLString and leave it to ClusterPermissions.

Apple App Store Warning

I received this warning when I recently submitted an app that uses ClusterPrePermissions from the app store:

This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCalendarsUsageDescription key with a string value explaining to the user how the app uses this data.

I'm not using the Calendar permissions at all, I'm only using microphone permissions.

Requesting new release

Hi!
This is a great project, would you make a new tag and push to cocoapods as a new version?
I'm missing the location services permissions from the cocoapods version.

Thanks!

Motion Activity

Hello and thanks for this excellent library.
can you expand this lib to support motion activity pre-permissions?

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.