Skip to content

Commit

Permalink
Release 4.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
王洋洋 committed Sep 2, 2022
1 parent f6420b6 commit a918f4c
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 28 deletions.
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SensorsAnalyticsSDK"
s.version = "4.4.3"
s.version = "4.4.4"
s.summary = "The official iOS SDK of Sensors Analytics."
s.homepage = "http://www.sensorsdata.cn"
s.source = { :git => 'https://github.com/sensorsdata/sa-sdk-ios.git', :tag => "v#{s.version}" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,30 @@ @implementation SAScrollViewDelegateProxy

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// 防止某些场景下循环调用
if (tableView.sensorsdata_indexPath == indexPath) {
if ([tableView.sensorsdata_delegateHashTable containsObject:self]) {
return;
}
tableView.sensorsdata_indexPath = indexPath;

[tableView.sensorsdata_delegateHashTable addObject:self];
SEL methodSelector = @selector(tableView:didSelectRowAtIndexPath:);
[SAScrollViewDelegateProxy trackEventWithTarget:self scrollView:tableView atIndexPath:indexPath];
[SAScrollViewDelegateProxy invokeWithTarget:self selector:methodSelector, tableView, indexPath];

tableView.sensorsdata_indexPath = nil;
[tableView.sensorsdata_delegateHashTable removeAllObjects];
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (collectionView.sensorsdata_indexPath == indexPath) {
// 防止某些场景下循环调用
if ([collectionView.sensorsdata_delegateHashTable containsObject:self]) {
return;
}
collectionView.sensorsdata_indexPath = indexPath;

[collectionView.sensorsdata_delegateHashTable addObject:self];
SEL methodSelector = @selector(collectionView:didSelectItemAtIndexPath:);
[SAScrollViewDelegateProxy trackEventWithTarget:self scrollView:collectionView atIndexPath:indexPath];
[SAScrollViewDelegateProxy invokeWithTarget:self selector:methodSelector, collectionView, indexPath];

collectionView.sensorsdata_indexPath = nil;
[collectionView.sensorsdata_delegateHashTable removeAllObjects];
}

+ (void)trackEventWithTarget:(NSObject *)target scrollView:(UIScrollView *)scrollView atIndexPath:(NSIndexPath *)indexPath {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ NS_ASSUME_NONNULL_BEGIN

@interface UITableView (AutoTrack)

@property (nonatomic, strong, nullable) NSIndexPath *sensorsdata_indexPath;
@property (nonatomic, strong, nullable) NSHashTable *sensorsdata_delegateHashTable;

- (void)sensorsdata_setDelegate:(id <UITableViewDelegate>)delegate;

@end

@interface UICollectionView (AutoTrack)

@property (nonatomic, strong, nullable) NSIndexPath *sensorsdata_indexPath;
@property (nonatomic, strong, nullable) NSHashTable *sensorsdata_delegateHashTable;

- (void)sensorsdata_setDelegate:(id <UICollectionViewDelegate>)delegate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,22 @@
#import "SAConstants+Private.h"
#import "SAAutoTrackManager.h"

static const void *kSATableViewIndexPath = &kSATableViewIndexPath;
static const void *kSACollectionViewIndexPath = &kSACollectionViewIndexPath;
static const void *kSATableViewDelegateHashTable = &kSATableViewDelegateHashTable;
static const void *kSACollectionViewDelegateHashTable = &kSACollectionViewDelegateHashTable;

@implementation UITableView (AutoTrack)

- (void)setSensorsdata_indexPath:(NSIndexPath *)indexPath {
objc_setAssociatedObject(self, kSATableViewIndexPath, indexPath, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- (void)setSensorsdata_delegateHashTable:(NSHashTable *)delegateHashTable {
objc_setAssociatedObject(self, kSATableViewDelegateHashTable, delegateHashTable, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (NSIndexPath *)sensorsdata_indexPath {
return objc_getAssociatedObject(self, kSATableViewIndexPath);
- (NSHashTable *)sensorsdata_delegateHashTable {
NSHashTable *delegateHashTable = objc_getAssociatedObject(self, kSATableViewDelegateHashTable);
if (!delegateHashTable) {
delegateHashTable = [NSHashTable weakObjectsHashTable];
self.sensorsdata_delegateHashTable = delegateHashTable;
}
return delegateHashTable;
}

- (void)sensorsdata_setDelegate:(id <UITableViewDelegate>)delegate {
Expand All @@ -66,12 +71,17 @@ - (void)sensorsdata_setDelegate:(id <UITableViewDelegate>)delegate {

@implementation UICollectionView (AutoTrack)

- (void)setSensorsdata_indexPath:(NSIndexPath *)indexPath {
objc_setAssociatedObject(self, kSACollectionViewIndexPath, indexPath, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
- (void)setSensorsdata_delegateHashTable:(NSHashTable *)delegateHashTable {
objc_setAssociatedObject(self, kSACollectionViewDelegateHashTable, delegateHashTable, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (NSIndexPath *)sensorsdata_indexPath {
return objc_getAssociatedObject(self, kSACollectionViewIndexPath);
- (NSHashTable *)sensorsdata_delegateHashTable {
NSHashTable *delegateHashTable = objc_getAssociatedObject(self, kSACollectionViewDelegateHashTable);
if (!delegateHashTable) {
delegateHashTable = [NSHashTable weakObjectsHashTable];
self.sensorsdata_delegateHashTable = delegateHashTable;
}
return delegateHashTable;
}

- (void)sensorsdata_setDelegate:(id <UICollectionViewDelegate>)delegate {
Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/Core/Flow/SAFlowData.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ - (SAIdentifier *)identifier {
}

- (void)setProperties:(NSDictionary *)properties {
[self setParamWithKey:kSAFlowDataProperties value:properties];
[self setParamWithKey:kSAFlowDataProperties value:[properties copy]];
}

- (NSDictionary *)properties {
Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#import "SASessionPropertyPlugin.h"
#import "SAEventStore.h"

#define VERSION @"4.4.3"
#define VERSION @"4.4.4"

void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag;

Expand Down
13 changes: 10 additions & 3 deletions SensorsAnalyticsSDK/Location/SALocationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,16 @@ - (void)startUpdatingLocation {
if (self.isUpdatingLocation) {
return;
}
//判断当前设备定位服务是否打开
if (![CLLocationManager locationServicesEnabled]) {
SALogWarn(@"location service is not enabled on the device");

// 判断当前设备定位授权的状态
CLAuthorizationStatus status;
if (@available(iOS 14.0, *)) {
status = self.locationManager.authorizationStatus;
} else {
status = [CLLocationManager authorizationStatus];
}
if ((status == kCLAuthorizationStatusDenied) || (status == kCLAuthorizationStatusRestricted)) {
SALogWarn(@"location authorization status is denied or restricted");
return;
}

Expand Down

0 comments on commit a918f4c

Please sign in to comment.