Permissionable 0.5.1

Permissionable 0.5.1

测试已测试
语言语言 SwiftSwift
许可 MIT
发布上次发布2016年3月
SPM支持SPM

Bell App Lab维护。



Permissionable

用法

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()
    }
}

要运行示例项目,请克隆该仓库,并首先从示例目录中运行pod install

本地化

要将此库本地化,请确保在您的Localizable.strings文件中包含以下条目:

"Yes" = "<您的翻译>";

"No" = "<您的翻译>";

"Please" = "<您的翻译>"; //默认提示标题

"Would you mind if we send you push notifications?" = "<您的翻译>"; //推送通知的默认消息

"Would you mind if we access your camera?" = "<您的翻译>"; //设备摄像头的默认消息

"Would you mind if we access your photos?" = "<您的翻译>"; //用户照片的默认消息

"Uh oh" = "<您的翻译>"; //出错时的默认提示标题

"Looks like we can't access the camera... Would you like to go to the Settings app to check?" = "<您的翻译>"; //提示用户到设置应用检查权限的默认消息

"Looks like we can't access your photos... Would you like to go to the Settings app to check?" = "<您的翻译>"; //提示用户到设置应用检查权限的默认消息

要求

iOS 8+

安装

Permissionable可通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中即可

pod "Permissionable"

请注意这将安装所有可能的权限(以及它们相关的库),这将增加您应用的依赖项。查看以下命令以找到一个适合您需求的命令

pod "Permissionable/Camera"
pod "Permissionable/Photos"

作者

Bell App Lab,[email protected]

许可

Permissionable基于MIT许可。有关更多信息,请参阅LICENSE文件。