NRLocationManager
简介
NRLocationManager:此类用于通过完成处理程序提供位置更新。此库的一些主要功能包括:
- 一次性位置
- 连续位置
- 显著位置
- 检查系统位置是否开启/关闭
示例
要运行示例项目,请克隆仓库,然后首先从示例目录运行pod install
。
需求
Xcode 9+,Swift 4,iOS 9及以上
plist密钥和后台模式
在您使用位置服务之前,请确保您的plist文件中包含以下密钥。
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Description</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Will you allow this app to always know your location?</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Do you allow this app to know your current location?</string>
Also enable background mode for location :
UIBackgroundModes -> Location updates
安装
NRLocationManager 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod "NRLocationManager"
使用方法
单次定位
@IBAction func oneTimeLocationButtonPressed() {
updateLabel(string: "One Time Location ...")
NRLocationManger.shared.fetchLocation(locationType: .onetime) { (location, error) in
if error != nil {
} }
}
连续定位
@IBAction func oneTimeLocationButtonPressed() {
updateLabel(string: "One Time Location ...")
NRLocationManger.shared.fetchLocation(locationType: .continous) { (location, error) in
if error != nil {
}}
}
显著位置
@IBAction func oneTimeLocationButtonPressed() {
updateLabel(string: "One Time Location ...")
NRLocationManger.shared.fetchLocation(locationType: .significant) { (location, error) in
if error != nil {
}}
}
贡献
我们随时欢迎贡献! (
- 派生它( http://github.com/naveenrana1309/NRLocationManager/fork )
- 创建您的功能分支 ('git checkout -b my-new-feature')
- 提交您的更改 ('git commit -am 'Add some feature')
- 推送到分支 ('git push origin my-new-feature')
- 创建新的 Pull Request
兼容性
Xcode 9+,Swift 4,iOS 10及更高版本
作者
Naveen Rana。 查看个人档案
电子邮件: [email protected]。
查看 Facebook个人资料 获取详细信息。
许可协议
NRLocationManager 在 MIT 许可协议下可用。有关更多信息,请参阅 LICENSE 文件。