Skip to content

Commit

Permalink
Release 3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
zhujg-00 committed Aug 6, 2021
1 parent c00c618 commit 50747eb
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 15 deletions.
6 changes: 4 additions & 2 deletions 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 = "3.0.2"
s.version = "3.0.3"
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 All @@ -9,7 +9,8 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.default_subspec = 'Core'
s.frameworks = 'Foundation', 'SystemConfiguration', 'CoreTelephony'
s.frameworks = 'Foundation', 'SystemConfiguration'

s.libraries = 'icucore', 'sqlite3', 'z'

s.subspec 'Common' do |c|
Expand All @@ -19,6 +20,7 @@ Pod::Spec.new do |s|
c.ios.source_files = "SensorsAnalyticsSDK/RemoteConfig/**/*.{h,m}", "SensorsAnalyticsSDK/ChannelMatch/**/*.{h,m}", "SensorsAnalyticsSDK/Encrypt/**/*.{h,m}", "SensorsAnalyticsSDK/Deeplink/**/*.{h,m}", "SensorsAnalyticsSDK/DebugMode/**/*.{h,m}"
c.ios.public_header_files = "SensorsAnalyticsSDK/Encrypt/SASecretKey.h", "SensorsAnalyticsSDK/ChannelMatch/SensorsAnalyticsSDK+SAChannelMatch.h"
c.ios.resource = 'SensorsAnalyticsSDK/SensorsAnalyticsSDK.bundle'
c.ios.frameworks = 'CoreTelephony'
end

s.subspec 'Core' do |c|
Expand Down
10 changes: 7 additions & 3 deletions SensorsAnalyticsSDK/Core/Builder/SAPresetProperty.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
#endif

#include <sys/sysctl.h>
#import <CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>

#import "SAPresetProperty.h"
#import "SAConstants+Private.h"
#import "SAIdentifier.h"
Expand All @@ -39,6 +36,11 @@
#import "SAModuleManager.h"
#import "SAJSONUtil.h"

#if TARGET_OS_IOS
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>
#endif

//中国运营商 mcc 标识
static NSString* const SACarrierChinaMCC = @"460";

Expand Down Expand Up @@ -198,6 +200,7 @@ + (NSString *)deviceModel {
return result;
}

#if TARGET_OS_IOS
+ (NSString *)carrierName API_UNAVAILABLE(macos) {
NSString *carrierName = nil;

Expand Down Expand Up @@ -262,6 +265,7 @@ + (NSString *)carrierName API_UNAVAILABLE(macos) {
}
return carrierName;
}
#endif

+ (NSString *)appName {
NSString *displayName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
Expand Down
13 changes: 8 additions & 5 deletions SensorsAnalyticsSDK/Core/Network/SANetwork.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
#import "SAJSONUtil.h"
#import "SAHTTPSession.h"
#import "SAReachability.h"

#if TARGET_OS_IOS
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#endif

@interface SANetwork ()

Expand Down Expand Up @@ -164,7 +167,8 @@ + (NSString *)networkTypeString {
return networkTypeString;
}

+ (SensorsAnalyticsNetworkType)networkTypeWWANOptionsWithString:(NSString *)networkTypeString API_UNAVAILABLE(macos) {
#if TARGET_OS_IOS
+ (SensorsAnalyticsNetworkType)networkTypeWWANOptionsWithString:(NSString *)networkTypeString {
if ([@"2G" isEqualToString:networkTypeString]) {
return SensorsAnalyticsNetworkType2G;
} else if ([@"3G" isEqualToString:networkTypeString]) {
Expand All @@ -181,7 +185,7 @@ + (SensorsAnalyticsNetworkType)networkTypeWWANOptionsWithString:(NSString *)netw
return SensorsAnalyticsNetworkTypeNONE;
}

+ (NSString *)networkTypeWWANString API_UNAVAILABLE(macos) {
+ (NSString *)networkTypeWWANString {
if (![SAReachability sharedInstance].isReachableViaWWAN) {
return @"NULL";
}
Expand All @@ -206,7 +210,7 @@ + (NSString *)networkTypeWWANString API_UNAVAILABLE(macos) {
return [SANetwork networkStatusWithRadioAccessTechnology:currentRadioAccessTechnology];
}

+ (NSString *)networkStatusWithRadioAccessTechnology:(NSString *)value API_UNAVAILABLE(macos) {
+ (NSString *)networkStatusWithRadioAccessTechnology:(NSString *)value {
if ([value isEqualToString:CTRadioAccessTechnologyGPRS] ||
[value isEqualToString:CTRadioAccessTechnologyEdge]
) {
Expand All @@ -225,7 +229,6 @@ + (NSString *)networkStatusWithRadioAccessTechnology:(NSString *)value API_UNAVA
return @"4G";
}

#if TARGET_OS_IOS
#ifdef __IPHONE_14_1
else if (@available(iOS 14.1, *)) {
if ([value isEqualToString:CTRadioAccessTechnologyNRNSA] ||
Expand All @@ -234,9 +237,9 @@ + (NSString *)networkStatusWithRadioAccessTechnology:(NSString *)value API_UNAVA
return @"5G";
}
}
#endif
#endif
return @"UNKNOWN";
}
#endif

@end
6 changes: 6 additions & 0 deletions SensorsAnalyticsSDK/Core/SAFileStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ + (BOOL)archiveWithFileName:(NSString *)fileName value:(nullable id)value {
return NO;
}
NSString *filePath = [SAFileStore filePath:fileName];
#if TARGET_OS_IOS
/* 为filePath文件设置保护等级 */
NSDictionary *protection = [NSDictionary dictionaryWithObject:NSFileProtectionComplete
forKey:NSFileProtectionKey];
#elif TARGET_OS_OSX
// macOS10.13 不包含 NSFileProtectionComplete
NSDictionary *protection = [NSDictionary dictionary];
#endif

[[NSFileManager defaultManager] setAttributes:protection
ofItemAtPath:filePath
error:nil];
Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ DeepLink 回调函数
触发 $AppDeepLinkLaunch 事件
@param url 唤起 App 的 DeepLink url
*/
- (void)trackDeepLinkLaunchWithURL:(NSString *)url;
- (void)trackDeepLinkLaunchWithURL:(NSString *)url API_UNAVAILABLE(macos);

@end

Expand Down
20 changes: 16 additions & 4 deletions SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#import "SAProfileEventObject.h"
#import "SAJSONUtil.h"

#define VERSION @"3.0.2"
#define VERSION @"3.0.3"

void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag;

Expand Down Expand Up @@ -253,7 +253,18 @@ - (NSDictionary *)getPresetProperties {
}

- (void)setServerUrl:(NSString *)serverUrl {
#if TARGET_OS_OSX
if (serverUrl && ![serverUrl isKindOfClass:[NSString class]]) {
SALogError(@"%@ serverUrl must be NSString, please check the value!", self);
return;
}
// macOS 暂不支持远程控制,即不支持 setServerUrl: isRequestRemoteConfig: 接口
dispatch_async(self.serialQueue, ^{
self.configOptions.serverURL = serverUrl;
});
#else
[self setServerUrl:serverUrl isRequestRemoteConfig:NO];
#endif
}

- (NSString *)serverUrl {
Expand Down Expand Up @@ -624,12 +635,13 @@ - (void)trackEventObject:(SABaseEventObject *)object properties:(NSDictionary *)
}

- (BOOL)willEnqueueWithObject:(SABaseEventObject *)obj {
if (!self.trackEventCallback || !obj.eventId) {
NSString *eventName = obj.event;
if (!self.trackEventCallback || !eventName) {
return YES;
}
BOOL willEnque = self.trackEventCallback(obj.eventId, obj.properties);
BOOL willEnque = self.trackEventCallback(eventName, obj.properties);
if (!willEnque) {
SALogDebug(@"\n【track event】: %@ can not enter database.", obj.eventId);
SALogDebug(@"\n【track event】: %@ can not enter database.", eventName);
return NO;
}
// 校验 properties
Expand Down

0 comments on commit 50747eb

Please sign in to comment.