Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 4.37.0 #691

Merged
merged 13 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.36.0"
s.version = "4.37.0"
s.summary = "This is the iOS SDK of adjust. You can read more about it at http://adjust.com."
s.homepage = "https://github.com/adjust/ios_sdk"
s.license = { :type => 'MIT', :file => 'MIT-LICENSE' }
s.author = { "Adjust" => "sdk@adjust.com" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.36.0" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.37.0" }
s.ios.deployment_target = '9.0'
s.tvos.deployment_target = '9.0'
s.framework = 'SystemConfiguration'
Expand Down
298 changes: 149 additions & 149 deletions Adjust.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions Adjust/ADJActivityHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
- (NSString *_Nullable)adid;

- (id _Nullable)initWithConfig:(ADJConfig *_Nullable)adjustConfig
savedPreLaunch:(ADJSavedPreLaunch * _Nullable)savedPreLaunch;
savedPreLaunch:(ADJSavedPreLaunch * _Nullable)savedPreLaunch
deeplinkResolutionCallback:(AdjustResolvedDeeplinkBlock _Nullable)deepLinkResolutionCallback;

- (void)applicationDidBecomeActive;
- (void)applicationWillResignActive;
Expand All @@ -83,6 +84,9 @@

- (void)appWillOpenUrl:(NSURL * _Nullable)url
withClickTime:(NSDate * _Nullable)clickTime;
- (void)processDeeplink:(NSURL * _Nullable)deeplink
clickTime:(NSDate * _Nullable)clickTime
completionHandler:(AdjustResolvedDeeplinkBlock _Nullable)completionHandler;
- (void)setDeviceToken:(NSData * _Nullable)deviceToken;
- (void)setPushToken:(NSString * _Nullable)deviceToken;
- (void)setGdprForgetMe;
Expand Down Expand Up @@ -128,8 +132,9 @@

@interface ADJActivityHandler : NSObject <ADJActivityHandler>

- (id _Nullable)initWithConfig:(ADJConfig * _Nullable)adjustConfig
savedPreLaunch:(ADJSavedPreLaunch * _Nullable)savedPreLaunch;
- (id _Nullable)initWithConfig:(ADJConfig *_Nullable)adjustConfig
savedPreLaunch:(ADJSavedPreLaunch * _Nullable)savedPreLaunch
deeplinkResolutionCallback:(AdjustResolvedDeeplinkBlock _Nullable)deepLinkResolutionCallback;

- (void)addSessionCallbackParameterI:(ADJActivityHandler * _Nullable)selfI
key:(NSString * _Nullable)key
Expand Down
30 changes: 27 additions & 3 deletions Adjust/ADJActivityHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ @interface ADJActivityHandler()
@property (nonatomic, copy) NSString* gdprPath;
@property (nonatomic, copy) NSString* subscriptionPath;
@property (nonatomic, copy) NSString* purchaseVerificationPath;
@property (nonatomic, copy) AdjustResolvedDeeplinkBlock cachedDeeplinkResolutionCallback;

- (void)prepareDeeplinkI:(ADJActivityHandler *_Nullable)selfI
responseData:(ADJAttributionResponseData *_Nullable)attributionResponseData NS_EXTENSION_UNAVAILABLE_IOS("");
Expand All @@ -118,9 +119,9 @@ @implementation ADJActivityHandler
@synthesize attribution = _attribution;
@synthesize trackingStatusManager = _trackingStatusManager;

- (id)initWithConfig:(ADJConfig *)adjustConfig
savedPreLaunch:(ADJSavedPreLaunch *)savedPreLaunch
{
- (id)initWithConfig:(ADJConfig *_Nullable)adjustConfig
savedPreLaunch:(ADJSavedPreLaunch * _Nullable)savedPreLaunch
deeplinkResolutionCallback:(AdjustResolvedDeeplinkBlock _Nullable)deepLinkResolutionCallback {
self = [super init];
if (self == nil) return nil;

Expand Down Expand Up @@ -151,6 +152,7 @@ - (id)initWithConfig:(ADJConfig *)adjustConfig
self.adjustConfig = adjustConfig;
self.savedPreLaunch = savedPreLaunch;
self.adjustDelegate = adjustConfig.delegate;
self.cachedDeeplinkResolutionCallback = deepLinkResolutionCallback;

// init logger to be available everywhere
self.logger = ADJAdjustFactory.logger;
Expand Down Expand Up @@ -382,6 +384,17 @@ - (void)appWillOpenUrl:(NSURL *)url withClickTime:(NSDate *)clickTime {
}];
}

- (void)processDeeplink:(NSURL * _Nullable)deeplink
clickTime:(NSDate * _Nullable)clickTime
completionHandler:(AdjustResolvedDeeplinkBlock _Nullable)completionHandler {
[ADJUtil launchInQueue:self.internalQueue
selfInject:self
block:^(ADJActivityHandler * selfI) {
selfI.cachedDeeplinkResolutionCallback = completionHandler;
[selfI appWillOpenUrlI:selfI url:deeplink clickTime:clickTime];
}];
}

- (void)setDeviceToken:(NSData *)deviceToken {
[ADJUtil launchInQueue:self.internalQueue
selfInject:self
Expand Down Expand Up @@ -1556,6 +1569,16 @@ - (void)launchSdkClickResponseTasksI:(ADJActivityHandler *)selfI
selector:@selector(adjustAttributionChanged:)
withObject:sdkClickResponseData.attribution];
}

// check if we got resolved deep link in the response
if (sdkClickResponseData.resolvedDeeplink != nil) {
if (selfI.cachedDeeplinkResolutionCallback != nil) {
[ADJUtil launchInMainThread:^{
selfI.cachedDeeplinkResolutionCallback(sdkClickResponseData.resolvedDeeplink);
selfI.cachedDeeplinkResolutionCallback = nil;
}];
}
}
}

- (void)launchAttributionResponseTasksI:(ADJActivityHandler *)selfI
Expand Down Expand Up @@ -2862,6 +2885,7 @@ - (void)updateAttStatusFromUserCallback:(int)newAttStatusFromUser {
[self.trackingStatusManager updateAttStatusFromUserCallback:newAttStatusFromUser];
}


- (void)processCoppaComplianceI:(ADJActivityHandler *)selfI {
if (!selfI.adjustConfig.coppaCompliantEnabled) {
[self resetThirdPartySharingCoppaActivityStateI:selfI];
Expand Down
5 changes: 5 additions & 0 deletions Adjust/ADJConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,9 @@
*/
@property (nonatomic, assign) BOOL coppaCompliantEnabled;

/**
* @brief Enables caching of device ids to read it only once
*/
@property (nonatomic, assign) BOOL readDeviceInfoOnceEnabled;

@end
1 change: 1 addition & 0 deletions Adjust/ADJConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ - (id)copyWithZone:(NSZone *)zone {
copy->_isSKAdNetworkHandlingActive = self.isSKAdNetworkHandlingActive;
copy->_urlStrategy = [self.urlStrategy copyWithZone:zone];
copy.linkMeEnabled = self.linkMeEnabled;
copy.readDeviceInfoOnceEnabled = self.readDeviceInfoOnceEnabled;
// adjust delegate not copied
}

Expand Down
3 changes: 2 additions & 1 deletion Adjust/ADJPackageBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@

+ (void)addIdfaToParameters:(NSMutableDictionary * _Nullable)parameters
withConfig:(ADJConfig * _Nullable)adjConfig
logger:(id<ADJLogger> _Nullable)logger;
logger:(id<ADJLogger> _Nullable)logger
packageParams:(ADJPackageParams * _Nullable)packageParams;
@end
// TODO change to ADJ...
extern NSString * _Nullable const ADJAttributionTokenParameter;
34 changes: 21 additions & 13 deletions Adjust/ADJPackageBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ - (id)initWithPackageParams:(ADJPackageParams * _Nullable)packageParams
config:(ADJConfig * _Nullable)adjustConfig
sessionParameters:(ADJSessionParameters * _Nullable)sessionParameters
trackingStatusManager:(ADJTrackingStatusManager * _Nullable)trackingStatusManager
createdAt:(double)createdAt
{
createdAt:(double)createdAt {
self = [super init];
if (self == nil) {
return nil;
Expand Down Expand Up @@ -1237,8 +1236,9 @@ - (NSMutableDictionary *)getPurchaseVerificationParameters {

- (void)addIdfaIfPossibleToParameters:(NSMutableDictionary *)parameters {
[ADJPackageBuilder addIdfaToParameters:parameters
withConfig:self.adjustConfig
logger:[ADJAdjustFactory logger]];
withConfig:self.adjustConfig
logger:[ADJAdjustFactory logger]
packageParams:self.packageParams];
}

- (void)addIdfvIfPossibleToParameters:(NSMutableDictionary *)parameters {
Expand Down Expand Up @@ -1374,25 +1374,33 @@ + (BOOL)isAdServicesPackage:(ADJActivityPackage *)activityPackage {

+ (void)addIdfaToParameters:(NSMutableDictionary * _Nullable)parameters
withConfig:(ADJConfig * _Nullable)adjConfig
logger:(id<ADJLogger> _Nullable)logger {

if (! adjConfig.allowIdfaReading) {
logger:(id<ADJLogger> _Nullable)logger
packageParams:(ADJPackageParams *)packageParams {
if (!adjConfig.allowIdfaReading) {
[logger info:@"Cannot read IDFA because it's forbidden by ADJConfig setting"];
return;
}

if (adjConfig.coppaCompliantEnabled) {
[logger info:@"Cannot read IDFA with COPPA enabled"];
return;
}

NSString *idfa = [ADJUtil idfa];
if (idfa == nil
|| idfa.length == 0
|| [idfa isEqualToString:@"00000000-0000-0000-0000-000000000000"])
{
// read once && IDFA not cached
if (adjConfig.readDeviceInfoOnceEnabled && packageParams.idfaCached != nil) {
[ADJPackageBuilder parameters:parameters setString:packageParams.idfaCached forKey:@"idfa"];
return;
}

// read IDFA
NSString *idfa = [ADJUtil idfa];
if (idfa == nil ||
idfa.length == 0 ||
[idfa isEqualToString:@"00000000-0000-0000-0000-000000000000"]) {
return;
}
// cache IDFA
packageParams.idfaCached = idfa;
// add IDFA to payload
[ADJPackageBuilder parameters:parameters setString:idfa forKey:@"idfa"];
}

Expand Down
3 changes: 2 additions & 1 deletion Adjust/ADJPackageHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ - (void)updatePackagesWithIdfaAndAttStatusI:(ADJPackageHandler *)selfI {
[ADJPackageBuilder parameters:activityPackage.parameters setInt:attStatus forKey:@"att_status"];
[ADJPackageBuilder addIdfaToParameters:activityPackage.parameters
withConfig:self.activityHandler.adjustConfig
logger:[ADJAdjustFactory logger]];
logger:[ADJAdjustFactory logger]
packageParams:self.activityHandler.packageParams];
// add to copy queue
[packageQueueCopy addObject:activityPackage];
}
Expand Down
1 change: 1 addition & 0 deletions Adjust/ADJPackageParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@property (nonatomic, copy) NSString *osVersion;
@property (nonatomic, copy) NSString *installedAt;
@property (nonatomic, assign) NSUInteger startedAt;
@property (nonatomic, copy) NSString *idfaCached;

- (id)initWithSdkPrefix:(NSString *)sdkPrefix;

Expand Down
3 changes: 2 additions & 1 deletion Adjust/ADJPurchaseVerificationHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ - (void)updatePackagesWithIdfaAndAttStatusI:(ADJPurchaseVerificationHandler *)se
forKey:@"att_status"];
[ADJPackageBuilder addIdfaToParameters:activityPackage.parameters
withConfig:self.activityHandler.adjustConfig
logger:[ADJAdjustFactory logger]];
logger:[ADJAdjustFactory logger]
packageParams:self.activityHandler.packageParams];
}
}

Expand Down
3 changes: 3 additions & 0 deletions Adjust/ADJResponseData.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ typedef NS_ENUM(int, ADJTrackingState) {
@end

@interface ADJSdkClickResponseData : ADJResponseData

@property (nonatomic, copy) NSString *resolvedDeeplink;

@end

@interface ADJPurchaseVerificationResponseData : ADJResponseData
Expand Down
6 changes: 5 additions & 1 deletion Adjust/ADJSdkClickHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ - (void)updatePackagesWithIdfaAndAttStatusI:(ADJSdkClickHandler *)selfI {
forKey:@"att_status"];
[ADJPackageBuilder addIdfaToParameters:activityPackage.parameters
withConfig:self.activityHandler.adjustConfig
logger:[ADJAdjustFactory logger]];
logger:[ADJAdjustFactory logger]
packageParams:self.activityHandler.packageParams];
}
}

Expand Down Expand Up @@ -237,6 +238,9 @@ - (void)responseCallback:(ADJResponseData *)responseData {
[self.logger info:@"Received Apple Ads click response"];
}

// in case there's resolved_click_url in the response
((ADJSdkClickResponseData *)responseData).resolvedDeeplink = [responseData.jsonResponse objectForKey:@"resolved_click_url"];

[self.activityHandler finishedTracking:responseData];
}

Expand Down
2 changes: 1 addition & 1 deletion Adjust/ADJUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
static NSRegularExpression *shortUniversalLinkRegex = nil;
static NSRegularExpression *excludedDeeplinkRegex = nil;

static NSString * const kClientSdk = @"ios4.36.0";
static NSString * const kClientSdk = @"ios4.37.0";
static NSString * const kDeeplinkParam = @"deep_link=";
static NSString * const kSchemeDelimiter = @"://";
static NSString * const kDefaultScheme = @"AdjustUniversalScheme";
Expand Down
16 changes: 15 additions & 1 deletion Adjust/Adjust.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Adjust.h
// Adjust SDK
//
// V4.36.0
// V4.37.0
// Created by Christian Wellenbrock (@wellle) on 23rd July 2013.
// Copyright (c) 2012-2021 Adjust GmbH. All rights reserved.
//
Expand All @@ -17,6 +17,8 @@
#import "ADJPurchase.h"
#import "ADJPurchaseVerificationResult.h"

typedef void(^AdjustResolvedDeeplinkBlock)(NSString * _Nonnull resolvedLink);

@interface AdjustTestOptions : NSObject

@property (nonatomic, copy, nullable) NSString *baseUrl;
Expand Down Expand Up @@ -137,6 +139,15 @@ extern NSString * __nonnull const ADJDataResidencyUS;
*/
+ (void)appWillOpenUrl:(nonnull NSURL *)url;

/**
* @brief Process the deep link that has opened an app and potentially get a resolved link.
*
* @param deeplink URL object which contains info about adjust deep link.
* @param completionHandler Completion handler where either resolved or echoed deep link will be sent.
*/
+ (void)processDeeplink:(nonnull NSURL *)deeplink
completionHandler:(void (^_Nonnull)(NSString * _Nonnull resolvedLink))completionHandler;

/**
* @brief Set the device token used by push notifications.
*
Expand Down Expand Up @@ -407,6 +418,9 @@ extern NSString * __nonnull const ADJDataResidencyUS;

- (void)appWillOpenUrl:(nonnull NSURL *)url;

- (void)processDeeplink:(nonnull NSURL *)deeplink
completionHandler:(void (^_Nonnull)(NSString * _Nonnull resolvedLink))completionHandler;

- (void)setOfflineMode:(BOOL)enabled;

- (void)setDeviceToken:(nonnull NSData *)deviceToken;
Expand Down
37 changes: 34 additions & 3 deletions Adjust/Adjust.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ @interface Adjust()

@property (nonatomic, strong) ADJSavedPreLaunch *savedPreLaunch;

@property (nonatomic) AdjustResolvedDeeplinkBlock cachedResolvedDeeplinkBlock;

@end

@implementation Adjust
Expand All @@ -78,6 +80,7 @@ - (instancetype)init {
self.activityHandler = nil;
self.logger = [ADJAdjustFactory logger];
self.savedPreLaunch = [[ADJSavedPreLaunch alloc] init];
self.cachedResolvedDeeplinkBlock = nil;
return self;
}

Expand Down Expand Up @@ -126,6 +129,13 @@ + (void)appWillOpenUrl:(NSURL *)url {
}
}

+ (void)processDeeplink:(nonnull NSURL *)deeplink
completionHandler:(void (^_Nonnull)(NSString * _Nonnull resolvedLink))completionHandler {
@synchronized (self) {
[[Adjust getInstance] processDeeplink:deeplink completionHandler:completionHandler];
}
}

+ (void)setDeviceToken:(NSData *)deviceToken {
@synchronized (self) {
[[Adjust getInstance] setDeviceToken:[deviceToken copy]];
Expand Down Expand Up @@ -356,9 +366,9 @@ - (void)appDidLaunch:(ADJConfig *)adjustConfig {
[self.logger error:@"Adjust already initialized"];
return;
}
self.activityHandler = [[ADJActivityHandler alloc]
initWithConfig:adjustConfig
savedPreLaunch:self.savedPreLaunch];
self.activityHandler = [[ADJActivityHandler alloc] initWithConfig:adjustConfig
savedPreLaunch:self.savedPreLaunch
deeplinkResolutionCallback:self.cachedResolvedDeeplinkBlock];
}

- (void)trackEvent:(ADJEvent *)event {
Expand Down Expand Up @@ -409,6 +419,27 @@ - (void)appWillOpenUrl:(NSURL *)url {
[self.activityHandler appWillOpenUrl:url withClickTime:clickTime];
}

- (void)processDeeplink:(nonnull NSURL *)deeplink
completionHandler:(void (^_Nonnull)(NSString * _Nonnull resolvedLink))completionHandler {
// if resolution result is not wanted, fallback to default method
if (completionHandler == nil) {
[self appWillOpenUrl:deeplink];
return;
}
// if deep link processing is triggered prior to SDK being initialized
[ADJUserDefaults cacheDeeplinkUrl:deeplink];
NSDate *clickTime = [NSDate date];
if (![self checkActivityHandler]) {
[ADJUserDefaults saveDeeplinkUrl:deeplink andClickTime:clickTime];
self.cachedResolvedDeeplinkBlock = completionHandler;
return;
}
// if deep link processing was triggered with SDK being initialized
[self.activityHandler processDeeplink:deeplink
clickTime:clickTime
completionHandler:completionHandler];
}

- (void)setDeviceToken:(NSData *)deviceToken {
[ADJUserDefaults savePushTokenData:deviceToken];

Expand Down
Loading