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

Updated adjust user id fetching logic #547

Merged
merged 3 commits into from
Oct 14, 2024
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
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
Loading