Commit d3941abe authored by jz's avatar jz

update

parent 8cd23190
......@@ -130,7 +130,7 @@ PODS:
DEPENDENCIES:
- 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`)"
- GMShareSDK (= 0.2.1)
- SnapKit (= 4.0.0)
......@@ -169,12 +169,16 @@ EXTERNAL SOURCES:
GMBase:
:path: "../"
GMBaseSwift:
:path: "../../GMBaseSwift"
:commit: 116868d
:git: "git@git.wanmeizhensuo.com:gengmeiios/GMBaseSwift.git"
GMPhobos:
:commit: 7e58199898627699373ad6a9f87b875ab04b0927
:git: "git@git.wanmeizhensuo.com:gengmeiios/GMPhobos.git"
CHECKOUT OPTIONS:
GMBaseSwift:
:commit: 116868d
:git: "git@git.wanmeizhensuo.com:gengmeiios/GMBaseSwift.git"
GMPhobos:
:commit: 7e58199898627699373ad6a9f87b875ab04b0927
:git: "git@git.wanmeizhensuo.com:gengmeiios/GMPhobos.git"
......@@ -210,6 +214,6 @@ SPEC CHECKSUMS:
WechatOpenSDK: 8b3ba4239193d1112205c139c94e21934e8f369a
Weibo_SDK: 5a4d08f7e1fedbb635435e4585c8c0439c7da089
PODFILE CHECKSUM: e95d6f8605334b66e3f2179ba01177c3fbae6cec
PODFILE CHECKSUM: faf86c6bf49a2950d2c920316609ef26dc4389c2
COCOAPODS: 1.9.1
COCOAPODS: 1.9.2
......@@ -11,6 +11,7 @@
#define kLastLocation @"lastLocation"
typedef void(^LocationFinishBlock)(CLLocation *location);
typedef void(^GMLocationAuthorizationBlock)(CLAuthorizationStatus status);
/**
保证新用户在有网络的情况下弹出 授权框 不然调不起地理位置弹框
......@@ -23,6 +24,8 @@ typedef void(^LocationFinishBlock)(CLLocation *location);
@property (nonatomic, readonly) CLLocation *location;
@property (nonatomic, assign, readonly) NSInteger statusWhenAppBackground;
/// 授权回调
@property (nonatomic, copy) GMLocationAuthorizationBlock authorBlock;
+ (instancetype)shareInstance;
......
......@@ -210,14 +210,24 @@
- (void)notDeterminedShowLocationAuthorize {
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (status == kCLAuthorizationStatusNotDetermined) {
[self.locationManager requestWhenInUseAuthorization];
[Phobos track:@"popup_view" attributes:@{@"page_name": SafeString([GMBaseTool getCurrentViewController].pageName), @"popup_name": @"location"} sendNow:YES];
[self _updatingLocation];
[self.locationManager requestWhenInUseAuthorization];
[Phobos track:@"popup_view" attributes:@{@"page_name": SafeString([GMBaseTool getCurrentViewController].pageName),
@"popup_name": @"location",
@"is_first_start":SafeString(@([self isAppFirst]))} sendNow:YES];
[self _updatingLocation];
} 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 {
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
BOOL enable = [CLLocationManager locationServicesEnabled];
......@@ -238,7 +248,6 @@
// 注意此处可能会被多次调用,这是CoreLocation中的正常现象
self.location = locations.lastObject;
[self finishUpdatingLocation];
}
// 定位失误时触发
......@@ -247,19 +256,30 @@
// self.location = [[CLLocation alloc] initWithLatitude:0 longitude:0];
[self finishUpdatingLocation];
if (error.code == kCLErrorLocationUnknown ) {
NSLog(@"获取失败,会继续尝试获取位置信息");
// debugLog(@"获取失败,会继续尝试获取位置信息");
}
}
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
/// 获取授权状态后进行回调
if (status != kCLAuthorizationStatusNotDetermined) {
if (self.authorBlock) {
self.authorBlock(status);
}
}
// 如果不允许访问地理位置,直接完成
if (status == kCLAuthorizationStatusRestricted || status == kCLAuthorizationStatusDenied) {
[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){
[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];
}
}
......@@ -285,7 +305,7 @@
[GMCache storeObjectAtDiskWithkey:kLastLocation object:_location];
}
#pragma mark - Block Manage
#pragma mark - Block Manage
- (void)addBlock:(LocationFinishBlock)block {
[_blocks addObject:block];
}
......
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