From 8197c8ed7f5962f3ea3d4193092cee48d2461b01 Mon Sep 17 00:00:00 2001 From: Surik Date: Fri, 11 Oct 2024 14:18:48 +0400 Subject: [PATCH 1/3] Updated adjust user id fetching logic --- .../QNUserPropertiesManager.m | 9 ++++--- .../Qonversion/Utils/QNDevice/QNDevice.h | 3 ++- .../Qonversion/Utils/QNDevice/QNDevice.m | 25 +++++++++++-------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Sources/Qonversion/Qonversion/Main/QNUserPropertiesManager/QNUserPropertiesManager.m b/Sources/Qonversion/Qonversion/Main/QNUserPropertiesManager/QNUserPropertiesManager.m index 6a95b294..33cb74e8 100644 --- a/Sources/Qonversion/Qonversion/Main/QNUserPropertiesManager/QNUserPropertiesManager.m +++ b/Sources/Qonversion/Qonversion/Main/QNUserPropertiesManager/QNUserPropertiesManager.m @@ -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]) { diff --git a/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.h b/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.h index f18a543c..93891c84 100644 --- a/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.h +++ b/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.h @@ -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 * _Nullable userId))completion; + @end diff --git a/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m b/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m index 5a84fad0..75716f63 100644 --- a/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m +++ b/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m @@ -258,20 +258,23 @@ - (nullable NSString *)fbAnonID { return nil; } -- (nullable NSString *)adjustUserID { +- (void)adjustUserIDWithCompletion:(void(^)(NSString * _Nullable 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]) { + [Adjust performSelector:adidWithCompletion withObject:completion]; } - - return adidString; } - - return nil; } - (NSString *)vendorID { From 35a3be095325137e6c541d0dc8e10f54953eb557 Mon Sep 17 00:00:00 2001 From: Surik Date: Fri, 11 Oct 2024 16:46:03 +0400 Subject: [PATCH 2/3] Fixed warnings --- Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.h | 2 +- Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.h b/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.h index 93891c84..917e4d3b 100644 --- a/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.h +++ b/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.h @@ -23,6 +23,6 @@ @property (readonly, copy, nonatomic) NSString *installDate; -- (void)adjustUserIDWithCompletion:(void(^)(NSString * _Nullable userId))completion; +- (void)adjustUserIDWithCompletion:(void(^)(NSString *userId))completion; @end diff --git a/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m b/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m index 75716f63..8dfc8e49 100644 --- a/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m +++ b/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m @@ -258,7 +258,7 @@ - (nullable NSString *)fbAnonID { return nil; } -- (void)adjustUserIDWithCompletion:(void(^)(NSString * _Nullable userId))completion { +- (void)adjustUserIDWithCompletion:(void(^)(NSString *userId))completion { Class Adjust = NSClassFromString(@"Adjust"); if (Adjust) { SEL adid = NSSelectorFromString(@"adid"); From 113dbbbcea81d1381a9b79fde55e6b3f4a458ef9 Mon Sep 17 00:00:00 2001 From: Surik Date: Fri, 11 Oct 2024 18:26:22 +0400 Subject: [PATCH 3/3] Fixed checks --- QonversionTests/QDeviceTests.m | 5 ----- Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/QonversionTests/QDeviceTests.m b/QonversionTests/QDeviceTests.m index 72ff6ea5..be166cff 100644 --- a/QonversionTests/QDeviceTests.m +++ b/QonversionTests/QDeviceTests.m @@ -52,9 +52,4 @@ - (void)testVendorID { XCTAssertEqualObjects(_device.vendorID, [[[UIDevice currentDevice] identifierForVendor] UUIDString]); } -- (void)testAfUserID { - XCTAssertNil(_device.afUserID); - XCTAssertNil(_device.adjustUserID); -} - @end diff --git a/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m b/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m index 8dfc8e49..0c216a8e 100644 --- a/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m +++ b/Sources/Qonversion/Qonversion/Utils/QNDevice/QNDevice.m @@ -272,7 +272,10 @@ - (void)adjustUserIDWithCompletion:(void(^)(NSString *userId))completion { completion(adidString); } else if ([Adjust respondsToSelector:adidWithCompletion]) { - [Adjust performSelector:adidWithCompletion withObject:completion]; + id (*imp1)(id, SEL, id) = (id (*)(id, SEL, id))[Adjust methodForSelector:adidWithCompletion]; + if (imp1) { + imp1(Adjust, adidWithCompletion, completion); + } } } }