Skip to content

Latest commit

 

History

History
140 lines (102 loc) · 5.8 KB

README.md

File metadata and controls

140 lines (102 loc) · 5.8 KB

About

This project is about managing permissions with the customizable visual effects. Beautiful dialog increases the chance of approval (which is important when we request notification). Simple control of this module saves you hours of development. You can start using this project with just two lines of code and easy customization! You can see how I am designed UI and how use pod tutorial on youtube

Preview GIF loading 4mb. Please, wait

The project is absolutely free, but but it takes time to support and update it. Your support is very motivating and very important. I often receive emails asking me to update or add functionality. Small donate for a cup of coffee helps to develop the project and make it better

Requirements

Swift 4.2. Ready for use on iOS 10+

Integration

Drop in source/sparrow folder to your Xcode project. Make sure to enable Copy items if needed and Create groups

Or via CocoaPods:

pod 'SPPermission'

and import library in class:

import SparrowKit

How to use

Call SPPermission and use func request(). Also passed controller, on which dialog should present

import UIKit
import SparrowKit

class ViewController: UIViewController {

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        SPPermission.Dialog.request(with: [.camera, .microphone, .notification], on: self)
    }
}

If you want to know if permission allowed, you should call the function:

let isAvailableCamera = SPPermission.isAllow(.сamera)

How customize titles and images you can read section DataSource & Customization

Permissions

Also now supported MediaLibrary (Apple Music) permission

If you want to request notification (or other permissions) without dialog, use the function:

SPPermission.request(.notification, with: {
    //callback
})

Notification permission should be tested only on a real device. If you want to add new permission, create a new issue here

Delegate

To track events hide & allowed permission associated with SPPermission, implement the protocol SPPermissionDialogDelegate

@objc public protocol SPPermissionDialogDelegate: class {
    
    @objc optional func didHide()
    @objc optional func didAllow(permission: SPPermissionType)
}

And pass the delegate to the function:

SPPermission.Dialog.request(
    with: [.calendar, .microphone],
    on: self,
    delegate: self
)

DataSource & Customization

If you want to change the text, you need to implement the SPPermissionDialogDataSource protocol. Override the needed parameters to see the changes

@objc public protocol SPPermissionDialogDataSource: class {

    @objc optional var dialogTitle: String { get }
    @objc optional var dialogSubtitle: String { get }
    @objc optional var dialogComment: String { get }
    @objc optional var allowTitle: String { get }
    @objc optional var allowedTitle: String { get }
    @objc optional var bottomComment: String { get }
    @objc optional var showCloseButton: Bool { get }
    @objc optional func name(for permission: SPPermissionType) -> String?
    @objc optional func description(for permission: SPPermissionType) -> String?
    @objc optional func image(for permission: SPPermissionType) -> UIImage?
}

And pass the object to the function:

SPPermission.Dialog.request(
    with: [.photoLibrary, .contacts],
    on: self,
    delegate: self,
    dataSource: self
)

If you want add or remove close button (for close dialog, need swipe it), you need override parametr showCloseButton. How it will look look at the picture below:

In the project you can find an example for usage SPPermissionDialogDataSource

Apps, using lib

I like the idea to specify applications that use the SPPermission. Please, contact me via email. You can find it in the section Contacts so that I added app here

For Russian-speaking users

Вы можете глянуть туториал на youtube или почитать статью на хабре, чтобы больше узнать о проекте

License

SPPermission is released under the MIT license. Check LICENSE.md for details

Contact

If you need develop application or UI, write me to hello@ivanvorobei.by. I am develop design and ios apps. I am use swift. If you want to ask for more functionality, you should create a new issue

hello.ivanvorobei.by & ivanvorobei.by

My apps in AppStore & in AppStore 2