Commit decc7f24 authored by luyueming's avatar luyueming

Merge branch 'lym/text' of git.wanmeizhensuo.com:gengmeiios/GMBase into lym/text

* 'lym/text' of git.wanmeizhensuo.com:gengmeiios/GMBase:
  update
parents 207e661f d3941abe
...@@ -130,7 +130,7 @@ PODS: ...@@ -130,7 +130,7 @@ PODS:
DEPENDENCIES: DEPENDENCIES:
- GMBase (from `../`) - GMBase (from `../`)
- GMBaseSwift (from `../../GMBaseSwift`) - "GMBaseSwift (from `git@git.wanmeizhensuo.com:gengmeiios/GMBaseSwift.git`, commit `116868d`)"
- "GMPhobos (from `git@git.wanmeizhensuo.com:gengmeiios/GMPhobos.git`, commit `7e58199898627699373ad6a9f87b875ab04b0927`)" - "GMPhobos (from `git@git.wanmeizhensuo.com:gengmeiios/GMPhobos.git`, commit `7e58199898627699373ad6a9f87b875ab04b0927`)"
- GMShareSDK (= 0.2.1) - GMShareSDK (= 0.2.1)
- SnapKit (= 4.0.0) - SnapKit (= 4.0.0)
...@@ -169,12 +169,16 @@ EXTERNAL SOURCES: ...@@ -169,12 +169,16 @@ EXTERNAL SOURCES:
GMBase: GMBase:
:path: "../" :path: "../"
GMBaseSwift: GMBaseSwift:
:path: "../../GMBaseSwift" :commit: 116868d
:git: "git@git.wanmeizhensuo.com:gengmeiios/GMBaseSwift.git"
GMPhobos: GMPhobos:
:commit: 7e58199898627699373ad6a9f87b875ab04b0927 :commit: 7e58199898627699373ad6a9f87b875ab04b0927
:git: "git@git.wanmeizhensuo.com:gengmeiios/GMPhobos.git" :git: "git@git.wanmeizhensuo.com:gengmeiios/GMPhobos.git"
CHECKOUT OPTIONS: CHECKOUT OPTIONS:
GMBaseSwift:
:commit: 116868d
:git: "git@git.wanmeizhensuo.com:gengmeiios/GMBaseSwift.git"
GMPhobos: GMPhobos:
:commit: 7e58199898627699373ad6a9f87b875ab04b0927 :commit: 7e58199898627699373ad6a9f87b875ab04b0927
:git: "git@git.wanmeizhensuo.com:gengmeiios/GMPhobos.git" :git: "git@git.wanmeizhensuo.com:gengmeiios/GMPhobos.git"
...@@ -210,6 +214,6 @@ SPEC CHECKSUMS: ...@@ -210,6 +214,6 @@ SPEC CHECKSUMS:
WechatOpenSDK: 8b3ba4239193d1112205c139c94e21934e8f369a WechatOpenSDK: 8b3ba4239193d1112205c139c94e21934e8f369a
Weibo_SDK: 5a4d08f7e1fedbb635435e4585c8c0439c7da089 Weibo_SDK: 5a4d08f7e1fedbb635435e4585c8c0439c7da089
PODFILE CHECKSUM: e95d6f8605334b66e3f2179ba01177c3fbae6cec PODFILE CHECKSUM: faf86c6bf49a2950d2c920316609ef26dc4389c2
COCOAPODS: 1.9.1 COCOAPODS: 1.9.2
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#define kLastLocation @"lastLocation" #define kLastLocation @"lastLocation"
typedef void(^LocationFinishBlock)(CLLocation *location); typedef void(^LocationFinishBlock)(CLLocation *location);
typedef void(^GMLocationAuthorizationBlock)(CLAuthorizationStatus status);
/** /**
保证新用户在有网络的情况下弹出 授权框 不然调不起地理位置弹框 保证新用户在有网络的情况下弹出 授权框 不然调不起地理位置弹框
...@@ -23,6 +24,8 @@ typedef void(^LocationFinishBlock)(CLLocation *location); ...@@ -23,6 +24,8 @@ typedef void(^LocationFinishBlock)(CLLocation *location);
@property (nonatomic, readonly) CLLocation *location; @property (nonatomic, readonly) CLLocation *location;
@property (nonatomic, assign, readonly) NSInteger statusWhenAppBackground; @property (nonatomic, assign, readonly) NSInteger statusWhenAppBackground;
/// 授权回调
@property (nonatomic, copy) GMLocationAuthorizationBlock authorBlock;
+ (instancetype)shareInstance; + (instancetype)shareInstance;
......
...@@ -211,13 +211,23 @@ ...@@ -211,13 +211,23 @@
CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (status == kCLAuthorizationStatusNotDetermined) { if (status == kCLAuthorizationStatusNotDetermined) {
[self.locationManager requestWhenInUseAuthorization]; [self.locationManager requestWhenInUseAuthorization];
[Phobos track:@"popup_view" attributes:@{@"page_name": SafeString([GMBaseTool getCurrentViewController].pageName), @"popup_name": @"location"} sendNow:YES];
[Phobos track:@"popup_view" attributes:@{@"page_name": SafeString([GMBaseTool getCurrentViewController].pageName),
@"popup_name": @"location",
@"is_first_start":SafeString(@([self isAppFirst]))} sendNow:YES];
[self _updatingLocation]; [self _updatingLocation];
} else { } else {
[self _updatingLocation]; [self _updatingLocation];
} }
} }
//TODO: 待艾娇平验证
- (BOOL)isAppFirst {
// 获取app初始启动时间
NSString *app_initial_time = [GMCache fetchObjectAtDocumentPathWithkey:@"app_initial_launch_time"];
return [app_initial_time isNonEmpty];
}
- (void)updateLocation { - (void)updateLocation {
CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
BOOL enable = [CLLocationManager locationServicesEnabled]; BOOL enable = [CLLocationManager locationServicesEnabled];
...@@ -238,7 +248,6 @@ ...@@ -238,7 +248,6 @@
// 注意此处可能会被多次调用,这是CoreLocation中的正常现象 // 注意此处可能会被多次调用,这是CoreLocation中的正常现象
self.location = locations.lastObject; self.location = locations.lastObject;
[self finishUpdatingLocation]; [self finishUpdatingLocation];
} }
// 定位失误时触发 // 定位失误时触发
...@@ -247,19 +256,30 @@ ...@@ -247,19 +256,30 @@
// self.location = [[CLLocation alloc] initWithLatitude:0 longitude:0]; // self.location = [[CLLocation alloc] initWithLatitude:0 longitude:0];
[self finishUpdatingLocation]; [self finishUpdatingLocation];
if (error.code == kCLErrorLocationUnknown ) { if (error.code == kCLErrorLocationUnknown ) {
NSLog(@"获取失败,会继续尝试获取位置信息"); // debugLog(@"获取失败,会继续尝试获取位置信息");
} }
} }
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
/// 获取授权状态后进行回调
if (status != kCLAuthorizationStatusNotDetermined) {
if (self.authorBlock) {
self.authorBlock(status);
}
}
// 如果不允许访问地理位置,直接完成 // 如果不允许访问地理位置,直接完成
if (status == kCLAuthorizationStatusRestricted || status == kCLAuthorizationStatusDenied) { if (status == kCLAuthorizationStatusRestricted || status == kCLAuthorizationStatusDenied) {
[self finishUpdatingLocation]; [self finishUpdatingLocation];
[Phobos track:@"report_status" attributes:@{@"page_name": SafeString([GMBaseTool getCurrentViewController].pageName), @"report_name":@"close_location"} sendNow:YES]; [Phobos track:@"report_status" attributes:@{@"page_name": SafeString([GMBaseTool getCurrentViewController].pageName),
@"report_name":@"close_location",
@"is_first_start": SafeString(@([self isAppFirst]))} sendNow:YES];
}else if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizedWhenInUse){ }else if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizedWhenInUse){
[self _updatingLocation]; [self _updatingLocation];
[Phobos track:@"report_status" attributes:@{@"page_name": SafeString([GMBaseTool getCurrentViewController].pageName), @"report_name":@"open_location"} sendNow:YES]; [Phobos track:@"report_status" attributes:@{@"page_name": SafeString([GMBaseTool getCurrentViewController].pageName),
@"report_name":@"open_location",
@"is_first_start": SafeString(@([self isAppFirst]))} sendNow:YES];
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment