Commit 8fe921d3 authored by 乔金柱's avatar 乔金柱

Merge branch 'jql/push' into 'master'

push

See merge request !55
parents a99eb119 6a63492b
...@@ -280,7 +280,8 @@ static dispatch_semaphore_t _phobos_semaphore; ...@@ -280,7 +280,8 @@ static dispatch_semaphore_t _phobos_semaphore;
[dict setObject:PhobosSafeString(page.referrerId) forKey:@"referrer_id"]; [dict setObject:PhobosSafeString(page.referrerId) forKey:@"referrer_id"];
[dict setObject:PhobosSafeString(page.extraParam) forKey:@"extra_param"]; [dict setObject:PhobosSafeString(page.extraParam) forKey:@"extra_param"];
[dict setObject:PhobosSafeString(page.referrerTabName) forKey:@"referrer_tab_name"]; [dict setObject:PhobosSafeString(page.referrerTabName) forKey:@"referrer_tab_name"];
[dict setObject:page.isPush.intValue ? @(page.isPush.intValue) : @(0) forKey:@"is_push"]; [dict setObject:@(page.isPush ? 1 : 0) forKey:@"is_push"];
[dict setObject:PhobosSafeString(page.messageId) forKey:@"message_id"];
[dict setObject:PhobosSafeString(page.inTimeMillis) forKey:@"in_time_millis"]; [dict setObject:PhobosSafeString(page.inTimeMillis) forKey:@"in_time_millis"];
[dict setObject:PhobosSafeString([PhobosUtil currentMMTime]) forKey:@"out_time_millis"]; [dict setObject:PhobosSafeString([PhobosUtil currentMMTime]) forKey:@"out_time_millis"];
......
...@@ -358,7 +358,8 @@ static OldPhobos *sharedClient = nil; ...@@ -358,7 +358,8 @@ static OldPhobos *sharedClient = nil;
[dict setObject:PhobosSafeString(page.referrerId) forKey:@"referrer_id"]; [dict setObject:PhobosSafeString(page.referrerId) forKey:@"referrer_id"];
[dict setObject:PhobosSafeString(page.extraParam) forKey:@"extra_param"]; [dict setObject:PhobosSafeString(page.extraParam) forKey:@"extra_param"];
[dict setObject:PhobosSafeString(page.referrerTabName) forKey:@"referrer_tab_name"]; [dict setObject:PhobosSafeString(page.referrerTabName) forKey:@"referrer_tab_name"];
[dict setObject:page.isPush.intValue ? @(page.isPush.intValue) : @(0) forKey:@"is_push"]; [dict setObject:@(page.isPush ? 1 : 0) forKey:@"is_push"];
[dict setObject:PhobosSafeString(page.messageId) forKey:@"message_id"];
[dict setObject:PhobosSafeString(page.inTimeMillis) forKey:@"in_time_millis"]; [dict setObject:PhobosSafeString(page.inTimeMillis) forKey:@"in_time_millis"];
[dict setObject:PhobosSafeString([PhobosUtil currentMMTime]) forKey:@"out_time_millis"]; [dict setObject:PhobosSafeString([PhobosUtil currentMMTime]) forKey:@"out_time_millis"];
......
...@@ -78,7 +78,12 @@ typedef void(^PhobosUpdatePVBlock)(void); ...@@ -78,7 +78,12 @@ typedef void(^PhobosUpdatePVBlock)(void);
1: 是推送页面跳转 1: 是推送页面跳转
0: 普通页面跳转 0: 普通页面跳转
*/ */
@property (nonatomic, copy) NSString *isPush; @property (nonatomic, assign) BOOL isPush;
/**
* 推送id, 如果isPush = 1,该值会取push信息中的message_id
*/
@property (nonatomic, copy) NSString *messageId;
/** /**
获取上一个页面链路的page_name link by 7.20.0 如果有此页面有page_name则添加 , 没有添加"" 获取上一个页面链路的page_name link by 7.20.0 如果有此页面有page_name则添加 , 没有添加""
......
...@@ -30,4 +30,6 @@ ...@@ -30,4 +30,6 @@
*/ */
- (void)initReferrerTabName; - (void)initReferrerTabName;
- (void)setSourceFromPushWithMessageId:(NSString *)messageId;
@end @end
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
// 所以此处要判断,如果是navigation弹出,最后还是要定位到topViewController // 所以此处要判断,如果是navigation弹出,最后还是要定位到topViewController
if ([me.presentingViewController isKindOfClass:[UINavigationController class]]) { if ([me.presentingViewController isKindOfClass:[UINavigationController class]]) {
UIViewController *top = ((UINavigationController *)me.presentingViewController).topViewController; UIViewController *top = ((UINavigationController *)me.presentingViewController).topViewController;
objc_setAssociatedObject(self, @selector(referer), top.pageName, OBJC_ASSOCIATION_COPY); self.referer = top.pageName;
} else { } else {
objc_setAssociatedObject(self, @selector(referer), me.presentingViewController.pageName, OBJC_ASSOCIATION_COPY); self.referer = me.presentingViewController.pageName;
} }
} else { } else {
NSArray *navigationPool = ((UIViewController *)self).navigationController.viewControllers; NSArray *navigationPool = ((UIViewController *)self).navigationController.viewControllers;
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
return ; return ;
} }
UIViewController *controller = navigationPool[refererIndex]; UIViewController *controller = navigationPool[refererIndex];
objc_setAssociatedObject(self, @selector(referer), controller.pageName, OBJC_ASSOCIATION_COPY); self.referer = controller.pageName;
} }
} }
} }
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
if (self.referrerLink.count == 0 && [self isKindOfClass:[UIViewController class]]) { if (self.referrerLink.count == 0 && [self isKindOfClass:[UIViewController class]]) {
// 分present与navigation两种情况 // 分present与navigation两种情况
UIViewController *me = (UIViewController *)self; UIViewController *me = (UIViewController *)self;
if (me.isPush.intValue) { // 如果是推送进来的,结果页面的referrerLink 为空数组, 此处添加过滤。 if (me.isPush) { // 如果是推送进来的,结果页面的referrerLink 为”push“ 此处添加过滤。
self.referrerLink = @[]; self.referrerLink = @[@"push"];
} else if (me.presentingViewController != nil) { } else if (me.presentingViewController != nil) {
// app全局只有一个navigation,发现此时用navigation.topViewController presentViewController时,最终使用的是navigation弹出的 // app全局只有一个navigation,发现此时用navigation.topViewController presentViewController时,最终使用的是navigation弹出的
// 所以此处要判断,如果是navigation弹出,最后还是要定位到topViewController // 所以此处要判断,如果是navigation弹出,最后还是要定位到topViewController
...@@ -102,9 +102,9 @@ ...@@ -102,9 +102,9 @@
// 所以此处要判断,如果是navigation弹出,最后还是要定位到topViewController // 所以此处要判断,如果是navigation弹出,最后还是要定位到topViewController
if ([me.presentingViewController isKindOfClass:[UINavigationController class]]) { if ([me.presentingViewController isKindOfClass:[UINavigationController class]]) {
UIViewController *top = ((UINavigationController *)me.presentingViewController).topViewController; UIViewController *top = ((UINavigationController *)me.presentingViewController).topViewController;
objc_setAssociatedObject(self, @selector(referrerTabName), top.tabName, OBJC_ASSOCIATION_COPY); self.referrerTabName = top.tabName;
} else { } else {
objc_setAssociatedObject(self, @selector(referrerTabName), me.presentingViewController.tabName, OBJC_ASSOCIATION_COPY); self.referrerTabName = me.presentingViewController.tabName;
} }
} else { } else {
NSArray *navigationPool = ((UIViewController *)self).navigationController.viewControllers; NSArray *navigationPool = ((UIViewController *)self).navigationController.viewControllers;
...@@ -113,13 +113,13 @@ ...@@ -113,13 +113,13 @@
return ; return ;
} }
UIViewController *controller = navigationPool[refererIndex]; UIViewController *controller = navigationPool[refererIndex];
objc_setAssociatedObject(self, @selector(referrerTabName), controller.tabName, OBJC_ASSOCIATION_COPY); self.referrerTabName = controller.tabName;
} }
} }
} }
- (void)setReferer:(NSString *)referer { - (void)setReferer:(NSString *)referer {
objc_setAssociatedObject(self, @selector(referer), referer, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(referer), referer, OBJC_ASSOCIATION_COPY_NONATOMIC);
} }
- (NSString *)referer - (NSString *)referer
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
} }
- (void)setPageName:(NSString *)pageName { - (void)setPageName:(NSString *)pageName {
objc_setAssociatedObject(self, @selector(pageName), pageName, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(pageName), pageName, OBJC_ASSOCIATION_COPY_NONATOMIC);
} }
- (NSString *)businessId { - (NSString *)businessId {
...@@ -143,11 +143,11 @@ ...@@ -143,11 +143,11 @@
} }
- (void)setBusinessId:(NSString *)businessId { - (void)setBusinessId:(NSString *)businessId {
objc_setAssociatedObject(self, @selector(businessId), businessId, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(businessId), businessId, OBJC_ASSOCIATION_COPY_NONATOMIC);
} }
- (void)setInTime:(NSString *)inTime { - (void)setInTime:(NSString *)inTime {
objc_setAssociatedObject(self, @selector(inTime), inTime, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(inTime), inTime, OBJC_ASSOCIATION_COPY_NONATOMIC);
} }
/** /**
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
} }
- (void)setInTimeMillis:(NSString *)inTimeMillis { - (void)setInTimeMillis:(NSString *)inTimeMillis {
objc_setAssociatedObject(self, @selector(inTimeMillis), inTimeMillis, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(inTimeMillis), inTimeMillis, OBJC_ASSOCIATION_COPY_NONATOMIC);
} }
- (NSString *)inTimeMillis { - (NSString *)inTimeMillis {
...@@ -178,18 +178,17 @@ ...@@ -178,18 +178,17 @@
NSArray *navigationPool = ((UIViewController *)self).navigationController.viewControllers; NSArray *navigationPool = ((UIViewController *)self).navigationController.viewControllers;
NSInteger refererIdIndex = navigationPool.count - 2; NSInteger refererIdIndex = navigationPool.count - 2;
if (refererIdIndex < 0) { if (refererIdIndex < 0) {
objc_setAssociatedObject(self, @selector(referrerId), @"", OBJC_ASSOCIATION_COPY); self.referrerId = @"";
} else { } else {
UIViewController *controller = navigationPool[refererIdIndex]; UIViewController *controller = navigationPool[refererIdIndex];
NSString *preBusinessId = controller.businessId; self.referrerId = controller.businessId;
objc_setAssociatedObject(self, @selector(referrerId), preBusinessId, OBJC_ASSOCIATION_COPY);
} }
} }
} }
} }
- (void)setReferrerId:(NSString *)referrerId { - (void)setReferrerId:(NSString *)referrerId {
objc_setAssociatedObject(self, @selector(referrerId), referrerId, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(referrerId), referrerId, OBJC_ASSOCIATION_COPY_NONATOMIC);
} }
- (NSString *)referrerId { - (NSString *)referrerId {
...@@ -207,7 +206,7 @@ ...@@ -207,7 +206,7 @@
} }
- (void)setExtraParam:(NSString *)extraParam { - (void)setExtraParam:(NSString *)extraParam {
objc_setAssociatedObject(self, @selector(extraParam), extraParam, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(extraParam), extraParam, OBJC_ASSOCIATION_COPY_NONATOMIC);
} }
- (NSString *)extraParam { - (NSString *)extraParam {
...@@ -216,7 +215,7 @@ ...@@ -216,7 +215,7 @@
} }
- (void)setTabName:(NSString *)tabName { - (void)setTabName:(NSString *)tabName {
objc_setAssociatedObject(self, @selector(tabName), tabName, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(tabName), tabName, OBJC_ASSOCIATION_COPY_NONATOMIC);
} }
- (NSString *)tabName { - (NSString *)tabName {
...@@ -225,7 +224,7 @@ ...@@ -225,7 +224,7 @@
} }
- (void)setReferrerTabName:(NSString *)referrerTabName { - (void)setReferrerTabName:(NSString *)referrerTabName {
objc_setAssociatedObject(self, @selector(referrerTabName), referrerTabName, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(referrerTabName), referrerTabName, OBJC_ASSOCIATION_COPY_NONATOMIC);
} }
- (NSString *)referrerTabName { - (NSString *)referrerTabName {
...@@ -233,17 +232,26 @@ ...@@ -233,17 +232,26 @@
return referrerTabName == nil ? @"" : referrerTabName; return referrerTabName == nil ? @"" : referrerTabName;
} }
- (void)setIsPush:(NSString *)isPush { - (void)setIsPush:(BOOL)isPush {
objc_setAssociatedObject(self, @selector(isPush), isPush, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(isPush), @(isPush), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
} }
- (NSString *)isPush { - (BOOL)isPush {
NSString *isPush = objc_getAssociatedObject(self, @selector(isPush)); NSNumber *isPush = objc_getAssociatedObject(self, @selector(isPush));
return isPush == nil ? @"" : isPush; return isPush == nil ? NO : isPush.boolValue;
}
- (void)setMessageId:(NSString *)messageId {
objc_setAssociatedObject(self, @selector(messageId), messageId, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
- (NSString *)messageId {
NSString *messageId = objc_getAssociatedObject(self, @selector(messageId));
return messageId == nil ? @"" : messageId;
} }
- (void)setUpdatePVStartBlock:(PhobosUpdatePVBlock)updatePVStartBlock { - (void)setUpdatePVStartBlock:(PhobosUpdatePVBlock)updatePVStartBlock {
objc_setAssociatedObject(self, @selector(updatePVStartBlock), updatePVStartBlock, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(updatePVStartBlock), updatePVStartBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
} }
- (PhobosUpdatePVBlock)updatePVStartBlock { - (PhobosUpdatePVBlock)updatePVStartBlock {
...@@ -252,11 +260,16 @@ ...@@ -252,11 +260,16 @@
} }
- (void)setUpdatePVEndBlock:(PhobosUpdatePVBlock)updatePVEndBlock { - (void)setUpdatePVEndBlock:(PhobosUpdatePVBlock)updatePVEndBlock {
objc_setAssociatedObject(self, @selector(updatePVEndBlock), updatePVEndBlock, OBJC_ASSOCIATION_COPY); objc_setAssociatedObject(self, @selector(updatePVEndBlock), updatePVEndBlock, OBJC_ASSOCIATION_COPY_NONATOMIC);
} }
- (PhobosUpdatePVBlock)updatePVEndBlock { - (PhobosUpdatePVBlock)updatePVEndBlock {
PhobosUpdatePVBlock updatePVBlock = objc_getAssociatedObject(self, @selector(updatePVEndBlock)); PhobosUpdatePVBlock updatePVBlock = objc_getAssociatedObject(self, @selector(updatePVEndBlock));
return updatePVBlock; return updatePVBlock;
} }
- (void)setSourceFromPushWithMessageId:(NSString *)messageId {
self.isPush = YES;
self.messageId = messageId;
}
@end @end
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