Skip to content

Commit 2d57ada

Browse files
committed
Merge pull request #46 from adjust/development
Add iAd detection
2 parents 8a1d1c8 + 224196b commit 2d57ada

File tree

12 files changed

+73
-18
lines changed

12 files changed

+73
-18
lines changed

Adjust.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Pod::Spec.new do |s|
22
s.name = "Adjust"
3-
s.version = "3.3.0"
3+
s.version = "3.3.1"
44
s.summary = "This is the iOS SDK of Adjust. You can read more about it at http://adjust.io."
55
s.homepage = "http://adjust.io"
66
s.license = { :type => 'MIT', :file => 'MIT-LICENSE' }
77
s.author = { "Christian Wellenbrock" => "[email protected]" }
8-
s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v3.3.0" }
8+
s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v3.3.1" }
99
s.platform = :ios, '4.3'
1010
s.framework = 'SystemConfiguration'
11-
s.weak_framework = 'AdSupport'
11+
s.weak_framework = 'AdSupport', 'iAd'
1212
s.source_files = 'Adjust/*.{h,m}', 'Adjust/AIAdditions/*.{h,m}'
1313
s.requires_arc = true
1414
end

Adjust.xcodeproj/project.pbxproj

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
96325E89190E892000A97911 /* iAd.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96325E86190E5CE400A97911 /* iAd.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
11+
96325E8A190E892600A97911 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96325E84190E5CD900A97911 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
12+
96325E8B190E8D6200A97911 /* iAd.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96325E86190E5CE400A97911 /* iAd.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
13+
96325E8C190E8D6B00A97911 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96325E84190E5CD900A97911 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
1014
9679921118BBAE2800394606 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679921018BBAE2800394606 /* Foundation.framework */; };
1115
9679921F18BBAE2800394606 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679921E18BBAE2800394606 /* XCTest.framework */; };
1216
9679922018BBAE2800394606 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679921018BBAE2800394606 /* Foundation.framework */; };
@@ -67,6 +71,8 @@
6771
/* End PBXCopyFilesBuildPhase section */
6872

6973
/* Begin PBXFileReference section */
74+
96325E84190E5CD900A97911 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; };
75+
96325E86190E5CE400A97911 /* iAd.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = iAd.framework; path = System/Library/Frameworks/iAd.framework; sourceTree = SDKROOT; };
7076
9679920D18BBAE2800394606 /* libAdjust.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAdjust.a; sourceTree = BUILT_PRODUCTS_DIR; };
7177
9679921018BBAE2800394606 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
7278
9679921D18BBAE2800394606 /* AdjustTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AdjustTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -129,6 +135,8 @@
129135
isa = PBXFrameworksBuildPhase;
130136
buildActionMask = 2147483647;
131137
files = (
138+
96325E8A190E892600A97911 /* AdSupport.framework in Frameworks */,
139+
96325E89190E892000A97911 /* iAd.framework in Frameworks */,
132140
9679921118BBAE2800394606 /* Foundation.framework in Frameworks */,
133141
96E5E3B918BBB75F008E7B30 /* XCTest.framework in Frameworks */,
134142
);
@@ -138,6 +146,8 @@
138146
isa = PBXFrameworksBuildPhase;
139147
buildActionMask = 2147483647;
140148
files = (
149+
96325E8C190E8D6B00A97911 /* AdSupport.framework in Frameworks */,
150+
96325E8B190E8D6200A97911 /* iAd.framework in Frameworks */,
141151
9679922518BBAE2800394606 /* libAdjust.a in Frameworks */,
142152
9679921F18BBAE2800394606 /* XCTest.framework in Frameworks */,
143153
9679922218BBAE2800394606 /* UIKit.framework in Frameworks */,
@@ -170,6 +180,8 @@
170180
9679920F18BBAE2800394606 /* Frameworks */ = {
171181
isa = PBXGroup;
172182
children = (
183+
96325E86190E5CE400A97911 /* iAd.framework */,
184+
96325E84190E5CD900A97911 /* AdSupport.framework */,
173185
9679921018BBAE2800394606 /* Foundation.framework */,
174186
9679921E18BBAE2800394606 /* XCTest.framework */,
175187
9679922118BBAE2800394606 /* UIKit.framework */,
@@ -421,8 +433,9 @@
421433
GCC_WARN_UNINITIALIZED_AUTOS = YES;
422434
GCC_WARN_UNUSED_FUNCTION = YES;
423435
GCC_WARN_UNUSED_VARIABLE = YES;
424-
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
436+
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
425437
ONLY_ACTIVE_ARCH = YES;
438+
OTHER_CFLAGS = "-DADJUST_NO_IDA";
426439
SDKROOT = iphoneos;
427440
};
428441
name = Debug;
@@ -452,7 +465,8 @@
452465
GCC_WARN_UNINITIALIZED_AUTOS = YES;
453466
GCC_WARN_UNUSED_FUNCTION = YES;
454467
GCC_WARN_UNUSED_VARIABLE = YES;
455-
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
468+
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
469+
OTHER_CFLAGS = "-DADJUST_NO_IDA";
456470
SDKROOT = iphoneos;
457471
VALIDATE_PRODUCT = YES;
458472
};
@@ -505,6 +519,7 @@
505519
"$(inherited)",
506520
);
507521
INFOPLIST_FILE = "AdjustTests/AdjustTests-Info.plist";
522+
OTHER_CFLAGS = "-DADJUST_NO_IDA";
508523
PRODUCT_NAME = "$(TARGET_NAME)";
509524
WRAPPER_EXTENSION = xctest;
510525
};
@@ -521,6 +536,7 @@
521536
GCC_PRECOMPILE_PREFIX_HEADER = YES;
522537
GCC_PREFIX_HEADER = "AdjustTests/Adjust-Prefix.pch";
523538
INFOPLIST_FILE = "AdjustTests/AdjustTests-Info.plist";
539+
OTHER_CFLAGS = "-DADJUST_NO_IDA";
524540
PRODUCT_NAME = "$(TARGET_NAME)";
525541
WRAPPER_EXTENSION = xctest;
526542
};

Adjust/AIActivityHandler.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#import "UIDevice+AIAdditions.h"
1818
#import "NSString+AIAdditions.h"
1919
#import "AIAdjustFactory.h"
20+
#if !ADJUST_NO_IDA
21+
#import <iAd/iAd.h>
22+
#endif
2023

2124
static NSString * const kActivityStateFilename = @"AdjustIoActivityState";
2225
static NSString * const kAdjustPrefix = @"adjust_";
@@ -44,6 +47,8 @@ @interface AIActivityHandler()
4447
@property (nonatomic, copy) NSString *clientSdk;
4548
@property (nonatomic, assign) BOOL trackingEnabled;
4649
@property (nonatomic, assign) BOOL internalEnabled;
50+
@property (nonatomic, assign) BOOL isIad;
51+
@property (nonatomic, copy) NSString *vendorId;
4752

4853
@end
4954

@@ -163,6 +168,15 @@ - (void)initInternal:(NSString *)yourAppToken {
163168
self.idForAdvertisers = UIDevice.currentDevice.aiIdForAdvertisers;
164169
self.fbAttributionId = UIDevice.currentDevice.aiFbAttributionId;
165170
self.userAgent = AIUtil.userAgent;
171+
self.vendorId = UIDevice.currentDevice.aiVendorId;
172+
173+
#if !ADJUST_NO_IDA
174+
if (NSClassFromString(@"ADClient")) {
175+
[ADClient.sharedClient determineAppInstallationAttributionWithCompletionHandler:^(BOOL appInstallationWasAttributedToiAd) {
176+
self.isIad = appInstallationWasAttributedToiAd;
177+
}];
178+
}
179+
#endif
166180

167181
self.packageHandler = [AIAdjustFactory packageHandlerForActivityHandler:self];
168182
[self readActivityState];
@@ -430,6 +444,8 @@ - (void)injectGeneralAttributes:(AIPackageBuilder *)builder {
430444
builder.idForAdvertisers = self.idForAdvertisers;
431445
builder.fbAttributionId = self.fbAttributionId;
432446
builder.environment = self.environment;
447+
builder.isIad = self.isIad;
448+
builder.vendorId = self.vendorId;
433449

434450
if (self.trackMacMd5) {
435451
builder.macShortMd5 = self.macShortMd5;

Adjust/AIAdditions/UIDevice+AIAdditions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
- (NSString *)aiDeviceType;
1818
- (NSString *)aiDeviceName;
1919
- (NSString *)aiCreateUuid;
20+
- (NSString *)aiVendorId;
2021

2122
@end

Adjust/AIAdditions/UIDevice+AIAdditions.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,9 @@ - (NSString *)aiCreateUuid {
158158
return lowerUuid;
159159
}
160160

161+
- (NSString *)aiVendorId {
162+
NSString * vendorId = [UIDevice.currentDevice.identifierForVendor UUIDString];
163+
return vendorId;
164+
}
165+
161166
@end

Adjust/AIPackageBuilder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
@property (nonatomic, copy) NSString *clientSdk;
2323
@property (nonatomic, copy) NSString *uuid;
2424
@property (nonatomic, assign) BOOL trackingEnabled;
25+
@property (nonatomic, assign) BOOL isIad;
26+
@property (nonatomic, copy) NSString *vendorId;
2527

2628
// sessions
2729
@property (nonatomic, assign) int sessionCount;

Adjust/AIPackageBuilder.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ - (NSMutableDictionary *)defaultParameters {
8888
[self parameters:parameters setString:self.fbAttributionId forKey:@"fb_id"];
8989
[self parameters:parameters setString:self.environment forKey:@"environment"];
9090
[self parameters:parameters setInt:self.trackingEnabled forKey:@"tracking_enabled"];
91+
[self parameters:parameters setBool:self.isIad forKey:@"is_iad"];
92+
[self parameters:parameters setString:self.vendorId forKey:@"idfv"];
9193

9294
// session related (used for events as well)
9395
[self parameters:parameters setInt:self.sessionCount forKey:@"session_count"];
@@ -167,5 +169,12 @@ - (void)parameters:(NSMutableDictionary *)parameters setDictionaryJson:(NSDictio
167169
[self parameters:parameters setString:dictionaryString forKey:key];
168170
}
169171

172+
- (void)parameters:(NSMutableDictionary *)parameters setBool:(BOOL)value forKey:(NSString *)key {
173+
if (value < 0) return;
174+
175+
int valueInt = [[NSNumber numberWithBool:value] intValue];
176+
177+
[self parameters:parameters setInt:valueInt forKey:key];
178+
}
170179
@end
171180

Adjust/AIUtil.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <sys/xattr.h>
1515

1616
static NSString * const kBaseUrl = @"https://app.adjust.io";
17-
static NSString * const kClientSdk = @"ios3.3.0";
17+
static NSString * const kClientSdk = @"ios3.3.1";
1818

1919
static NSString * const kDateFormat = @"yyyy-MM-dd'T'HH:mm:ss'Z'Z";
2020
static NSDateFormatter * dateFormat;

AdjustTests/AIActivityHandlerTests.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ - (void)testFirstRun
8888
AIActivityPackage *activityPackage = (AIActivityPackage *) self.packageHandlerMock.packageQueue[0];
8989

9090
// check the Sdk version is being tested
91-
XCTAssertEqual(@"ios3.3.0", activityPackage.clientSdk, @"%@", activityPackage.extendedString);
91+
XCTAssertEqual(@"ios3.3.1", activityPackage.clientSdk, @"%@", activityPackage.extendedString);
9292

9393
// packageType should be SESSION_START
9494
XCTAssertEqual(@"/startup", activityPackage.path, @"%@", activityPackage.extendedString);
@@ -112,6 +112,12 @@ - (void)testFirstRun
112112
// lastInterval -1, same as before
113113
XCTAssertNil(parameters[@"last_interval"], @"%@", activityPackage.extendedString);
114114

115+
// is_iad should be false
116+
XCTAssertEqual(NO, [(NSString *)parameters[@"is_iad"] boolValue], @"%@", activityPackage.extendedString);
117+
118+
// vendorId of the simulator
119+
XCTAssertNotNil((NSString *)parameters[@"idfv"], @"%@", activityPackage.extendedString);
120+
115121
// after adding, the activity handler ping the Package handler to send the package
116122
XCTAssert([self.loggerMock containsMessage:AILogLevelTest beginsWith:@"AIPackageHandler sendFirstPackage"],
117123
@"%@", self.loggerMock);

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ If you're using [CocoaPods][cocoapods], you can add the following line to your
1313
`Podfile` and continue with [step 3](#step3):
1414

1515
```ruby
16-
pod 'Adjust', :git => 'git://github.com/adjust/ios_sdk.git', :tag => 'v3.3.0'
16+
pod 'Adjust', :git => 'git://github.com/adjust/ios_sdk.git', :tag => 'v3.3.1'
1717
```
1818

1919
### 1. Get the SDK
@@ -35,14 +35,14 @@ radio button to `Create groups for any added folders`.
3535

3636
![][add]
3737

38-
### <a id="step3"></a>3. Add the AdSupport framework
38+
### <a id="step3"></a>3. Add the AdSupport and iAd framework
3939

4040
In the Project Navigator select your project. In the left hand side of the main
4141
view select your target. In the tab `Build Phases` expand the group `Link
4242
Binary with Libraries`. On the bottom of that group click on the `+` button.
43-
Select the `AdSupport.framework` and click the `Add` button. In the list of
44-
frameworks select the newly added `AdSupport.framework` and change the
45-
attribute `Required` to `Optional`.
43+
Select the `AdSupport.framework` and click the `Add` button. Repeat the same step to
44+
add the `iAd.framework`. In the list of frameworks select the newly added `AdSupport.framework`
45+
and `iAd.framework`. Change the attribute `Required` to `Optional`.
4646

4747
![][framework]
4848

@@ -337,7 +337,7 @@ or add the method `openURL` and add the following call to adjust:
337337
[transition]: http://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html
338338
[drag]: https://raw.github.com/adjust/sdks/master/Resources/ios/drag3.png
339339
[add]: https://raw.github.com/adjust/sdks/master/Resources/ios/add2.png
340-
[framework]: https://raw.github.com/adjust/sdks/master/Resources/ios/framework2.png
340+
[framework]: https://raw.github.com/adjust/sdks/master/Resources/ios/framework3.png
341341
[delegate]: https://raw.github.com/adjust/sdks/master/Resources/ios/delegate3.png
342342
[run]: https://raw.github.com/adjust/sdks/master/Resources/ios/run3.png
343343
[AEPriceMatrix]: https://github.com/adjust/AEPriceMatrix

0 commit comments

Comments
 (0)