Skip to content

Commit

Permalink
Merge pull request #547 from qonversion/adjustFix
Browse files Browse the repository at this point in the history
Updated adjust user id fetching logic
  • Loading branch information
suriksarkisyan authored Oct 14, 2024
2 parents c661d3f + 113dbbb commit 310ce33
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
5 changes: 0 additions & 5 deletions QonversionTests/QDeviceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,4 @@ - (void)testVendorID {
XCTAssertEqualObjects(_device.vendorID, [[[UIDevice currentDevice] identifierForVendor] UUIDString]);
}

- (void)testAfUserID {
XCTAssertNil(_device.afUserID);
XCTAssertNil(_device.adjustUserID);
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,11 @@ - (void)collectIntegrationsData {
}

- (void)collectIntegrationsDataInBackground {
NSString *adjustUserID = _device.adjustUserID;
if (![QNUtils isEmptyString:adjustUserID]) {
[self setUserProperty:@"_q_adjust_adid" value:adjustUserID];
}
[_device adjustUserIDWithCompletion:^(NSString * _Nullable userId) {
if (![QNUtils isEmptyString:userId]) {
[self setUserProperty:@"_q_adjust_adid" value:userId];
}
}];

NSString *fbAnonID = _device.fbAnonID;
if (![QNUtils isEmptyString:fbAnonID]) {
Expand Down
3 changes: 2 additions & 1 deletion Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
@property (readonly, copy, nonatomic) NSString *vendorID;

@property (readonly, copy, nonatomic) NSString *afUserID;
@property (readonly, copy, nonatomic) NSString *adjustUserID;
@property (readonly, copy, nonatomic) NSString *fbAnonID;

@property (readonly, copy, nonatomic) NSString *installDate;

- (void)adjustUserIDWithCompletion:(void(^)(NSString *userId))completion;

@end
28 changes: 17 additions & 11 deletions Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,26 @@ - (nullable NSString *)fbAnonID {
return nil;
}

- (nullable NSString *)adjustUserID {
- (void)adjustUserIDWithCompletion:(void(^)(NSString *userId))completion {
Class Adjust = NSClassFromString(@"Adjust");
SEL adid = NSSelectorFromString(@"adid");
if (Adjust && adid) {
id (*imp1)(id, SEL) = (id (*)(id, SEL))[Adjust methodForSelector:adid];
NSString *adidString = nil;
if (imp1) {
adidString = imp1(Adjust, adid);
if (Adjust) {
SEL adid = NSSelectorFromString(@"adid");
SEL adidWithCompletion = NSSelectorFromString(@"adidWithCompletionHandler:");
if ([Adjust respondsToSelector:adid]) {
id (*imp1)(id, SEL) = (id (*)(id, SEL))[Adjust methodForSelector:adid];
NSString *adidString = nil;
if (imp1) {
adidString = imp1(Adjust, adid);
}

completion(adidString);
} else if ([Adjust respondsToSelector:adidWithCompletion]) {
id (*imp1)(id, SEL, id) = (id (*)(id, SEL, id))[Adjust methodForSelector:adidWithCompletion];
if (imp1) {
imp1(Adjust, adidWithCompletion, completion);
}
}

return adidString;
}

return nil;
}

- (NSString *)vendorID {
Expand Down

0 comments on commit 310ce33

Please sign in to comment.