当前位置:网站首页>高德定位---权限弹框不出现的问题
高德定位---权限弹框不出现的问题
2022-07-23 05:41:00 【努力成为包租婆】
定位弹框不提示了
最近在优化公司以前的老项目,发现项目里面定位权限弹框没有提示。
刚开始以为是plist文件里面没有配置,就重新进行一次配置,下面图片里面红色框里面标出来的三个权限都是关于位置的配置。
一般情况我们使用的权限是第三个:在APP使用期间获取位置信息。防止APP审核因为位置权限问题被拒

配置好这些之后就按照官方文档里面的正常流程进行编写。
1、先将高德SDK导入项目(官方文档里面有具体的方法)。
2、项目里面导入头问题件
#import <AMapFoundationKit/AMapFoundationKit.h>
#import <AMapLocationKit/AMapLocationKit.h>
3、初始化
self.GlocationManager = [[AMapLocationManager alloc] init]; // 初始化
self.GlocationManager.delegate = self; // 实现代理
self.GlocationManager.desiredAccuracy = kCLLocationAccuracyBest; // 定位精度
self.GlocationManager.distanceFilter = 50; // 定位最小更新距离
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9) {
self.GlocationManager.allowsBackgroundLocationUpdates = YES;
}
[self.GlocationManager setLocatingWithReGeocode:YES];
[self.GlocationManager startUpdatingLocation];
4、实现代理方法
弹框不出现的问题就是这里了,之前运行的时候总是不弹框,警告提示
" 要在iOS 8及以上版本使用后台定位服务, 需要实现amapLocationManager:doRequireLocationAuth: 代理方法"
项目里面就是因为这个方法没有添加实现才没弹框的,之后添加进去这个方法,再次运行就成功弹出提示框了。
- (void)amapLocationManager:(AMapLocationManager *)manager doRequireLocationAuth:(CLLocationManager*)locationManager{
[locationManager requestWhenInUseAuthorization];// 项目使用期间使用位置信息 可以更换
}
- (void)amapLocationManager:(AMapLocationManager *)manager didUpdateLocation:(CLLocation *)location reGeocode:(AMapLocationReGeocode *)reGeocode
{
NSLog(@"location:{lat:%f; lon:%f; accuracy:%f}", location.coordinate.latitude, location.coordinate.longitude, location.horizontalAccuracy);
if (reGeocode)
{
NSLog(@"当前地址信息:%@%@%@%@%@%@", reGeocode.province,reGeocode.city,reGeocode.district,reGeocode.street,reGeocode.number,reGeocode.AOIName);
}
}
综上,如果你的项目是这样的问题,就可以参考一下这个方法。
边栏推荐
- [untitled]
- Man in the middle attacks ARP Spoofing and its linkage with beef XSS
- 數倉4.0筆記——業務數據采集
- Data warehouse 4.0 notes - data warehouse environment construction - Yan configuration
- The difference between slice() and slice()
- NFT digital collection development: Jingdong "Qida bear takes you to the capital" tourism package
- [flick]flick on yarn's flick conf simplest configuration
- Mysqldump batch export MySQL table creation statement
- NFT数字藏品系统开发:音乐和NFT的结合
- IP地址是什么
猜你喜欢

Upload lab level 1-4

Data warehouse 4.0 notes - user behavior data generation

Introduction to the process structure used by activiti workflow

Image fuzzy processing batch production fuzzy data set

利用动态规划解决最长增长子序列问题

Data warehouse 4.0 notes - business data collection

Installation and process creation of activiti app used by activiti workflow

kubesphere haproxy+keepalived (一)

DVWA learning notes

Sqli lab 1-16 notes with customs clearance
随机推荐
Wordcount of the first Flink program
Understanding of the decoder in the transformer in NLP
Using dynamic programming to solve the longest growing subsequence problem
Digital collection development / digital collection system development solution
Data warehouse 4.0 notes - user behavior data collection III
[untitled]
NFT数字藏品开发:京东“奇达熊带你游京城”旅游套装
Introduction to the process structure used by activiti workflow
DBA命令
[uiautomation] key instructions (and three call methods) + common mouse actions +sendkeys+inspect learning
Quartz2.2 simple scheduling job
2、MySQL数据管理--DML(添加、修改、删除数据)
Chinese interpretation of notepad++ background color adjustment options
mysql免密登录设置
Federal Reserve governor Waller: decentralized finance may eventually change the traditional financial market
phxpaxos安装编译流程
window运行gradle build -- --stacktrace出现找不到文件framework-4.3.0.BUILD-SNAPSHOT-schema.zip异常
数字藏品系统开发/数字藏品方案介绍
互联网通信
mysql根据中文字段首字母排序