From b78cbb0302224ca1ce9c0ba17f30101b761ea340 Mon Sep 17 00:00:00 2001 From: Kamo Spertsyan Date: Wed, 23 Aug 2023 13:53:23 +0300 Subject: [PATCH 1/2] Qonversion usage without initialization fixed. (#391) --- Sources/Qonversion/Public/Qonversion.m | 33 +++++++++++++------ .../Services/QNAPIClient/QNAPIClient.m | 8 ++--- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Sources/Qonversion/Public/Qonversion.m b/Sources/Qonversion/Public/Qonversion.m index 42321fa9..4c160e91 100644 --- a/Sources/Qonversion/Public/Qonversion.m +++ b/Sources/Qonversion/Public/Qonversion.m @@ -32,9 +32,17 @@ @interface Qonversion() @implementation Qonversion +static bool _isInitialized = NO; + // MARK: - Public + (instancetype)initWithConfig:(QONConfiguration *)configuration { + if (_isInitialized) { + return [Qonversion sharedInstance]; + } + + _isInitialized = YES; + QONConfiguration *configCopy = [configuration copy]; [Qonversion sharedInstance].debugMode = configCopy.environment == QONEnvironmentSandbox; [[QNAPIClient shared] setSDKVersion:configCopy.version]; @@ -51,6 +59,21 @@ + (instancetype)initWithConfig:(QONConfiguration *)configuration { return [Qonversion sharedInstance]; } ++ (instancetype)sharedInstance { + if (!_isInitialized) { + QONVERSION_ERROR(@"Attempt to get Qonversion instance before initialization. Please, call `initWithConfig` first."); + return nil; + } + + static id shared = nil; + static dispatch_once_t once; + dispatch_once(&once, ^{ + shared = self.new; + }); + + return shared; +} + - (void)launchWithKey:(nonnull NSString *)key completion:(QONLaunchCompletionHandler)completion { NSString *userID = [[Qonversion sharedInstance].userInfoService obtainUserID]; QONVERSION_LOG(@"🚀 Qonversion initialized with userID: %@", userID); @@ -184,16 +207,6 @@ - (void)handlePurchases:(NSArray *)purchasesInfo co // MARK: - Private -+ (instancetype)sharedInstance { - static id shared = nil; - static dispatch_once_t once; - dispatch_once(&once, ^{ - shared = self.new; - }); - - return shared; -} - - (instancetype)init { self = super.init; if (self) { diff --git a/Sources/Qonversion/Qonversion/Services/QNAPIClient/QNAPIClient.m b/Sources/Qonversion/Qonversion/Services/QNAPIClient/QNAPIClient.m index 79761d05..ec7a5765 100644 --- a/Sources/Qonversion/Qonversion/Services/QNAPIClient/QNAPIClient.m +++ b/Sources/Qonversion/Qonversion/Services/QNAPIClient/QNAPIClient.m @@ -327,10 +327,10 @@ - (NSDictionary *)enrichParameters:(NSDictionary *)parameters { NSMutableDictionary *baseDict = [[NSMutableDictionary alloc] initWithDictionary:_parameters]; baseDict[@"access_token"] = _apiKey; - [baseDict setObject:_userID forKey:@"q_uid"]; - [baseDict setObject:_userID forKey:@"client_uid"]; - [baseDict setObject:self.version forKey:@"version"]; - [baseDict setObject:@(self.debug) forKey:@"debug_mode"]; + baseDict[@"q_uid"] = _userID; + baseDict[@"client_uid"] = _userID; + baseDict[@"version"] = self.version; + baseDict[@"debug_mode"] = @(self.debug); return [baseDict copy]; } From b563917d5cf1238f2fbf1f00d31e5e19d341b2b2 Mon Sep 17 00:00:00 2001 From: SpertsyanKM Date: Wed, 23 Aug 2023 10:55:33 +0000 Subject: [PATCH 2/2] [create-pull-request] automated change --- Framework/Info.plist | 2 +- Qonversion.podspec | 2 +- Sources/Qonversion/Public/QONConfiguration.m | 2 +- fastlane/report.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Framework/Info.plist b/Framework/Info.plist index 11b5baf7..df9138c2 100644 --- a/Framework/Info.plist +++ b/Framework/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 5.0.0 + 5.0.1 CFBundleSignature ???? CFBundleVersion diff --git a/Qonversion.podspec b/Qonversion.podspec index c9955320..e49262bf 100644 --- a/Qonversion.podspec +++ b/Qonversion.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| idfa_exclude_files = ['Sources/Qonversion/IDFA'] s.name = 'Qonversion' s.swift_version = '5.5' - s.version = '5.0.0' + s.version = '5.0.1' s.summary = 'qonversion.io' s.description = <<-DESC Deep Analytics for iOS Subscriptions diff --git a/Sources/Qonversion/Public/QONConfiguration.m b/Sources/Qonversion/Public/QONConfiguration.m index b918b58e..b88b6882 100644 --- a/Sources/Qonversion/Public/QONConfiguration.m +++ b/Sources/Qonversion/Public/QONConfiguration.m @@ -9,7 +9,7 @@ #import "QONConfiguration.h" #import "QNAPIConstants.h" -static NSString *const kSDKVersion = @"5.0.0"; +static NSString *const kSDKVersion = @"5.0.1"; @interface QONConfiguration () diff --git a/fastlane/report.xml b/fastlane/report.xml index d1f28b82..5ad8f75d 100644 --- a/fastlane/report.xml +++ b/fastlane/report.xml @@ -5,12 +5,12 @@ - + - +