Skip to content

Commit

Permalink
Merge pull request #548 from qonversion/emptyOfferingsFix
Browse files Browse the repository at this point in the history
Empty offerings fix
  • Loading branch information
suriksarkisyan authored Oct 14, 2024
2 parents 310ce33 + cf47363 commit fed3dd7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/Qonversion/Public/QONErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ typedef NS_ERROR_ENUM(QONErrorDomain, QONError) {
QONErrorStorePaymentDeferred = 18,

// No remote configuration for the current user
QONErrorRemoteConfigurationNotAvailable = 19
QONErrorRemoteConfigurationNotAvailable = 19,

// No offerings for the current user
QONErrorOfferingsNotAvailable = 20,

} NS_SWIFT_NAME(Qonversion.Error);

Expand Down Expand Up @@ -131,6 +134,7 @@ typedef NS_ERROR_ENUM(QONErrorDomain, QONAPIError) {
+ (NSError *)errorFromURLDomainError:(NSError *)error;
+ (NSError *)errorFromTransactionError:(NSError *)error;
+ (NSError *)deferredTransactionError;
+ (NSError *)emptyOfferingsError;

@end

7 changes: 7 additions & 0 deletions Sources/Qonversion/Public/QONErrors.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ + (NSError *)deferredTransactionError {
return [self errorWithQonversionErrorCode:QONErrorStorePaymentDeferred userInfo:[userInfo copy]];
}

+ (NSError *)emptyOfferingsError {
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
userInfo[NSLocalizedDescriptionKey] = @"Offerings are not available";

return [self errorWithQonversionErrorCode:QONErrorOfferingsNotAvailable userInfo:[userInfo copy]];
}

+ (NSError *)errorFromTransactionError:(NSError *)error {
QONError errorCode = QONErrorUnknown;
NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,10 @@ - (void)executeOfferingsBlocksWithError:(NSError * _Nullable)error {
QONOfferings *offerings = [self enrichOfferingsWithStoreProducts];
resultError = offerings ? nil : resultError;

if (!offerings && !resultError) {
resultError = [QONErrors emptyOfferingsError];
}

for (QONOfferingsCompletionHandler block in blocks) {
run_block_on_main(block, offerings, resultError);
}
Expand Down

0 comments on commit fed3dd7

Please sign in to comment.