This repository has been archived by the owner on Apr 5, 2022. It is now read-only.
forked from saturngod/IAPHelper
-
Notifications
You must be signed in to change notification settings - Fork 2
/
IAPHelper.h
executable file
·41 lines (28 loc) · 1.6 KB
/
IAPHelper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// IAPHelper.h
//
// Original Created by Ray Wenderlich on 2/28/11.
// Created by saturngod on 7/9/12.
// Copyright 2011 Ray Wenderlich. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "StoreKit/StoreKit.h"
#define kProductsLoadedNotification @"ProductsLoaded"
#define kProductPurchasedNotification @"ProductPurchased"
#define kProductPurchaseFailedNotification @"ProductPurchaseFailed"
typedef void (^IAPRequestProductsResponseBlock)(SKProductsRequest *request, SKProductsResponse *response);
// if purchase is successful, error will be nil, and non-nil if an error occurs
typedef void (^IAPBuyProductCompletionBlock)(SKPaymentTransaction *transaction, NSError *error);
// if restore is successful, error will be nil, and non-nil if an error occurs
typedef void (^IAPRestoreProductsCompletionBlock)(SKPaymentQueue *payment, NSError *error);
@interface IAPHelper : NSObject <SKProductsRequestDelegate, SKPaymentTransactionObserver>
@property (nonatomic,strong,readonly) NSSet *productIdentifiers;
@property (nonatomic,strong,readonly) SKProductsRequest *request;
@property (nonatomic,strong,readonly) NSArray *products;
@property (nonatomic,strong,readonly) NSMutableSet *purchasedProducts;
- (id)initWithProductIdentifiers:(NSSet *)productIdentifiers;
- (void)requestProductsWithCompletion:(IAPRequestProductsResponseBlock)completion;
- (void)buyProduct:(SKProduct *)productIdentifier completion:(IAPBuyProductCompletionBlock)completion;
- (void)restoreProductsWithCompletion:(IAPRestoreProductsCompletionBlock)completion;
- (BOOL)isPurchasedProductsIdentifier:(NSString *)productID;
@end