Skip to content

Commit

Permalink
Merge pull request #631 from adjust/v4320
Browse files Browse the repository at this point in the history
Version 4.32.0
  • Loading branch information
uerceg authored Sep 7, 2022
2 parents fb48fb6 + 77aab70 commit 73e4121
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 21 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.31.0"
s.version = "4.32.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 GmbH" => "[email protected]" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.31.0" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.32.0" }
s.ios.deployment_target = '9.0'
s.tvos.deployment_target = '9.0'
s.framework = 'SystemConfiguration'
Expand Down
3 changes: 3 additions & 0 deletions Adjust/ADJPackageBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,9 @@ - (NSMutableDictionary *)getThirdPartySharingParameters:(nonnull ADJThirdPartySh
[ADJPackageBuilder parameters:parameters
setDictionaryJson:thirdPartySharing.granularOptions
forKey:@"granular_third_party_sharing_options"];
[ADJPackageBuilder parameters:parameters
setDictionaryJson:thirdPartySharing.partnerSharingSettings
forKey:@"partner_sharing_settings"];

if ([self.trackingStatusManager canGetAttStatus]) {
[ADJPackageBuilder parameters:parameters setInt:self.trackingStatusManager.attStatus
Expand Down
9 changes: 7 additions & 2 deletions Adjust/ADJThirdPartySharing.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@

@interface ADJThirdPartySharing : NSObject

@property (nonatomic, nullable, readonly, strong) NSNumber *enabled;
@property (nonatomic, nonnull, readonly, strong) NSMutableDictionary *granularOptions;
@property (nonatomic, nonnull, readonly, strong) NSMutableDictionary *partnerSharingSettings;

- (nullable id)initWithIsEnabledNumberBool:(nullable NSNumber *)isEnabledNumberBool;

- (void)addGranularOption:(nonnull NSString *)partnerName
key:(nonnull NSString *)key
value:(nonnull NSString *)value;

@property (nonatomic, nullable, readonly, strong) NSNumber *enabled;
@property (nonatomic, nonnull, readonly, strong) NSMutableDictionary *granularOptions;
- (void)addPartnerSharingSetting:(nonnull NSString *)partnerName
key:(nonnull NSString *)key
value:(BOOL)value;

@end

28 changes: 22 additions & 6 deletions Adjust/ADJThirdPartySharing.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "ADJThirdPartySharing.h"
#import "ADJAdjustFactory.h"
#import "ADJUtil.h"

@implementation ADJThirdPartySharing

Expand All @@ -17,19 +18,17 @@ - (nullable id)initWithIsEnabledNumberBool:(nullable NSNumber *)isEnabledNumberB
return nil;
}

_granularOptions = [[NSMutableDictionary alloc] init];
_enabled = isEnabledNumberBool;
_granularOptions = [[NSMutableDictionary alloc] init];
_partnerSharingSettings = [[NSMutableDictionary alloc] init];

return self;
}

- (void)addGranularOption:(nonnull NSString *)partnerName
key:(nonnull NSString *)key
value:(nonnull NSString *)value
{
if (partnerName == nil || [partnerName isEqual:[NSNull null]] ||
key == nil || [key isEqual:[NSNull null]] ||
value == nil || [value isEqual:[NSNull null]]) {
value:(nonnull NSString *)value {
if ([ADJUtil isNull:partnerName] || [ADJUtil isNull:key] || [ADJUtil isNull:value]) {
[ADJAdjustFactory.logger error:@"Cannot add granular option with any nil value"];
return;
}
Expand All @@ -43,4 +42,21 @@ - (void)addGranularOption:(nonnull NSString *)partnerName
[partnerOptions setObject:value forKey:key];
}

- (void)addPartnerSharingSetting:(nonnull NSString *)partnerName
key:(nonnull NSString *)key
value:(BOOL)value {
if ([ADJUtil isNull:partnerName] || [ADJUtil isNull:key]) {
[ADJAdjustFactory.logger error:@"Cannot add partner sharing setting with any nil value"];
return;
}

NSMutableDictionary *partnerSharingSetting = [self.partnerSharingSettings objectForKey:partnerName];
if (partnerSharingSetting == nil) {
partnerSharingSetting = [[NSMutableDictionary alloc] init];
[self.partnerSharingSettings setObject:partnerSharingSetting forKey:partnerName];
}

[partnerSharingSetting setObject:[NSNumber numberWithBool:value] forKey:key];
}

@end
4 changes: 4 additions & 0 deletions Adjust/ADJUserDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@

+ (BOOL)getLinkMeChecked;

+ (void)cacheDeeplinkUrl:(NSURL *)deeplink;

+ (NSURL *)getCachedDeeplinkUrl;

@end
10 changes: 10 additions & 0 deletions Adjust/ADJUserDefaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
static NSString * const PREFS_KEY_ADSERVICES_TRACKED = @"adj_adservices_tracked";
static NSString * const PREFS_KEY_SKAD_REGISTER_CALL_TIME = @"adj_skad_register_call_time";
static NSString * const PREFS_KEY_LINK_ME_CHECKED = @"adj_link_me_checked";
static NSString * const PREFS_KEY_DEEPLINK_URL_CACHED = @"adj_deeplink_url_cached";

@implementation ADJUserDefaults

Expand Down Expand Up @@ -147,6 +148,14 @@ + (BOOL)getLinkMeChecked {
return [[NSUserDefaults standardUserDefaults] boolForKey:PREFS_KEY_LINK_ME_CHECKED];
}

+ (void)cacheDeeplinkUrl:(NSURL *)deeplink {
[[NSUserDefaults standardUserDefaults] setURL:deeplink forKey:PREFS_KEY_DEEPLINK_URL_CACHED];
}

+ (NSURL *)getCachedDeeplinkUrl {
return [[NSUserDefaults standardUserDefaults] URLForKey:PREFS_KEY_DEEPLINK_URL_CACHED];
}

+ (void)clearAdjustStuff {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:PREFS_KEY_PUSH_TOKEN_DATA];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:PREFS_KEY_PUSH_TOKEN_STRING];
Expand All @@ -159,6 +168,7 @@ + (void)clearAdjustStuff {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:PREFS_KEY_ADSERVICES_TRACKED];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:PREFS_KEY_SKAD_REGISTER_CALL_TIME];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:PREFS_KEY_LINK_ME_CHECKED];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:PREFS_KEY_DEEPLINK_URL_CACHED];
}

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

static NSString * const kClientSdk = @"ios4.31.0";
static NSString * const kClientSdk = @"ios4.32.0";
static NSString * const kDeeplinkParam = @"deep_link=";
static NSString * const kSchemeDelimiter = @"://";
static NSString * const kDefaultScheme = @"AdjustUniversalScheme";
Expand Down
13 changes: 11 additions & 2 deletions Adjust/Adjust.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Adjust.h
// Adjust SDK
//
// V4.31.0
// V4.32.0
// Created by Christian Wellenbrock (@wellle) on 23rd July 2013.
// Copyright (c) 2012-2021 Adjust GmbH. All rights reserved.
//
Expand Down Expand Up @@ -308,7 +308,7 @@ extern NSString * __nonnull const ADJDataResidencyUS;
/**
* @brief Getter for app tracking authorization status.
*
* return Value of app tracking authorization status.
* @return Value of app tracking authorization status.
*/
+ (int)appTrackingAuthorizationStatus;

Expand All @@ -324,6 +324,13 @@ extern NSString * __nonnull const ADJDataResidencyUS;
*/
+ (void)checkForNewAttStatus;

/**
* @brief Get the last deep link which has opened the app.
*
* @return Last deep link which has opened the app.
*/
+ (nullable NSURL *)lastDeeplink;

/**
* @brief Method used for internal testing only. Don't use it in production.
*/
Expand Down Expand Up @@ -400,4 +407,6 @@ extern NSString * __nonnull const ADJDataResidencyUS;

- (void)checkForNewAttStatus;

- (nullable NSURL *)lastDeeplink;

@end
11 changes: 11 additions & 0 deletions Adjust/Adjust.m
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ + (void)checkForNewAttStatus {
}
}

+ (NSURL *)lastDeeplink {
@synchronized (self) {
return [[Adjust getInstance] lastDeeplink];
}
}

+ (void)setTestOptions:(AdjustTestOptions *)testOptions {
@synchronized (self) {
if (testOptions.teardown) {
Expand Down Expand Up @@ -346,6 +352,7 @@ - (BOOL)isEnabled {
}

- (void)appWillOpenUrl:(NSURL *)url {
[ADJUserDefaults cacheDeeplinkUrl:url];
NSDate *clickTime = [NSDate date];
if (![self checkActivityHandler]) {
[ADJUserDefaults saveDeeplinkUrl:url andClickTime:clickTime];
Expand Down Expand Up @@ -581,6 +588,10 @@ - (void)checkForNewAttStatus {
[self.activityHandler checkForNewAttStatus];
}

- (NSURL *)lastDeeplink {
return [ADJUserDefaults getCachedDeeplinkUrl];
}

- (void)teardown {
if (self.activityHandler == nil) {
[self.logger error:@"Adjust already down or not initialized"];
Expand Down
20 changes: 18 additions & 2 deletions AdjustBridge/AdjustBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -537,21 +537,26 @@ - (void)loadWKWebViewBridge:(WKWebView *)wkWebView
[self.bridgeRegister registerHandler:@"adjust_trackThirdPartySharing" handler:^(id data, WVJBResponseCallback responseCallback) {
id isEnabledO = [data objectForKey:@"isEnabled"];
id granularOptions = [data objectForKey:@"granularOptions"];
id partnerSharingSettings = [data objectForKey:@"partnerSharingSettings"];

NSNumber *isEnabled = nil;
if ([isEnabledO isKindOfClass:[NSNumber class]]) {
isEnabled = (NSNumber *)isEnabledO;
}

ADJThirdPartySharing *adjustThirdPartySharing =
[[ADJThirdPartySharing alloc] initWithIsEnabledNumberBool:isEnabled];

for (int i = 0; i < [granularOptions count]; i += 3) {
NSString *partnerName = [[granularOptions objectAtIndex:i] description];
NSString *key = [[granularOptions objectAtIndex:(i + 1)] description];
NSString *value = [[granularOptions objectAtIndex:(i + 2)] description];
[adjustThirdPartySharing addGranularOption:partnerName key:key value:value];
}
for (int i = 0; i < [partnerSharingSettings count]; i += 3) {
NSString *partnerName = [[partnerSharingSettings objectAtIndex:i] description];
NSString *key = [[partnerSharingSettings objectAtIndex:(i + 1)] description];
BOOL value = [[partnerSharingSettings objectAtIndex:(i + 2)] boolValue];
[adjustThirdPartySharing addPartnerSharingSetting:partnerName key:key value:value];
}

[Adjust trackThirdPartySharing:adjustThirdPartySharing];
}];
Expand All @@ -563,6 +568,17 @@ - (void)loadWKWebViewBridge:(WKWebView *)wkWebView
[Adjust trackMeasurementConsent:[(NSNumber *)data boolValue]];
}];

[self.bridgeRegister registerHandler:@"adjust_checkForNewAttStatus" handler:^(id data, WVJBResponseCallback responseCallback) {
[Adjust checkForNewAttStatus];
}];

[self.bridgeRegister registerHandler:@"adjust_lastDeeplink" handler:^(id data, WVJBResponseCallback responseCallback) {
if (responseCallback == nil) {
return;
}
NSURL *lastDeeplink = [Adjust lastDeeplink];
responseCallback(lastDeeplink != nil ? [lastDeeplink absoluteString] : nil);
}];

[self.bridgeRegister registerHandler:@"adjust_setTestOptions" handler:^(id data, WVJBResponseCallback responseCallback) {
NSString *baseUrl = [data objectForKey:@"baseUrl"];
Expand Down
19 changes: 17 additions & 2 deletions AdjustBridge/AdjustBridgeRegister.m
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ + (NSString *)adjust_js {
WebViewJavascriptBridge.callHandler('adjust_trackMeasurementConsent', consentMeasurement, null);
}
},
checkForNewAttStatus: function() {
if (WebViewJavascriptBridge != null) {
WebViewJavascriptBridge.callHandler('adjust_checkForNewAttStatus', null, null);
}
},
getLastDeeplink: function(callback) {
if (WebViewJavascriptBridge) {
WebViewJavascriptBridge.callHandler('adjust_lastDeeplink', null, callback);
}
},
fbPixelEvent: function(pixelID, evtName, customData) {
if (WebViewJavascriptBridge != null) {
WebViewJavascriptBridge.callHandler('adjust_fbPixelEvent',
Expand All @@ -246,7 +256,7 @@ + (NSString *)adjust_js {
if (this.sdkPrefix) {
return this.sdkPrefix;
} else {
return 'web-bridge4.31.0';
return 'web-bridge4.32.0';
}
},
setTestOptions: function(testOptions) {
Expand Down Expand Up @@ -290,13 +300,18 @@ + (NSString *)adjust_js {
window.AdjustThirdPartySharing = function(isEnabled) {
this.isEnabled = isEnabled;
this.granularOptions = [];
this.partnerSharingSettings = [];
};

AdjustThirdPartySharing.prototype.addGranularOption = function(partnerName, key, value) {
this.granularOptions.push(partnerName);
this.granularOptions.push(key);
this.granularOptions.push(value);
};
AdjustThirdPartySharing.prototype.addPartnerSharingSetting = function(partnerName, key, value) {
this.partnerSharingSettings.push(partnerName);
this.partnerSharingSettings.push(key);
this.partnerSharingSettings.push(value);
};

// Copied from adjust_config.js
window.AdjustConfig = function(appToken, environment, legacy) {
Expand Down
22 changes: 22 additions & 0 deletions AdjustTests/AdjustTestApp/AdjustTestApp/ATAAdjustCommandExecutor.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ - (void)executeCommand:(NSString *)className
[self trackSubscription:parameters];
} else if ([methodName isEqualToString:@"trackAdRevenueV2"]) {
[self trackAdRevenueV2:parameters];
} else if ([methodName isEqualToString:@"getLastDeeplink"]) {
[self getLastDeeplink:parameters];
}
}

Expand Down Expand Up @@ -616,6 +618,16 @@ - (void)thirdPartySharing:(NSDictionary *)parameters {
[adjustThirdPartySharing addGranularOption:partnerName key:key value:value];
}
}

if ([parameters objectForKey:@"partnerSharingSettings"]) {
NSArray *partnerSharingSettings = [parameters objectForKey:@"partnerSharingSettings"];
for (int i = 0; i < partnerSharingSettings.count; i = i + 3) {
NSString *partnerName = partnerSharingSettings[i];
NSString *key = partnerSharingSettings[i + 1];
NSString *value = partnerSharingSettings[i + 2];
[adjustThirdPartySharing addPartnerSharingSetting:partnerName key:key value:[value boolValue]];
}
}

[Adjust trackThirdPartySharing:adjustThirdPartySharing];
}
Expand Down Expand Up @@ -738,4 +750,14 @@ - (void)trackAdRevenueV2:(NSDictionary *)parameters {
[Adjust trackAdRevenue:adRevenue];
}

- (void)getLastDeeplink:(NSDictionary *)parameters {
NSURL * lastDeeplink = [Adjust lastDeeplink];

NSString * lastDeeplinkString = lastDeeplink == nil ? @"" : [lastDeeplink absoluteString];

[self.testLibrary addInfoToSend:@"last_deeplink" value:lastDeeplinkString];

[self.testLibrary sendInfoToServer:self.extraPath];
}

@end
2 changes: 1 addition & 1 deletion AdjustTests/AdjustUnitTests/ADJPackageFields.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ - (id) init {

// default values
self.appToken = @"qwerty123456";
self.clientSdk = @"ios4.31.0";
self.clientSdk = @"ios4.32.0";
self.suffix = @"";
self.environment = @"sandbox";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ AdjustCommandExecutor.prototype.thirdPartySharing = function(params) {
}

var adjustThirdPartySharing = new AdjustThirdPartySharing(isEnabled);

if ('granularOptions' in params) {
var granularOptions = getValues(params, 'granularOptions');
for (var i = 0; i < granularOptions.length; i = i + 3) {
Expand All @@ -603,6 +602,15 @@ AdjustCommandExecutor.prototype.thirdPartySharing = function(params) {
adjustThirdPartySharing.addGranularOption(partnerName, key, value);
}
}
if ('partnerSharingSettings' in params) {
var partnerSharingSettings = getValues(params, 'partnerSharingSettings');
for (var i = 0; i < partnerSharingSettings.length; i = i + 3) {
var partnerName = partnerSharingSettings[i];
var key = partnerSharingSettings[i + 1];
var value = partnerSharingSettings[i + 2];
adjustThirdPartySharing.addPartnerSharingSetting(partnerName, key, value);
}
}

Adjust.trackThirdPartySharing(adjustThirdPartySharing);
};
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### Version 4.32.0 (7th September 2022)
#### Added
- Added partner sharing settings to the third party sharing feature.
- Added `lastDeeplink` getter to `Adjust` API to be able to get last tracked deep link by the SDK.

---

### Version 4.31.0 (18th July 2022)
#### Added
- Added support for `LinkMe` feature.
Expand Down
Loading

0 comments on commit 73e4121

Please sign in to comment.