TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Mar 2016 |
SPMSupports SPM | ✗ |
Maintained by Bell App Lab.
import Permissionable
class ViewController: UIViewController {
func askPermission() {
Permissions.Camera.request(self) { (success: Bool) -> Void in
if success {
print("\o/")
}
}
}
func askForPushPermission() {
Permissions.Push.request(self, categories) { (success: Bool) -> Void in
if success {
print("\o/")
}
}
}
}
//===================================================
import Permissionable
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
{...}
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
Permissions.didFinishRegisteringForPushNotifications(error)
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
//Do domething with the token
Permissions.didFinishRegisteringForPushNotifications(nil)
}
}
//===================================================
import Permissionable
class UserHandler {
func logout() {
Permissions.reset()
}
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
To localize this library, make sure you include the following entries in your Localizable.strings file:
"Yes" = "<Your translation>";
"No" = "<Your translation>";
"Please" = "<Your translation>"; //Default alert title
"Would you mind if we send you push notifications?" = "<Your translation>"; //Default message for push notifications
"Would you mind if we access your camera?" = "<Your translation>"; //Default message for the device's camera
"Would you mind if we access your photos?" = "<Your translation>"; //Default message for the user's photos
"Uh oh" = "<Your translation>"; //Default alert title for when things go wrong
"Looks like we can't access the camera... Would you like to go to the Settings app to check?" = "<Your translation>"; //Default message to prompt the user to fix a permission on the Settings app
"Looks like we can't access your photos... Would you like to go to the Settings app to check?" = "<Your translation>"; //Default message to prompt the user to fix a permission on the Settings app
iOS 8+
Permissionable is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Permissionable"
Please note that this will install all possible permissions (and their related libraries as well), bloating up your app’s dependencies. Take a look at the commands below to find one that suits your needs:
pod "Permissionable/Camera"
pod "Permissionable/Photos"
Bell App Lab, [email protected]
Permissionable is available under the MIT license. See the LICENSE file for more info.