Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
GMBase
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMBase
Commits
d3941abe
Commit
d3941abe
authored
May 25, 2020
by
jz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
8cd23190
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
13 deletions
+40
-13
Podfile.lock
Example/Podfile.lock
+8
-4
GMLocationManager.h
GMBase/Classes/AddClass/GMLocationManager.h
+3
-0
GMLocationManager.m
GMBase/Classes/AddClass/GMLocationManager.m
+29
-9
No files found.
Example/Podfile.lock
View file @
d3941abe
...
...
@@ -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
GMBase/Classes/AddClass/GMLocationManager.h
View file @
d3941abe
...
...
@@ -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
;
...
...
GMBase/Classes/AddClass/GMLocationManager.m
View file @
d3941abe
...
...
@@ -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
)
{
NS
Log
(
@"获取失败,会继续尝试获取位置信息"
);
// debug
Log(@"获取失败,会继续尝试获取位置信息");
}
}
-
(
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
];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment