Skip to content

Commit

Permalink
Merge pull request #46 from adjust/development
Browse files Browse the repository at this point in the history
Add iAd detection
  • Loading branch information
nonelse committed May 2, 2014
2 parents 8a1d1c8 + 224196b commit 2d57ada
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Adjust.podspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Pod::Spec.new do |s|
s.name = "Adjust"
s.version = "3.3.0"
s.version = "3.3.1"
s.summary = "This is the iOS SDK of Adjust. You can read more about it at http://adjust.io."
s.homepage = "http://adjust.io"
s.license = { :type => 'MIT', :file => 'MIT-LICENSE' }
s.author = { "Christian Wellenbrock" => "[email protected]" }
s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v3.3.0" }
s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v3.3.1" }
s.platform = :ios, '4.3'
s.framework = 'SystemConfiguration'
s.weak_framework = 'AdSupport'
s.weak_framework = 'AdSupport', 'iAd'
s.source_files = 'Adjust/*.{h,m}', 'Adjust/AIAdditions/*.{h,m}'
s.requires_arc = true
end
20 changes: 18 additions & 2 deletions Adjust.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
96325E89190E892000A97911 /* iAd.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96325E86190E5CE400A97911 /* iAd.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
96325E8A190E892600A97911 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96325E84190E5CD900A97911 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
96325E8B190E8D6200A97911 /* iAd.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96325E86190E5CE400A97911 /* iAd.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
96325E8C190E8D6B00A97911 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96325E84190E5CD900A97911 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
9679921118BBAE2800394606 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679921018BBAE2800394606 /* Foundation.framework */; };
9679921F18BBAE2800394606 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679921E18BBAE2800394606 /* XCTest.framework */; };
9679922018BBAE2800394606 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9679921018BBAE2800394606 /* Foundation.framework */; };
Expand Down Expand Up @@ -67,6 +71,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
96325E84190E5CD900A97911 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; };
96325E86190E5CE400A97911 /* iAd.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = iAd.framework; path = System/Library/Frameworks/iAd.framework; sourceTree = SDKROOT; };
9679920D18BBAE2800394606 /* libAdjust.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAdjust.a; sourceTree = BUILT_PRODUCTS_DIR; };
9679921018BBAE2800394606 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
9679921D18BBAE2800394606 /* AdjustTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AdjustTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -129,6 +135,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96325E8A190E892600A97911 /* AdSupport.framework in Frameworks */,
96325E89190E892000A97911 /* iAd.framework in Frameworks */,
9679921118BBAE2800394606 /* Foundation.framework in Frameworks */,
96E5E3B918BBB75F008E7B30 /* XCTest.framework in Frameworks */,
);
Expand All @@ -138,6 +146,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
96325E8C190E8D6B00A97911 /* AdSupport.framework in Frameworks */,
96325E8B190E8D6200A97911 /* iAd.framework in Frameworks */,
9679922518BBAE2800394606 /* libAdjust.a in Frameworks */,
9679921F18BBAE2800394606 /* XCTest.framework in Frameworks */,
9679922218BBAE2800394606 /* UIKit.framework in Frameworks */,
Expand Down Expand Up @@ -170,6 +180,8 @@
9679920F18BBAE2800394606 /* Frameworks */ = {
isa = PBXGroup;
children = (
96325E86190E5CE400A97911 /* iAd.framework */,
96325E84190E5CD900A97911 /* AdSupport.framework */,
9679921018BBAE2800394606 /* Foundation.framework */,
9679921E18BBAE2800394606 /* XCTest.framework */,
9679922118BBAE2800394606 /* UIKit.framework */,
Expand Down Expand Up @@ -421,8 +433,9 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DADJUST_NO_IDA";
SDKROOT = iphoneos;
};
name = Debug;
Expand Down Expand Up @@ -452,7 +465,8 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
OTHER_CFLAGS = "-DADJUST_NO_IDA";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
Expand Down Expand Up @@ -505,6 +519,7 @@
"$(inherited)",
);
INFOPLIST_FILE = "AdjustTests/AdjustTests-Info.plist";
OTHER_CFLAGS = "-DADJUST_NO_IDA";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = xctest;
};
Expand All @@ -521,6 +536,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "AdjustTests/Adjust-Prefix.pch";
INFOPLIST_FILE = "AdjustTests/AdjustTests-Info.plist";
OTHER_CFLAGS = "-DADJUST_NO_IDA";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = xctest;
};
Expand Down
16 changes: 16 additions & 0 deletions Adjust/AIActivityHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#import "UIDevice+AIAdditions.h"
#import "NSString+AIAdditions.h"
#import "AIAdjustFactory.h"
#if !ADJUST_NO_IDA
#import <iAd/iAd.h>
#endif

static NSString * const kActivityStateFilename = @"AdjustIoActivityState";
static NSString * const kAdjustPrefix = @"adjust_";
Expand Down Expand Up @@ -44,6 +47,8 @@ @interface AIActivityHandler()
@property (nonatomic, copy) NSString *clientSdk;
@property (nonatomic, assign) BOOL trackingEnabled;
@property (nonatomic, assign) BOOL internalEnabled;
@property (nonatomic, assign) BOOL isIad;
@property (nonatomic, copy) NSString *vendorId;

@end

Expand Down Expand Up @@ -163,6 +168,15 @@ - (void)initInternal:(NSString *)yourAppToken {
self.idForAdvertisers = UIDevice.currentDevice.aiIdForAdvertisers;
self.fbAttributionId = UIDevice.currentDevice.aiFbAttributionId;
self.userAgent = AIUtil.userAgent;
self.vendorId = UIDevice.currentDevice.aiVendorId;

#if !ADJUST_NO_IDA
if (NSClassFromString(@"ADClient")) {
[ADClient.sharedClient determineAppInstallationAttributionWithCompletionHandler:^(BOOL appInstallationWasAttributedToiAd) {
self.isIad = appInstallationWasAttributedToiAd;
}];
}
#endif

self.packageHandler = [AIAdjustFactory packageHandlerForActivityHandler:self];
[self readActivityState];
Expand Down Expand Up @@ -430,6 +444,8 @@ - (void)injectGeneralAttributes:(AIPackageBuilder *)builder {
builder.idForAdvertisers = self.idForAdvertisers;
builder.fbAttributionId = self.fbAttributionId;
builder.environment = self.environment;
builder.isIad = self.isIad;
builder.vendorId = self.vendorId;

if (self.trackMacMd5) {
builder.macShortMd5 = self.macShortMd5;
Expand Down
1 change: 1 addition & 0 deletions Adjust/AIAdditions/UIDevice+AIAdditions.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
- (NSString *)aiDeviceType;
- (NSString *)aiDeviceName;
- (NSString *)aiCreateUuid;
- (NSString *)aiVendorId;

@end
5 changes: 5 additions & 0 deletions Adjust/AIAdditions/UIDevice+AIAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,9 @@ - (NSString *)aiCreateUuid {
return lowerUuid;
}

- (NSString *)aiVendorId {
NSString * vendorId = [UIDevice.currentDevice.identifierForVendor UUIDString];
return vendorId;
}

@end
2 changes: 2 additions & 0 deletions Adjust/AIPackageBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
@property (nonatomic, copy) NSString *clientSdk;
@property (nonatomic, copy) NSString *uuid;
@property (nonatomic, assign) BOOL trackingEnabled;
@property (nonatomic, assign) BOOL isIad;
@property (nonatomic, copy) NSString *vendorId;

// sessions
@property (nonatomic, assign) int sessionCount;
Expand Down
9 changes: 9 additions & 0 deletions Adjust/AIPackageBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ - (NSMutableDictionary *)defaultParameters {
[self parameters:parameters setString:self.fbAttributionId forKey:@"fb_id"];
[self parameters:parameters setString:self.environment forKey:@"environment"];
[self parameters:parameters setInt:self.trackingEnabled forKey:@"tracking_enabled"];
[self parameters:parameters setBool:self.isIad forKey:@"is_iad"];
[self parameters:parameters setString:self.vendorId forKey:@"idfv"];

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

- (void)parameters:(NSMutableDictionary *)parameters setBool:(BOOL)value forKey:(NSString *)key {
if (value < 0) return;

int valueInt = [[NSNumber numberWithBool:value] intValue];

[self parameters:parameters setInt:valueInt forKey:key];
}
@end

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

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

static NSString * const kDateFormat = @"yyyy-MM-dd'T'HH:mm:ss'Z'Z";
static NSDateFormatter * dateFormat;
Expand Down
8 changes: 7 additions & 1 deletion AdjustTests/AIActivityHandlerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ - (void)testFirstRun
AIActivityPackage *activityPackage = (AIActivityPackage *) self.packageHandlerMock.packageQueue[0];

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

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

// is_iad should be false
XCTAssertEqual(NO, [(NSString *)parameters[@"is_iad"] boolValue], @"%@", activityPackage.extendedString);

// vendorId of the simulator
XCTAssertNotNil((NSString *)parameters[@"idfv"], @"%@", activityPackage.extendedString);

// after adding, the activity handler ping the Package handler to send the package
XCTAssert([self.loggerMock containsMessage:AILogLevelTest beginsWith:@"AIPackageHandler sendFirstPackage"],
@"%@", self.loggerMock);
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ If you're using [CocoaPods][cocoapods], you can add the following line to your
`Podfile` and continue with [step 3](#step3):

```ruby
pod 'Adjust', :git => 'git://github.com/adjust/ios_sdk.git', :tag => 'v3.3.0'
pod 'Adjust', :git => 'git://github.com/adjust/ios_sdk.git', :tag => 'v3.3.1'
```

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

![][add]

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

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

![][framework]

Expand Down Expand Up @@ -337,7 +337,7 @@ or add the method `openURL` and add the following call to adjust:
[transition]: http://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html
[drag]: https://raw.github.com/adjust/sdks/master/Resources/ios/drag3.png
[add]: https://raw.github.com/adjust/sdks/master/Resources/ios/add2.png
[framework]: https://raw.github.com/adjust/sdks/master/Resources/ios/framework2.png
[framework]: https://raw.github.com/adjust/sdks/master/Resources/ios/framework3.png
[delegate]: https://raw.github.com/adjust/sdks/master/Resources/ios/delegate3.png
[run]: https://raw.github.com/adjust/sdks/master/Resources/ios/run3.png
[AEPriceMatrix]: https://github.com/adjust/AEPriceMatrix
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.3.1
8 changes: 4 additions & 4 deletions doc/migrate.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Migrate your adjust SDK for iOS to v3.3.0 from v3.0.0
## Migrate your adjust SDK for iOS to v3.3.1 from v3.0.0

We added an optional parameter `transactionId` to our `trackRevenue` methods. If you are tracking In-App Purchases you might want to pass in the transaction identifier provided by Apple to avoid duplicate revenue tracking. It should look roughly like this:

Expand Down Expand Up @@ -36,14 +36,14 @@ all adjust SDK calls.

![][rename]

3. Download version v3.3.0 and drag the new folder `Adjust` into your Xcode
3. Download version v3.3.1 and drag the new folder `Adjust` into your Xcode
Project Navigator.

![][drag]

4. Build your project to confirm that everything is properly connected again.

The adjust SDK v3.3.0 added delegate callbacks. Check out the [README] for
The adjust SDK v3.3.1 added delegate callbacks. Check out the [README] for
details.


Expand Down Expand Up @@ -99,7 +99,7 @@ meaningful at all times! Especially if you are tracking revenue.
1. The `appDidLaunch` method now expects your App Token instead of your App ID.
You can find your App Token in your [dashboard].
2. The adjust SDK for iOS 3.3.0 uses [ARC][arc]. If you haven't done already,
2. The adjust SDK for iOS 3.3.1 uses [ARC][arc]. If you haven't done already,
we recommend [transitioning your project to use ARC][transition] as well. If
you don't want to use ARC, you have to enable ARC for all files of the
adjust SDK. Please consult the [README] for details.
Expand Down

0 comments on commit 2d57ada

Please sign in to comment.