Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
GMPhobos
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
GMPhobos
Commits
ddf12bb5
Commit
ddf12bb5
authored
Dec 06, 2018
by
汪洋
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'yefengming/GMPhobos' into 'master'
Yefengming/gm phobos See merge request
!22
parents
945921bf
2c86f2d8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
0 deletions
+67
-0
Phobos.m
GMPhobos/Classes/Phobos.m
+5
-0
PhobosPVProtocol.h
GMPhobos/Classes/PhobosPVProtocol.h
+10
-0
UIResponder+PhobosPV.h
GMPhobos/Classes/UIResponder+PhobosPV.h
+5
-0
UIResponder+PhobosPV.m
GMPhobos/Classes/UIResponder+PhobosPV.m
+47
-0
No files found.
GMPhobos/Classes/Phobos.m
View file @
ddf12bb5
...
...
@@ -326,6 +326,7 @@ static NSString *sdkVersion = @"110";
// 必须在此处调用一下referer,因为onControllerStart
[
page
initReferer
];
[
page
initReferrerIdIfNil
];
[
page
initReferrerTabName
];
page
.
inTime
=
[
PhobosUtil
currentTime
];
}
...
...
@@ -344,6 +345,10 @@ static NSString *sdkVersion = @"110";
[
dict
setObject
:
@
(
0
)
forKey
:
@"fake"
];
[
dict
setObject
:
page
.
referrerId
?
:
@""
forKey
:
@"referrer_id"
];
[
dict
setObject
:
page
.
extraParam
?
:
@""
forKey
:
@"extra_param"
];
[
dict
setObject
:
page
.
homeTabName
?
:
@""
forKey
:
@"tab_name"
];
[
dict
setObject
:
page
.
referrerTabName
?
:
@""
forKey
:
@"referrer_tab_name"
];
NSAssert
(
page
.
inTime
.
length
>
0
,
@"页面显示时间不能为空!"
);
[
Phobos
track
:
@"page_view"
attributes
:
dict
];
if
(
page
.
inTime
.
length
>
0
)
{
// 页面显示时间为空时不记录页面pv事件
[
Phobos
track
:
@"page_view"
attributes
:
dict
];
...
...
GMPhobos/Classes/PhobosPVProtocol.h
View file @
ddf12bb5
...
...
@@ -58,4 +58,14 @@
*/
@property
(
nonatomic
,
copy
,
nonnull
)
NSString
*
extraParam
;
/**
首页tab名称
*/
@property
(
nonatomic
,
copy
)
NSString
*
tabName
;
/**
获取上一个页面的tab名称
*/
@property
(
nonatomic
,
copy
)
NSString
*
referrerTabName
;
@end
GMPhobos/Classes/UIResponder+PhobosPV.h
View file @
ddf12bb5
...
...
@@ -19,4 +19,9 @@
此方法在onPvStart时调用,如果发现已经有值了,不会给referrerId再次赋值
*/
-
(
void
)
initReferrerIdIfNil
;
/**
此方法在onPvStart时调用,给referrerTabName赋值
*/
-
(
void
)
initReferrerTabName
;
@end
GMPhobos/Classes/UIResponder+PhobosPV.m
View file @
ddf12bb5
...
...
@@ -45,6 +45,35 @@
}
}
/**
此方法在onPvStart时调用,给referrerTabName赋值
*/
-
(
void
)
initReferrerTabName
{
// 只有是controller的情况下才自动获取
if
([
self
isKindOfClass
:[
UIViewController
class
]])
{
// 分present与navigation两种情况
UIViewController
*
me
=
(
UIViewController
*
)
self
;
if
(
me
.
presentingViewController
!=
nil
)
{
// app全局只有一个navigation,发现此时用navigation.topViewController presentViewController时,最终使用的是navigation弹出的
// 所以此处要判断,如果是navigation弹出,最后还是要定位到topViewController
if
([
me
.
presentingViewController
isKindOfClass
:[
UINavigationController
class
]])
{
UIViewController
*
top
=
((
UINavigationController
*
)
me
.
presentingViewController
).
topViewController
;
objc_setAssociatedObject
(
self
,
@selector
(
referrerTabName
),
top
.
tabName
,
OBJC_ASSOCIATION_COPY
);
}
else
{
objc_setAssociatedObject
(
self
,
@selector
(
referrerTabName
),
me
.
presentingViewController
.
tabName
,
OBJC_ASSOCIATION_COPY
);
}
}
else
{
NSArray
*
navigationPool
=
((
UIViewController
*
)
self
).
navigationController
.
viewControllers
;
NSInteger
refererIndex
=
navigationPool
.
count
-
2
;
if
(
refererIndex
<
0
)
{
return
;
}
UIViewController
*
controller
=
navigationPool
[
refererIndex
];
objc_setAssociatedObject
(
self
,
@selector
(
referrerTabName
),
controller
.
tabName
,
OBJC_ASSOCIATION_COPY
);
}
}
}
-
(
void
)
setReferer
:
(
NSString
*
)
referer
{
objc_setAssociatedObject
(
self
,
@selector
(
referer
),
referer
,
OBJC_ASSOCIATION_COPY
);
}
...
...
@@ -134,4 +163,22 @@
return
extraParam
==
nil
?
@""
:
extraParam
;
}
-
(
void
)
setTabName
:
(
NSString
*
)
tabName
{
objc_setAssociatedObject
(
self
,
@selector
(
tabName
),
tabName
,
OBJC_ASSOCIATION_COPY
);
}
-
(
NSString
*
)
tabName
{
NSString
*
tabName
=
objc_getAssociatedObject
(
self
,
@selector
(
tabName
));
return
tabName
==
nil
?
@""
:
tabName
;
}
-
(
void
)
setReferrerTabName
:
(
NSString
*
)
referrerTabName
{
objc_setAssociatedObject
(
self
,
@selector
(
referrerTabName
),
referrerTabName
,
OBJC_ASSOCIATION_COPY
);
}
-
(
NSString
*
)
referrerTabName
{
NSString
*
referrerTabName
=
objc_getAssociatedObject
(
self
,
@selector
(
referrerTabName
));
return
referrerTabName
==
nil
?
@""
:
referrerTabName
;
}
@end
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