Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[in_app_puchase_storekit] handle appStoreReceiptURL is nil #7069

Merged
merged 2 commits into from
Feb 1, 2023
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.5+2

* Fix a crash when `appStoreReceiptURL` is nil.

## 0.3.5+1

* Uses the new `sharedDarwinSource` flag when available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ @implementation FIAPReceiptManager

- (NSString *)retrieveReceiptWithError:(FlutterError **)flutterError {
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
if (!receiptURL) {
return nil;
}
NSError *receiptError;
NSData *receipt = [self getReceiptData:receiptURL error:&receiptError];
if (!receipt || receiptError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,23 @@ - (void)testRetrieveReceiptDataSuccess {
XCTAssert([result isKindOfClass:[NSString class]]);
}

- (void)testRetrieveReceiptDataNil {
NSBundle *mockBundle = OCMPartialMock([NSBundle mainBundle]);
OCMStub(mockBundle.appStoreReceiptURL).andReturn(nil);
XCTestExpectation *expectation = [self expectationWithDescription:@"nil receipt data retrieved"];
FlutterMethodCall *call = [FlutterMethodCall
methodCallWithMethodName:@"-[InAppPurchasePlugin retrieveReceiptData:result:]"
arguments:nil];
__block NSDictionary *result;
[self.plugin handleMethodCall:call
result:^(id r) {
result = r;
[expectation fulfill];
}];
[self waitForExpectations:@[ expectation ] timeout:5];
XCTAssertNil(result);
}

- (void)testRetrieveReceiptDataError {
XCTestExpectation *expectation = [self expectationWithDescription:@"receipt data retrieved"];
FlutterMethodCall *call = [FlutterMethodCall
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: in_app_purchase_storekit
description: An implementation for the iOS and macOS platforms of the Flutter `in_app_purchase` plugin. This uses the StoreKit Framework.
repository: https://github.com/flutter/plugins/tree/main/packages/in_app_purchase/in_app_purchase_storekit
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 0.3.5+1
version: 0.3.5+2

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down