Skip to content

Commit

Permalink
Merge pull request #140 from adjust/tvos_macro
Browse files Browse the repository at this point in the history
Tvos macro
  • Loading branch information
nonelse committed Nov 13, 2015
2 parents 6b757b2 + 6156c6f commit a77d60d
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 156 deletions.
4 changes: 2 additions & 2 deletions Adjust.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = "Adjust"
s.version = "4.4.1"
s.version = "4.4.2"
s.summary = "This is the iOS SDK of adjust. You can read more about it at http://adjust.com."
s.homepage = "http://adjust.com"
s.license = { :type => 'MIT', :file => 'MIT-LICENSE' }
s.author = { "Christian Wellenbrock" => "welle@adjust.com" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.4.1" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.4.2" }
s.ios.deployment_target = '5.0'
s.tvos.deployment_target = '9.0'
s.framework = 'SystemConfiguration'
Expand Down
6 changes: 4 additions & 2 deletions Adjust.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -712,7 +712,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
OTHER_CFLAGS = "";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand All @@ -725,6 +725,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
DEAD_CODE_STRIPPING = NO;
DSTROOT = /tmp/Adjust.dst;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
Expand All @@ -745,6 +746,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
DEAD_CODE_STRIPPING = NO;
DSTROOT = /tmp/Adjust.dst;
ENABLE_BITCODE = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
Expand Down
8 changes: 4 additions & 4 deletions Adjust/ADJActivityHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,13 @@ - (void)setDeviceToken:(NSData *)deviceToken {

- (void)setIadDate:(NSDate *)iAdImpressionDate withPurchaseDate:(NSDate *)appPurchaseDate {
if (iAdImpressionDate == nil) {
[self.logger verbose:@"iAdImpressionDate not received"];
return;
}

[self.logger verbose:@"iAdImpressionDate received: %@", iAdImpressionDate];


double now = [NSDate.date timeIntervalSince1970];
ADJPackageBuilder *clickBuilder = [[ADJPackageBuilder alloc]
initWithDeviceInfo:self.deviceInfo
Expand Down Expand Up @@ -283,10 +287,6 @@ - (void)initInternal {
[self.logger setLogLevel:self.adjustConfig.logLevel];
}

if (!self.adjustConfig.macMd5TrackingEnabled) {
[self.logger info:@"Tracking of macMd5 is disabled"];
}

if (self.adjustConfig.eventBufferingEnabled) {
[self.logger info:@"Event buffering is enabled"];
}
Expand Down
2 changes: 0 additions & 2 deletions Adjust/ADJAdditions/NSString+ADJAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
@interface NSString(ADJAdditions)

- (NSString *)adjTrim;
- (NSString *)adjMd5;
- (NSString *)adjSha1;
- (NSString *)adjUrlEncode;
- (NSString *)adjRemoveColons;

Expand Down
27 changes: 0 additions & 27 deletions Adjust/ADJAdditions/NSString+ADJAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,12 @@

#import "NSString+ADJAdditions.h"

#import "CommonCrypto/CommonDigest.h"

@implementation NSString(ADJAdditions)

- (NSString *)adjTrim {
return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}

- (NSString *)adjMd5 {
const char *cStr = [self UTF8String];
unsigned char digest[16];
CC_MD5(cStr, (CC_LONG)strlen(cStr), digest);

NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
[output appendFormat:@"%02x", digest[i]];
}
return output;
}

- (NSString *)adjSha1 {
const char *cstr = [self cStringUsingEncoding:NSUTF8StringEncoding];
NSData *data = [NSData dataWithBytes:cstr length:self.length];
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(data.bytes, (CC_LONG)data.length, digest);

NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
[output appendFormat:@"%02x", digest[i]];
}
return output;
}

-(NSString *)adjUrlEncode {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
Expand Down
1 change: 0 additions & 1 deletion Adjust/ADJAdditions/UIDevice+ADJAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
- (BOOL)adjTrackingEnabled;
- (NSString *)adjIdForAdvertisers;
- (NSString *)adjFbAttributionId;
- (NSString *)adjMacAddress;
- (NSString *)adjDeviceType;
- (NSString *)adjDeviceName;
- (NSString *)adjCreateUuid;
Expand Down
66 changes: 11 additions & 55 deletions Adjust/ADJAdditions/UIDevice+ADJAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@
#import "UIDevice+ADJAdditions.h"
#import "NSString+ADJAdditions.h"

#import <sys/socket.h>
#import <sys/sysctl.h>
#import <net/if.h>
#import <net/if_dl.h>

#if !ADJUST_NO_IDFA
#import <AdSupport/ASIdentifierManager.h>
#endif

#ifdef asdfg
#endif
#if !ADJUST_NO_IAD && !defined(TARGET_OS_TV)
#if !ADJUST_NO_IAD && !TARGET_OS_TV
#import <iAd/iAd.h>
#endif

#import "ADJAdjustFactory.h"

@implementation UIDevice(ADJAdditions)

- (BOOL)adjTrackingEnabled {
Expand Down Expand Up @@ -110,53 +108,6 @@ - (NSString *)adjFbAttributionId {
#endif
}

- (NSString *)adjMacAddress {
int mib[6];
size_t len;
char *buf;
unsigned char *ptr;
struct if_msghdr *ifm;
struct sockaddr_dl *sdl;

mib[0] = CTL_NET;
mib[1] = AF_ROUTE;
mib[2] = 0;
mib[3] = AF_LINK;
mib[4] = NET_RT_IFLIST;

if ((mib[5] = if_nametoindex("en0")) == 0) {
printf("Error: if_nametoindex error\n");
return NULL;
}

if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) {
printf("Error: sysctl, take 1\n");
return NULL;
}

if ((buf = malloc(len)) == NULL) {
printf("Could not allocate memory. error!\n");
return NULL;
}

if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) {
printf("Error: sysctl, take 2");
free(buf);
return NULL;
}

ifm = (struct if_msghdr *)buf;
sdl = (struct sockaddr_dl *)(ifm + 1);
ptr = (unsigned char *)LLADDR(sdl);

NSString *macAddress = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
*ptr, *(ptr+1), *(ptr+2), *(ptr+3), *(ptr+4), *(ptr+5)];

free(buf);

return macAddress;
}

- (NSString *)adjDeviceType {
NSString *type = [self.model stringByReplacingOccurrencesOfString:@" " withString:@""];
return type;
Expand Down Expand Up @@ -188,10 +139,15 @@ - (NSString *)adjVendorId {
return @"";
}

- (void) adjSetIad:(ADJActivityHandler *) activityHandler{
#if ADJUST_NO_IAD || defined (TARGET_OS_TV)
- (void) adjSetIad:(ADJActivityHandler *) activityHandler
{
id<ADJLogger> logger = [ADJAdjustFactory logger];

#if ADJUST_NO_IAD || TARGET_OS_TV
[logger debug:@"ADJUST_NO_IAD or TARGET_OS_TV set"];
return;
#else
[logger debug:@"ADJUST_NO_IAD or TARGET_OS_TV not set"];

// [[ADClient sharedClient] lookupAdConversionDetails:...]
Class ADClientClass = NSClassFromString(@"ADClient");
Expand Down
8 changes: 0 additions & 8 deletions Adjust/ADJConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@
*/
@property (nonatomic, assign) BOOL eventBufferingEnabled;

/**
* Disable macMd5 tracking if your privacy constraints require it.
*
* @param macMd5TrackingEnabled Enable or disable tracking of
* the MD5 hash of the MAC address
*/
@property (nonatomic, assign) BOOL macMd5TrackingEnabled;

/**
* Set the optional delegate that will inform you about attribution
*
Expand Down
2 changes: 0 additions & 2 deletions Adjust/ADJConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ - (id) initSelfWithAppToken:(NSString *)appToken

// default values
self.logLevel = ADJLogLevelInfo;
self.macMd5TrackingEnabled = YES;
self.hasDelegate = NO;
self.eventBufferingEnabled = NO;

Expand Down Expand Up @@ -114,7 +113,6 @@ -(id)copyWithZone:(NSZone *)zone
copy.sdkPrefix = [self.sdkPrefix copyWithZone:zone];
copy.defaultTracker = [self.defaultTracker copyWithZone:zone];
copy.eventBufferingEnabled = self.eventBufferingEnabled;
copy.macMd5TrackingEnabled = self.macMd5TrackingEnabled;
copy.hasDelegate = self.hasDelegate;
// adjust delegate not copied
}
Expand Down
2 changes: 0 additions & 2 deletions Adjust/ADJDeviceInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

@interface ADJDeviceInfo : NSObject<NSCopying>

@property (nonatomic, copy) NSString *macSha1;
@property (nonatomic, copy) NSString *macShortMd5;
@property (nonatomic, copy) NSString *idForAdvertisers;
@property (nonatomic, copy) NSString *fbAttributionId;
@property (nonatomic, assign) BOOL trackingEnabled;
Expand Down
6 changes: 0 additions & 6 deletions Adjust/ADJDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ - (id) initWithSdkPrefix:(NSString *)sdkPrefix {
self = [super init];
if (self == nil) return nil;

NSString *macAddress = UIDevice.currentDevice.adjMacAddress;
NSString *macShort = macAddress.adjRemoveColons;
UIDevice *device = UIDevice.currentDevice;
NSLocale *locale = NSLocale.currentLocale;
NSBundle *bundle = NSBundle.mainBundle;
NSDictionary *infoDictionary = bundle.infoDictionary;

self.macSha1 = macAddress.adjSha1;
self.macShortMd5 = macShort.adjMd5;
self.trackingEnabled = UIDevice.currentDevice.adjTrackingEnabled;
self.idForAdvertisers = UIDevice.currentDevice.adjIdForAdvertisers;
self.fbAttributionId = UIDevice.currentDevice.adjFbAttributionId;
Expand Down Expand Up @@ -60,8 +56,6 @@ -(id)copyWithZone:(NSZone *)zone
{
ADJDeviceInfo* copy = [[[self class] allocWithZone:zone] init];
if (copy) {
copy.macSha1 = [self.macSha1 copyWithZone:zone];
copy.macShortMd5 = [self.macShortMd5 copyWithZone:zone];
copy.idForAdvertisers = [self.idForAdvertisers copyWithZone:zone];
copy.fbAttributionId = [self.fbAttributionId copyWithZone:zone];
copy.trackingEnabled = self.trackingEnabled;
Expand Down
24 changes: 0 additions & 24 deletions Adjust/ADJPackageBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ - (NSMutableDictionary *)idsParameters {
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];

[self injectDeviceInfoIds:self.deviceInfo
macMd5TrackingEnabled:self.adjustConfig.macMd5TrackingEnabled
intoParameters:parameters];
[self injectConfig:self.adjustConfig intoParameters:parameters];
[self injectCreatedAt:self.createdAt intoParameters:parameters];
Expand All @@ -145,7 +144,6 @@ - (NSMutableDictionary *)defaultParameters {
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];

[self injectDeviceInfo:self.deviceInfo
macMd5TrackingEnabled:self.adjustConfig.macMd5TrackingEnabled
intoParameters:parameters];
[self injectConfig:self.adjustConfig intoParameters:parameters];
[self injectActivityState:self.activityState intoParamters:parameters];
Expand All @@ -155,24 +153,16 @@ - (NSMutableDictionary *)defaultParameters {
}

- (void) injectDeviceInfoIds:(ADJDeviceInfo *)deviceInfo
macMd5TrackingEnabled:(BOOL) macMd5TrackingEnabled
intoParameters:(NSMutableDictionary *) parameters
{
[self parameters:parameters setString:deviceInfo.macSha1 forKey:@"mac_sha1"];
[self parameters:parameters setString:deviceInfo.idForAdvertisers forKey:@"idfa"];
[self parameters:parameters setString:deviceInfo.vendorId forKey:@"idfv"];

if (macMd5TrackingEnabled) {
[self parameters:parameters setString:deviceInfo.macShortMd5 forKey:@"mac_md5"];
}
}

- (void) injectDeviceInfo:(ADJDeviceInfo *)deviceInfo
macMd5TrackingEnabled:(BOOL) macMd5TrackingEnabled
intoParameters:(NSMutableDictionary *) parameters
{
[self injectDeviceInfoIds:deviceInfo
macMd5TrackingEnabled:macMd5TrackingEnabled
intoParameters:parameters];
[self parameters:parameters setString:deviceInfo.fbAttributionId forKey:@"fb_id"];
[self parameters:parameters setInt:deviceInfo.trackingEnabled forKey:@"tracking_enabled"];
Expand Down Expand Up @@ -277,19 +267,5 @@ - (void)parameters:(NSMutableDictionary *)parameters setNumber:(NSNumber *)value
[self parameters:parameters setString:numberString forKey:key];
}

- (NSMutableDictionary *) joinParamters:(NSMutableDictionary *)permanentParameters
parameters:(NSMutableDictionary *)parameters {
if (permanentParameters == nil) {
return parameters;
}
if (parameters == nil) {
return permanentParameters;
}

NSMutableDictionary *joinedParameters = [[NSMutableDictionary alloc] initWithDictionary:permanentParameters];
[joinedParameters addEntriesFromDictionary:parameters];

return joinedParameters;
}
@end

2 changes: 1 addition & 1 deletion Adjust/ADJUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <sys/xattr.h>

static NSString * const kBaseUrl = @"https://app.adjust.com";
static NSString * const kClientSdk = @"ios4.4.1";
static NSString * const kClientSdk = @"ios4.4.2";

static NSString * const kDateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'Z";
static NSDateFormatter *dateFormat;
Expand Down
9 changes: 0 additions & 9 deletions AdjustTests/ADJActivityHandlerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ - (void)testFirstSession
// test init values
[self checkInit:ADJEnvironmentSandbox logLevel:@"3"];

// check mac mad5 is enabled
anInfo(@"Tracking of macMd5 is disabled");

// check event buffering is disabled
anInfo(@"Event buffering is enabled");

Expand Down Expand Up @@ -131,9 +128,6 @@ - (void)testEventBuffered
// set default tracker
[config setDefaultTracker:@"default1234tracker"];

// set macMd5 disabled
[config setMacMd5TrackingEnabled:NO];

// create handler and start the first session
id<ADJActivityHandler> activityHandler = [ADJActivityHandler handlerWithConfig:config];

Expand All @@ -142,9 +136,6 @@ - (void)testEventBuffered
// test init values
[self checkInit:ADJEnvironmentSandbox logLevel:@"1"];

// check mac mad5 is disabled
aInfo(@"Tracking of macMd5 is disabled");

// check event buffering is enabled
aInfo(@"Event buffering is enabled");

Expand Down
Loading

0 comments on commit a77d60d

Please sign in to comment.