Skip to content

Commit bca1fe6

Browse files
committed
Fix PFPurchase block nullability annotations.
1 parent 0003438 commit bca1fe6

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Parse/PFPurchase.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
PF_ASSUME_NONNULL_BEGIN
1919

20+
typedef void (^PFPurchaseProductObservationBlock)(SKPaymentTransaction *transaction);
21+
typedef void (^PFPurchaseBuyProductResultBlock)(NSError *PF_NULLABLE_S error);
22+
typedef void (^PFPurchaseDownloadAssetResultBlock)(NSString *PF_NULLABLE_S filePath, NSError *PF_NULLABLE_S error);
23+
2024
/*!
2125
`PFPurchase` provides a set of APIs for working with in-app purchases.
2226
@@ -35,16 +39,15 @@ PF_ASSUME_NONNULL_BEGIN
3539
@param productIdentifier the product identifier
3640
@param block The block to be run when buying a product.
3741
*/
38-
+ (void)addObserverForProduct:(NSString *)productIdentifier
39-
block:(void(^)(SKPaymentTransaction *transaction))block;
42+
+ (void)addObserverForProduct:(NSString *)productIdentifier block:(PFPurchaseProductObservationBlock)block;
4043

4144
/*!
4245
@abstract *Asynchronously* initiates the purchase for the product.
4346
4447
@param productIdentifier the product identifier
4548
@param block the completion block.
4649
*/
47-
+ (void)buyProduct:(NSString *)productIdentifier block:(void(^)(NSError *error))block;
50+
+ (void)buyProduct:(NSString *)productIdentifier block:(PFPurchaseBuyProductResultBlock)block;
4851

4952
/*!
5053
@abstract *Asynchronously* download the purchased asset, which is stored on Parse's server.
@@ -55,7 +58,7 @@ PF_ASSUME_NONNULL_BEGIN
5558
@param completion the completion block.
5659
*/
5760
+ (void)downloadAssetForTransaction:(SKPaymentTransaction *)transaction
58-
completion:(void(^)(NSString *filePath, NSError *error))completion;
61+
completion:(PFPurchaseDownloadAssetResultBlock)completion;
5962

6063
/*!
6164
@abstract *Asynchronously* download the purchased asset, which is stored on Parse's server.
@@ -67,7 +70,7 @@ PF_ASSUME_NONNULL_BEGIN
6770
@param progress the progress block, which is called multiple times to reveal progress of the download.
6871
*/
6972
+ (void)downloadAssetForTransaction:(SKPaymentTransaction *)transaction
70-
completion:(void(^)(NSString *filePath, NSError *error))completion
73+
completion:(PFPurchaseDownloadAssetResultBlock)completion
7174
progress:(PF_NULLABLE PFProgressBlock)progress;
7275

7376
/*!

Parse/PFPurchase.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ @implementation PFPurchase
2424
#pragma mark - Public
2525
///--------------------------------------
2626

27-
+ (void)addObserverForProduct:(NSString *)productIdentifier block:(void(^)(SKPaymentTransaction *))block {
27+
+ (void)addObserverForProduct:(NSString *)productIdentifier block:(PFPurchaseProductObservationBlock)block {
2828
// We require the following method to run on the main thread because we want to add the observer
2929
// *after* all products handlers have been added. Developers might be calling this method multiple
3030
// times; and if the observer is added after the first call, the observer might not know how to
@@ -37,7 +37,7 @@ + (void)addObserverForProduct:(NSString *)productIdentifier block:(void(^)(SKPay
3737
[[Parse _currentManager].purchaseController.transactionObserver handle:productIdentifier block:block];
3838
}
3939

40-
+ (void)buyProduct:(NSString *)productIdentifier block:(void(^)(NSError *))completion {
40+
+ (void)buyProduct:(NSString *)productIdentifier block:(PFPurchaseBuyProductResultBlock)completion {
4141
[[[self _purchaseController] buyProductAsyncWithIdentifier:productIdentifier] continueWithBlock:^id(BFTask *task) {
4242
if (completion) {
4343
completion(task.error);
@@ -50,12 +50,13 @@ + (void)restore {
5050
[[self _purchaseController].paymentQueue restoreCompletedTransactions];
5151
}
5252

53-
+ (void)downloadAssetForTransaction:(SKPaymentTransaction *)transaction completion:(PFStringResultBlock)completion {
53+
+ (void)downloadAssetForTransaction:(SKPaymentTransaction *)transaction
54+
completion:(PFPurchaseDownloadAssetResultBlock)completion {
5455
[self downloadAssetForTransaction:transaction completion:completion progress:nil];
5556
}
5657

5758
+ (void)downloadAssetForTransaction:(SKPaymentTransaction *)transaction
58-
completion:(PFStringResultBlock)completion
59+
completion:(PFPurchaseDownloadAssetResultBlock)completion
5960
progress:(PFProgressBlock)progress {
6061
@weakify(self);
6162
[[[PFUser _getCurrentUserSessionTokenAsync] continueWithBlock:^id(BFTask *task) {

0 commit comments

Comments
 (0)