diff --git a/SensorsAnalyticsSDK.podspec b/SensorsAnalyticsSDK.podspec index 319776f2..de9dcd31 100644 --- a/SensorsAnalyticsSDK.podspec +++ b/SensorsAnalyticsSDK.podspec @@ -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}" } @@ -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| @@ -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| diff --git a/SensorsAnalyticsSDK/Core/Builder/SAPresetProperty.m b/SensorsAnalyticsSDK/Core/Builder/SAPresetProperty.m index f1c3e6e9..c694cab1 100644 --- a/SensorsAnalyticsSDK/Core/Builder/SAPresetProperty.m +++ b/SensorsAnalyticsSDK/Core/Builder/SAPresetProperty.m @@ -23,9 +23,6 @@ #endif #include -#import -#import - #import "SAPresetProperty.h" #import "SAConstants+Private.h" #import "SAIdentifier.h" @@ -39,6 +36,11 @@ #import "SAModuleManager.h" #import "SAJSONUtil.h" +#if TARGET_OS_IOS +#import +#import +#endif + //中国运营商 mcc 标识 static NSString* const SACarrierChinaMCC = @"460"; @@ -198,6 +200,7 @@ + (NSString *)deviceModel { return result; } +#if TARGET_OS_IOS + (NSString *)carrierName API_UNAVAILABLE(macos) { NSString *carrierName = nil; @@ -262,6 +265,7 @@ + (NSString *)carrierName API_UNAVAILABLE(macos) { } return carrierName; } +#endif + (NSString *)appName { NSString *displayName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; diff --git a/SensorsAnalyticsSDK/Core/Network/SANetwork.m b/SensorsAnalyticsSDK/Core/Network/SANetwork.m index d3ede47c..a143bd22 100644 --- a/SensorsAnalyticsSDK/Core/Network/SANetwork.m +++ b/SensorsAnalyticsSDK/Core/Network/SANetwork.m @@ -33,7 +33,10 @@ #import "SAJSONUtil.h" #import "SAHTTPSession.h" #import "SAReachability.h" + +#if TARGET_OS_IOS #import +#endif @interface SANetwork () @@ -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]) { @@ -181,7 +185,7 @@ + (SensorsAnalyticsNetworkType)networkTypeWWANOptionsWithString:(NSString *)netw return SensorsAnalyticsNetworkTypeNONE; } -+ (NSString *)networkTypeWWANString API_UNAVAILABLE(macos) { ++ (NSString *)networkTypeWWANString { if (![SAReachability sharedInstance].isReachableViaWWAN) { return @"NULL"; } @@ -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] ) { @@ -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] || @@ -234,9 +237,9 @@ + (NSString *)networkStatusWithRadioAccessTechnology:(NSString *)value API_UNAVA return @"5G"; } } -#endif #endif return @"UNKNOWN"; } +#endif @end diff --git a/SensorsAnalyticsSDK/Core/SAFileStore.m b/SensorsAnalyticsSDK/Core/SAFileStore.m index 876b3352..be3c9084 100644 --- a/SensorsAnalyticsSDK/Core/SAFileStore.m +++ b/SensorsAnalyticsSDK/Core/SAFileStore.m @@ -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]; diff --git a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h index 0a254d27..b073999f 100644 --- a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h +++ b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK+Public.h @@ -687,7 +687,7 @@ DeepLink 回调函数 触发 $AppDeepLinkLaunch 事件 @param url 唤起 App 的 DeepLink url */ -- (void)trackDeepLinkLaunchWithURL:(NSString *)url; +- (void)trackDeepLinkLaunchWithURL:(NSString *)url API_UNAVAILABLE(macos); @end diff --git a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m index 1effc86e..6e74d3d9 100755 --- a/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m +++ b/SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m @@ -41,7 +41,7 @@ #import "SAProfileEventObject.h" #import "SAJSONUtil.h" -#define VERSION @"3.0.2" +#define VERSION @"3.0.3" void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag; @@ -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 { @@ -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