Skip to content

Commit

Permalink
Merge pull request #432 from adjust/v500_sdk2034_sdk2035_sdk2036_sdk2038
Browse files Browse the repository at this point in the history
All the remaining async getters
  • Loading branch information
uerceg authored May 22, 2024
2 parents 8a9e105 + 7a9401f commit ede52cf
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Adjust/ADJActivityHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
- (void)trackAdRevenue:(ADJAdRevenue * _Nullable)adRevenue;
- (void)verifyPurchase:(nonnull ADJPurchase *)purchase
completionHandler:(void (^_Nonnull)(ADJPurchaseVerificationResult * _Nonnull verificationResult))completionHandler;
- (void)attributionWithCallback:(nonnull id<ADJAdjustAttributionCallback>)attributionCallback;
- (void)attributionWithCallback:(nonnull id<ADJAttributionCallback>)attributionCallback;
- (void)setCoppaCompliance:(BOOL)isCoppaComplianceEnabled;

- (ADJPackageParams * _Nullable)packageParams;
Expand Down
6 changes: 3 additions & 3 deletions Adjust/ADJActivityHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ - (void)verifyPurchase:(nonnull ADJPurchase *)purchase
}];
}

- (void)attributionWithCallback:(nonnull id<ADJAdjustAttributionCallback>)attributionCallback {
- (void)attributionWithCallback:(nonnull id<ADJAttributionCallback>)attributionCallback {
__block ADJAttribution *_Nullable localAttribution = self.attribution;

if (localAttribution == nil) {
Expand All @@ -664,7 +664,7 @@ - (void)attributionWithCallback:(nonnull id<ADJAdjustAttributionCallback>)attrib
return;
}

__block id<ADJAdjustAttributionCallback>_Nonnull localAttributionCallback =
__block id<ADJAttributionCallback>_Nonnull localAttributionCallback =
attributionCallback;

[ADJUtil launchInMainThread:^{
Expand Down Expand Up @@ -1606,7 +1606,7 @@ - (void)processCachedAttributionReadCallback {
return;
}

for (id<ADJAdjustAttributionCallback> attributionCallback in
for (id<ADJAttributionCallback> attributionCallback in
self.savedPreLaunch.cachedAttributionReadCallbacksArray)
{
[ADJUtil launchInMainThread:^{
Expand Down
68 changes: 49 additions & 19 deletions Adjust/Adjust.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ typedef void(^AdjustResolvedDeeplinkBlock)(NSString * _Nonnull resolvedLink);

@end

@protocol ADJAdjustAttributionCallback;
@protocol ADJAttributionCallback;
@protocol ADJIdfaCallback;
@protocol ADJIdfvCallback;
@protocol ADJSdkVersionCallback;
@protocol ADJLastDeeplinkCallback;

/**
* Constants for our supported tracking environments.
Expand Down Expand Up @@ -159,18 +163,18 @@ extern NSString * __nonnull const ADJDataResidencyUS;
+ (void)setOfflineMode:(BOOL)enabled;

/**
* @brief Retrieve iOS device IDFA value.
* @brief Retrieve iOS device IDFA value through a callback.
*
* @return Device IDFA value.
* @param idfaCallback Callback to get IDFA value delivered to.
*/
+ (nullable NSString *)idfa;
+ (void)idfaWithCallback:(nonnull id<ADJIdfaCallback>)idfaCallback;

/**
* @brief Retrieve iOS device IDFV value.
* @brief Retrieve iOS device IDFV value through a callback.
*
* @return Device IDFV value.
* @param idfvCallback Callback to get the IDFV value delivered to.
*/
+ (nullable NSString *)idfv;
+ (void)idfvWithCallback:(nonnull id<ADJIdfvCallback>)idfvCallback;


/**
Expand All @@ -188,14 +192,14 @@ extern NSString * __nonnull const ADJDataResidencyUS;
* @note Attribution information is available only after installation has been successfully tracked
* and attribution information arrived after that from the backend.
*/
+ (void)attributionWithCallback:(nonnull id<ADJAdjustAttributionCallback>)attributionCallback;
+ (void)attributionWithCallback:(nonnull id<ADJAttributionCallback>)attributionCallback;

/**
* @brief Get current Adjust SDK version string.
* @brief Get current Adjust SDK version string through a callback.
*
* @return Adjust SDK version string (iosX.Y.Z).
* @param sdkVersionCallback Callback to get the Adjust SDK version string (iosX.Y.Z) delivered to.
*/
+ (nullable NSString *)sdkVersion;
+ (void)sdkVersionWithCallback:(nonnull id<ADJSdkVersionCallback>)sdkVersionCallback;

/**
* @brief Convert a universal link style URL to a deeplink style URL with the corresponding scheme.
Expand Down Expand Up @@ -309,11 +313,11 @@ extern NSString * __nonnull const ADJDataResidencyUS;
completionHandler:(void (^_Nullable)(NSError *_Nullable error))completion;

/**
* @brief Get the last deep link which has opened the app.
* @brief Get the last deep link which has opened the app through a callback.
*
* @return Last deep link which has opened the app.
* @param lastDeeplinkCallback Callback to get the last opened deep link delivered to.
*/
+ (nullable NSURL *)lastDeeplink;
+ (void)lastDeeplinkWithCallback:(nonnull id<ADJLastDeeplinkCallback>)lastDeeplinkCallback;

/**
* @brief Verify in-app-purchase.
Expand Down Expand Up @@ -387,11 +391,13 @@ extern NSString * __nonnull const ADJDataResidencyUS;

- (nullable NSString *)adid;

- (nullable NSString *)idfa;
- (void)idfaWithCallback:(nonnull id<ADJIdfaCallback>)idfaCallback;

- (nullable NSString *)sdkVersion;
- (void)idfvWithCallback:(nonnull id<ADJIdfvCallback>)idfvCallback;

- (void)attributionWithCallback:(nonnull id<ADJAdjustAttributionCallback>)attributionCallback;
- (void)sdkVersionWithCallback:(nonnull id<ADJSdkVersionCallback>)sdkVersionCallback;

- (void)attributionWithCallback:(nonnull id<ADJAttributionCallback>)attributionCallback;

- (nullable NSURL *)convertUniversalLink:(nonnull NSURL *)url withScheme:(nonnull NSString *)scheme;

Expand All @@ -410,7 +416,7 @@ extern NSString * __nonnull const ADJDataResidencyUS;

- (void)trackAdRevenue:(nonnull ADJAdRevenue *)adRevenue;

- (nullable NSURL *)lastDeeplink;
- (void)lastDeeplinkWithCallback:(nonnull id<ADJLastDeeplinkCallback>)lastDeeplinkCallback;

- (void)verifyPurchase:(nonnull ADJPurchase *)purchase
completionHandler:(void (^_Nonnull)(ADJPurchaseVerificationResult * _Nonnull verificationResult))completionHandler;
Expand All @@ -421,8 +427,32 @@ extern NSString * __nonnull const ADJDataResidencyUS;

@end

@protocol ADJAdjustAttributionCallback <NSObject>
@protocol ADJAttributionCallback <NSObject>

- (void)didReadWithAdjustAttribution:(nonnull ADJAttribution *)adjustAttribution;

@end

@protocol ADJIdfaCallback <NSObject>

- (void)didReadWithIdfa:(nullable NSString *)idfa;

@end

@protocol ADJIdfvCallback <NSObject>

- (void)didReadWithIdfv:(nullable NSString *)idfv;

@end

@protocol ADJSdkVersionCallback <NSObject>

- (void)didReadWithSdkVersion:(nullable NSString *)sdkVersion;

@end

@protocol ADJLastDeeplinkCallback <NSObject>

- (void)didReadWithLastDeeplink:(nullable NSURL *)lastDeeplink;

@end
68 changes: 50 additions & 18 deletions Adjust/Adjust.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,21 @@ + (void)setOfflineMode:(BOOL)enabled {
}
}

+ (NSString *)idfa {
+ (void)idfaWithCallback:(nonnull id<ADJIdfaCallback>)idfaCallback {
@synchronized (self) {
return [[Adjust getInstance] idfa];
[[Adjust getInstance] idfaWithCallback:idfaCallback];
}
}

+ (NSString *)idfv {
+ (void)idfvWithCallback:(nonnull id<ADJIdfvCallback>)idfvCallback {
@synchronized (self) {
return [[Adjust getInstance] idfv];
[[Adjust getInstance] idfvWithCallback:idfvCallback];
}
}

+ (NSString *)sdkVersion {
+ (void)sdkVersionWithCallback:(nonnull id<ADJSdkVersionCallback>)sdkVersionCallback {
@synchronized (self) {
return [[Adjust getInstance] sdkVersion];
[[Adjust getInstance] sdkVersionWithCallback:sdkVersionCallback];
}
}

Expand Down Expand Up @@ -257,7 +257,7 @@ + (void)trackAdRevenue:(ADJAdRevenue *)adRevenue {
}
}

+ (void)attributionWithCallback:(nonnull id<ADJAdjustAttributionCallback>)attributionCallback {
+ (void)attributionWithCallback:(nonnull id<ADJAttributionCallback>)attributionCallback {
@synchronized (self) {
[[Adjust getInstance] attributionWithCallback:attributionCallback];
}
Expand All @@ -269,9 +269,9 @@ + (NSString *)adid {
}
}

+ (NSURL *)lastDeeplink {
+ (void)lastDeeplinkWithCallback:(nonnull id<ADJLastDeeplinkCallback>)lastDeeplinkCallback {
@synchronized (self) {
return [[Adjust getInstance] lastDeeplink];
[[Adjust getInstance] lastDeeplinkWithCallback:lastDeeplinkCallback];
}
}

Expand Down Expand Up @@ -415,12 +415,28 @@ - (void)setOfflineMode:(BOOL)enabled {
}
}

- (NSString *)idfa {
return [ADJUtil idfa];
- (void)idfaWithCallback:(nonnull id<ADJIdfaCallback>)idfaCallback {
if (idfaCallback == nil) {
[self.logger error:@"Callback for getting IDFA can't be null"];
return;
}

NSString *idfa = [ADJUtil idfa];
[ADJUtil launchInMainThread:^{
[idfaCallback didReadWithIdfa:idfa];
}];
}

- (NSString *)idfv {
return [ADJUtil idfv];
- (void)idfvWithCallback:(nonnull id<ADJIdfvCallback>)idfvCallback {
if (idfvCallback == nil) {
[self.logger error:@"Callback for getting IDFV can't be null"];
return;
}

NSString *idfv = [ADJUtil idfv];
[ADJUtil launchInMainThread:^{
[idfvCallback didReadWithIdfv:idfv];
}];
}

- (NSURL *)convertUniversalLink:(NSURL *)url withScheme:(NSString *)scheme {
Expand Down Expand Up @@ -580,7 +596,7 @@ - (void)trackAdRevenue:(ADJAdRevenue *)adRevenue {
[self.activityHandler trackAdRevenue:adRevenue];
}

- (void)attributionWithCallback:(nonnull id<ADJAdjustAttributionCallback>)attributionCallback {
- (void)attributionWithCallback:(nonnull id<ADJAttributionCallback>)attributionCallback {
if (attributionCallback == nil) {
[self.logger error:@"Callback for getting attribution can't be null"];
return;
Expand All @@ -604,12 +620,28 @@ - (NSString *)adid {
return [self.activityHandler adid];
}

- (NSString *)sdkVersion {
return [ADJUtil sdkVersion];
- (void)sdkVersionWithCallback:(nonnull id<ADJSdkVersionCallback>)sdkVersionCallback {
if (sdkVersionCallback == nil) {
[self.logger error:@"Callback for getting SDK version can't be null"];
return;
}

NSString *sdkVersion = [ADJUtil sdkVersion];
[ADJUtil launchInMainThread:^{
[sdkVersionCallback didReadWithSdkVersion:sdkVersion];
}];
}

- (NSURL *)lastDeeplink {
return [ADJUserDefaults getCachedDeeplinkUrl];
- (void)lastDeeplinkWithCallback:(nonnull id<ADJLastDeeplinkCallback>)lastDeeplinkCallback {
if (lastDeeplinkCallback == nil) {
[self.logger error:@"Callback for getting last opened deep link can't be null"];
return;
}

NSURL *lastDeeplink = [ADJUserDefaults getCachedDeeplinkUrl];
[ADJUtil launchInMainThread:^{
[lastDeeplinkCallback didReadWithLastDeeplink:lastDeeplink];
}];
}

- (void)verifyPurchase:(nonnull ADJPurchase *)purchase
Expand Down
Loading

0 comments on commit ede52cf

Please sign in to comment.