iOS开源 - AREK:干净、易用的 iOS 权限封装库
<p style="text-align:center"><img src="https://simg.open-open.com/show/ff4d738c3d41bf32bd37f88030c24a3c.png"></p> <p> </p> <p>AREK is a clean and easy to use wrapper over any kind of iOS permission.</p> <ul> <li>show a native popup used to avoid to burn the possibility to ask to iOS the <em>real</em> permission</li> <li>show a popup to invite the user to re-enable the permission if it has been denied</li> <li>manage through an easy configuration how many times to ask the user to re-enable the permission (Only once, every hour, once a day, weekly, always :mask: )</li> </ul> <p>:rotating_light: AREK is a <strong>Swift 3</strong> and <strong>XCode 8</strong> compatible project :rotating_light:</p> <h2>Implemented permissions</h2> <ul> <li>Camera</li> <li>Contacts</li> <li>Events (Calendar)</li> <li>Health</li> <li>Location (Always)</li> <li>Location (When in use)</li> <li>Microphone</li> <li>Notifications</li> <li>Photo</li> <li>Reminders</li> </ul> <h2>How to use AREK</h2> <h2>Check permission status</h2> <pre> let permission = ArekPhoto() permission.status { (status) in switch status { case .Authorized: print("Yoah! :white_check_mark:") case .Denied: print("! :no_entry:️ !" ) case .NotDetermined: print("! �� !" ) } }</pre> <h2>Request permission</h2> <pre> let permission = ArekEvent() permission.manage { (status) in switch status { case .Authorized: symbol = ":white_check_mark:" case .Denied: symbol = ":no_entry:️" case .NotDetermined: symbol = "��" } }</pre> <h2>Permission Configuration</h2> <p>Each permission type included in AREK is configurable through the <em>ArekConfiguration</em> struct. Each permission has a default configuration, so if you are happy with the basic configuration you don't have to take care about how it works behind the scenes.</p> <p>An <em>ArekConfiguration</em> is made up by:</p> <p>frequency: ArekPermissionFrequency (.Always, .EveryHour, .OnceADay, .OnceAWeek, .JustOnce) This frequency value is related to how often you want to the user to re-enable a permission if that one has been disallowed.</p> <p>Set by default to <strong>.OnceADay</strong></p> <p>presentInitialPopup: Bool This is an initial popup used to ask <strong>kindly</strong> to the user to allow a permission. This is useful to avoid burning the possibility to show the system popup.</p> <p>Set by default to <strong>true</strong></p> <p>presentReEnablePopup: Bool This is the popup used to <strong>kindly</strong> to the user to re-enable that permission. The <em>frequency</em> value is related to this popup.</p> <p>Set by defaul to <strong>true</strong></p> <h2>How to install AREK</h2> <h2>CocoaPods</h2> <p>You could add to your Podfile the line</p> <p>use_frameworks! target 'MyTarget' do pod 'arek', '~> 0.0.5' end</p> <h2>Add AREK source code to your project</h2> <p>Add <a href="/misc/goto?guid=4959728373134797315" rel="nofollow,noindex">https://github.com/ennioma/arek/tree/master/arek/arek/Arek</a> folder to your project.</p> <p>:pray: Take care about adding the ArekHealth class to your project. It includes HealthKit in your project, so if you do this without using HealthKit, your app will be rejected during the AppStore review.</p> <h2>Contribute</h2> <p>Contributions are welcome :raised_hands: If you'd like to improve this projects I've shared with the community, just open an issue or raise a PR.</p> <h2>License</h2> <p>AREK is available under the MIT license. See the LICENSE file for more info.</p> <h2>TODO:</h2> <ul> <li>split podfile.spec in submodules to let the devs to add only the desired permissions</li> <li>add support to carthage</li> <li>add tests to every permission type</li> </ul> <p> </p> <p> </p>
本文由用户 qawn8847 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!