Sudhanshudwivedi / AllowX

AllowX is a zero setup and unified API to ask for permissions on iOS β“πŸ‘€

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AllowX

Cocoapod Version MIT License
Facebook: @KarimEbrahemAbdelaziz Twitter: @k_ebrahem_

AllowX exposes a unified API to request permissions on iOS with awesome dialog for permssion requests.

Screenshots

Requirements

  • Xcode 10.2+
  • Swift 5+
  • iOS 10+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate AllowX into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'AllowX', '~> 1.0.2'

Usage

AllowX supports 3 kinds of permissions (for now).

// AllowX Camera Permission.
let cameraPermission: AllowX = AllowX(type: .camera)

// AllowX Location Always Permission.
let locationAlwaysPermission: AllowX = AllowX(type: .locationAlways)

// AllowX Location While in Use Permission.
let locationWhileInUsePermission: AllowX = AllowX(type: .locationWhenInUse)

// AllowX Notifications Permission.
let notificationsPermission: AllowX = AllowX(type: .notifications([.alert, .badge, .sound]))

There are defaults for every value in the permission dialog, but you can change all of them using these properties:

// AllowX Permission Alert Height.
// The default value is .intrinsic to adapt on the content.
cameraPermission.alertHeight = .constant(value: 400)

// AllowX Permission Dialog Image.
cameraPermission.image = UIImage(named: "camera")

// AllowX Permission Dialog Title.
cameraPermission.title = "Camera Custom Access"

// AllowX Permission Dialog Message.
cameraPermission.message = "Please give us permission to capture your awesome moments."

// AllowX Permission Dialog Cancel Button's Title.
cameraPermission.cancelButtonTitle = "Cancel"

// AllowX Permission Dialog NotNow Button's Title.
cameraPermission.notNowButtonTitle = "Not now"

// AllowX Permission Dialog Go to Settings Button's Title.
cameraPermission.goToSettingsButtonTitle = "Go to Settings"

// AllowX Permission Dialog Confirm Button's Title.
cameraPermission.confirmButtonTitle = "Allow Permission"

By default AllowX will ask for permission and present corresponding dialog for the permission's status, but you can disable presenting those dialogs

// Control if you want to present Pre-Premission dialog.
cameraPermission.presentPrePermissionAlert = true

// Control if you want to present Denied dialog.
cameraPermission.presentDeniedAlert = true

// Control if you want to present Disabled dialog.
cameraPermission.presentDisabledAlert = true

You can specifiy a block of code to be excuted when you ask about permission's status

// Ask for Premission πŸ”₯
cameraPermission.request { status in
    switch status {
    case .authorized:    print("authorized")
    case .denied:        print("denied")
    case .disabled:      print("disabled")
    case .notDetermined: print("not determined")
    }
}

Author

Karim Ebrahem, karimabdelazizmansour@gmail.com

License

AllowX is available under the MIT license. See the LICENSE file for more info.

It will be updated when necessary and fixes will be done as soon as discovered to keep it up to date.

Enjoy!

About

AllowX is a zero setup and unified API to ask for permissions on iOS β“πŸ‘€

License:MIT License


Languages

Language:Swift 97.3%Language:Ruby 2.7%