All Projects → varabeis → Sppermissions

varabeis / Sppermissions

Licence: mit
Ask permissions with ready-use interface. You can check status permission and if it has been requested before. Support SwiftUI.

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Sppermissions

ios-permissions-service
An easy way to do permissions requests & handling automatically.
Stars: ✭ 25 (-99.47%)
Mutual labels:  camera, calendar, permissions
CustomPermissionsDialogue
Custom Permissions Dialogue is the only permissions library that supports ALL permission request scenarios. This library handles multiple edge cases such as not enabling all permissions or permanently rejecting a permission request.
Stars: ✭ 51 (-98.92%)
Mutual labels:  permissions, dialog, permission
LocationFetcher
Easy Location fetching for Android apps.
Stars: ✭ 33 (-99.3%)
Mutual labels:  location, permissions
PermissionManager
android6.0之后开始会有权限使用的问题。这个项目演示了如何在代码中动态申请权限。尤其是"存储"这一个在6.0之前不需要申请的权限,本项目以这个作为例子。
Stars: ✭ 21 (-99.55%)
Mutual labels:  permissions, permission
thymeflow
Installer for Thymeflow, a personal knowledge management system.
Stars: ✭ 27 (-99.43%)
Mutual labels:  calendar, location
HeimGuard
🛡 A simple library that allows you to easily manage permissions in your .NET projects.
Stars: ✭ 77 (-98.36%)
Mutual labels:  permissions, permission
denbun
Adjust showing frequency of Android app messages, and to be more user friendly 🐦
Stars: ✭ 17 (-99.64%)
Mutual labels:  dialog, notification
servie
Standard, framework-agnostic HTTP interfaces for JavaScript servers and clients
Stars: ✭ 39 (-99.17%)
Mutual labels:  interface, request
QuickRawPicker
📷 QuickRawPicker is a free and open source program that lets you cull, pick or rate raw photos captured by your camera. It is also compatible with the XMP sidecar file used by Adobe Bridge/Lightroom/Darktable or PP3 sidecar file used by Rawtherapee.
Stars: ✭ 26 (-99.45%)
Mutual labels:  camera, photo-gallery
Md Date Time Picker
An implementation of Material Design Picker components in vanilla CSS, JS, and HTML
Stars: ✭ 272 (-94.21%)
Mutual labels:  calendar, dialog
google streetview
A command line tool and module for Google Street View Image API
Stars: ✭ 77 (-98.36%)
Mutual labels:  interface, location
Stevia
🍃 Concise Autolayout code
Stars: ✭ 3,182 (-32.31%)
Mutual labels:  xcode, interface
ccalendar
Chinese Calendar in calendar(1) for BSD, Linux & macOS
Stars: ✭ 17 (-99.64%)
Mutual labels:  reminder, calendar
Vision CoreML-App
This app predicts the age of a person from the picture input using camera or photos gallery. The app uses Core ML framework of iOS for the predictions. The Vision library of CoreML is used here. The trained model fed to the system is AgeNet.
Stars: ✭ 15 (-99.68%)
Mutual labels:  camera, photo-gallery
flutter examples
Random flutter examples
Stars: ✭ 18 (-99.62%)
Mutual labels:  location, dialog
silly-android
Android plugins for Java, making core Android APIs easy to use
Stars: ✭ 40 (-99.15%)
Mutual labels:  dialog, permission
easypermissions-ktx
🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.
Stars: ✭ 324 (-93.11%)
Mutual labels:  permissions, permission
rx-postmessenger
Minimal RxJS adapter for the window.postMessage API for request-response streams and notification streams across frame windows.
Stars: ✭ 27 (-99.43%)
Mutual labels:  request, notification
ReminderPro
ReminderPro(location, note, voice recording)
Stars: ✭ 27 (-99.43%)
Mutual labels:  reminder, location
Netfox
A lightweight, one line setup, iOS / OSX network debugging library! 🦊
Stars: ✭ 3,188 (-32.18%)
Mutual labels:  xcode, request

SPPermissions

Availalbe three ready-use interface - list, dialog & native. Supports iPad, dark mode and has ready localizations. Also you can check state of permissions, available are .authorized, .denied & .notDetermined.

Supported Permissions

Navigate

Installation

Ready to use on iOS 11+, and supports iOS, tvOS, and SwiftUI.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

Once you have your Swift package set up, adding as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/ivanvorobei/SPPermissions", .upToNextMajor(from: "7.0.1"))
]

Next choose the permissions you need. But don't add all of them, because apple will reject app.

CocoaPods:

CocoaPods is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your Podfile:

pod 'SPPermissions/Notification'

Due to Apple's new policy regarding permission access you need to specifically define what kind of permissions you want to access using subspecs. For example if you want to access Camera, Location & Microphone you define the following:

pod 'SPPermissions/Camera'
pod 'SPPermissions/LocationAlways'
pod 'SPPermissions/Microphone'
Subspecs

pod 'SPPermissions/Camera'
pod 'SPPermissions/Contacts'
pod 'SPPermissions/Calendar'
pod 'SPPermissions/PhotoLibrary'
pod 'SPPermissions/Notification'
pod 'SPPermissions/Microphone'
pod 'SPPermissions/Reminders'
pod 'SPPermissions/SpeechRecognizer'
pod 'SPPermissions/LocationWhenInUse'
pod 'SPPermissions/LocationAlways'
pod 'SPPermissions/Motion'
pod 'SPPermissions/Music'
pod 'SPPermissions/Bluetooth'
pod 'SPPermissions/Tracking'
pod 'SPPermissions/FaceID'
pod 'SPPermissions/Siri'
pod 'SPPermissions/Health'

Manually

If you prefer not to use any of dependency managers, you can integrate SPPermissions manually. Copy code and add compile flags from CONTRIBUTING.md file.

Imports

If you install via Swift Package Manager, you shoud import each module:

import SPPermissions
import SPPermissionsCamera
import SPPermissionsPhotoLibrary

It's required because library split to modules. After importing you'll see available permissions by typing SPPermissions.Permission.camera for example. If you install via CocoaPods, you only need to import one class:

import SPPermissions

All other installed classes imported automatically.

Quick Start

// MARK: 1. Choose the permissions you need:

let permissions: [SPPermissions.Permission] = [.camera, .notification]

// MARK: 2. Choose present style:

// 2a. List Style
let controller = SPPermissions.list(permissions)
controller.present(on: self)

// 2b. Dialog Style
let controller = SPPermissions.dialog(permissions)
controller.present(on: self)

// 2c. Native Style
let controller = SPPermissions.native(permissions)
controller.present(on: self)

// MARK: 3. Optional: Check permission state (available `authorized`, `denied`, `notDetermined`):

let authorized = SPPermissions.Permission.calendar.authorized

For more details see Request section.

Status

To check the state of any permission, call SPPermissions.Permission:

let authorized = SPPermissions.Permission.calendar.authorized

Also available are status for denied & notDetermined.

Request

SPPermissions has three presentation styles: Dialog, List and Native. Each interface has delegates and a data source. If you want see an example app, open Example Apps/SPPermissions.xcodeproj.

List

It's native UITableViewController. Use it when you have more than two permissions. An example of how it is used:

let controller = SPPermissions.list([.calendar, .camera, .contacts])

// Ovveride texts in controller
controller.titleText = "Title Text"
controller.headerText = "Header Text"
controller.footerText = "Footer Text"

// Set `DataSource` or `Delegate` if need. 
// By default using project texts and icons.
controller.dataSource = self
controller.delegate = self

// If you want auto dismiss controler,
// when all permissions has any determinated state
// set dismiss mode `allPermissionsDeterminated`.
// By default dismiss controller happen only when all permission allowed.
controller.dismissCondition = .allPermissionsDeterminated

// Always use this method for present
controller.present(on: self)

Dialog

This is a modal alert. I recommend using this alert style when you have less than three requested permissions. Usage example:

let controller = SPPermissions.dialog([.camera, .photoLibrary])

// Override texts in controller
controller.titleText = "Title Text"
controller.headerText = "Header Text"
controller.footerText = "Footer Text"

// Set `DataSource` or `Delegate` if need. 
// By default using project texts and icons.
controller.dataSource = self
controller.delegate = self

// If you want auto dismiss controler,
// when all permissions has any determinated state
// set dismiss mode `allPermissionsDeterminated`.
// By default dismiss controller happen only when all permission allowed.
controller.dismissCondition = .allPermissionsDeterminated

// Always use this method for present
controller.present(on: self)

Native

Request permissions with native UIAlertController. You can request many permissions at once:

let controller = SPPermissions.native([.calendar, .camera, .contacts])

// Set `Delegate` if need. 
controller.delegate = self

// Always use this method for request. 
controller.present(on: self)

DataSource

For data source using protocol SPPermissionsDataSource. You can customize the permission cells and provide denied alert texts.

extension Controller: SPPermissionsDataSource {
    
    func configure(_ cell: SPPermissionsTableViewCell, for permission: SPPermissions.Permission) {
        
        // Here you can customise cell, like texts or colors.
        cell.permissionTitleLabel.text = "Title"
        cell.permissionDescriptionLabel.text = "Description"
        
        // If you need change icon, choose one of this:
        cell.permissionIconView.setPermissionType(.bluetooth)
        cell.permissionIconView.setCustomImage(UIImage.init(named: "custom-name"))
        cell.permissionIconView.setCustomView(YourView())
    }
}

Denied alert

If a permission is denied, you can provide an alert to the user with an option to open settings. An example of how you can customise the alert text:

let texts = SPPermissionsDeniedAlertTexts()
texts.titleText = "Permission denied"
texts.descriptionText = "Please, go to Settings and allow permission."
texts.actionText = "Settings"
texts.cancelText = "Cancel"

Next implement the following method and return:

func deniedAlertTexts(for permission: SPPermissions.Permission) -> SPPermissionsDeniedAlertTexts? {
    
    // Custom texts:
    return texts
    
    // or default texts:
    // return .default
}

Delegate

To get hidden, allowed or denied events , set the delegate with protocol SPPermissionsDelegate:

extension Controller: SPPermissionsDelegate {
    
    func didHidePermissions(_ permissions: [SPPermissions.Permission]) {}
    func didAllowPermission(_ permission: SPPermissions.Permission) {}
    func didDeniedPermission(_ permission: SPPermissions.Permission) {}
}

Localizations

SPPermissions has ready-to-use localizations for:

  • English en
  • Arabic ar
  • German de
  • Spanish es
  • French fr
  • Polish pl
  • Portuguese pt
  • Ukrainian uk
  • Russian ru
  • Chinese Simplified Han zh_Hans
  • Italian it
  • Chinese Traditional zh_Hant

If you want to add more, please, create folder [language_id].lproj and make a pull request. If you want to use your custom strings, check the DataSource section.

Keys in Info.plist

You need to add some keys to the Info.plist file with descriptions, per Apple's requirement(s). You can get a plist of keys for permissions as follows:

let key = SPPermissions.Permission.bluetooth.usageDescriptionKey

List of keys:

  • NSCameraUsageDescription
  • NSContactsUsageDescription
  • NSCalendarsUsageDescription
  • NSMicrophoneUsageDescription
  • NSAppleMusicUsageDescription
  • NSRemindersUsageDescription
  • NSPhotoLibraryUsageDescription
  • NSPhotoLibraryAddUsageDescription
  • NSSpeechRecognitionUsageDescription
  • NSMotionUsageDescription
  • NSLocationWhenInUseUsageDescription
  • NSLocationAlwaysAndWhenInUseUsageDescription
  • NSBluetoothAlwaysUsageDescription
  • NSBluetoothPeripheralUsageDescription (iOS 12 and earlier)
  • NSUserTrackingUsageDescription
  • NSFaceIDUsageDescription
  • NSSiriUsageDescription
  • NSHealthUpdateUsageDescription
  • NSHealthShareUsageDescription

Do not use the description as the name of the key.

If you use xliff localization export, keys will be create automatically. If you prefer do the localization file manually, you need to create InfoPlist.strings, select languages on the right side menu and add keys as keys in plist-file. See:

"NSCameraUsageDescription" = "Here description of usage camera";

Apple Review

Apple changed its review guidelines in June 2021. When requesting permissions, apps should require users to always request and make a decision whether to allow or decline the permission. For this reason, the close button in SPPermissions is hidden by default. If you want to force show the close button, run the following code:

// Show & hide close button
controller.showCloseButton = true

// Enable or Disable drag intercation
controller.allowSwipeDismiss = true

Also changed title for button. Instead of allow now using continue. The Apple Review Team asked for this. For details, check out this issue.

Russian Community

Я веду телеграм-канал, там публикую новости и туториалы.
С проблемой помогут в чате.

Видео-туториалы выклыдываю на YouTube:

Tutorials on YouTube

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].