commit | author | age
|
330f2f
|
1 |
/* |
H |
2 |
File: StoreObserver.h |
|
3 |
Abstract: Implements the SKPaymentTransactionObserver protocol. Handles purchasing and restoring products as well as |
|
4 |
downloading hosted content using paymentQueue:updatedTransactions: and paymentQueue:updatedDownloads:, respectively. |
|
5 |
Provides download progress information using SKDownload's progres. Logs the location of the downloaded file using SKDownload's contentURL property. |
|
6 |
|
|
7 |
Version: 1.0 |
|
8 |
|
|
9 |
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple |
|
10 |
Inc. ("Apple") in consideration of your agreement to the following |
|
11 |
terms, and your use, installation, modification or redistribution of |
|
12 |
this Apple software constitutes acceptance of these terms. If you do |
|
13 |
not agree with these terms, please do not use, install, modify or |
|
14 |
redistribute this Apple software. |
|
15 |
|
|
16 |
In consideration of your agreement to abide by the following terms, and |
|
17 |
subject to these terms, Apple grants you a personal, non-exclusive |
|
18 |
license, under Apple's copyrights in this original Apple software (the |
|
19 |
"Apple Software"), to use, reproduce, modify and redistribute the Apple |
|
20 |
Software, with or without modifications, in source and/or binary forms; |
|
21 |
provided that if you redistribute the Apple Software in its entirety and |
|
22 |
without modifications, you must retain this notice and the following |
|
23 |
text and disclaimers in all such redistributions of the Apple Software. |
|
24 |
Neither the name, trademarks, service marks or logos of Apple Inc. may |
|
25 |
be used to endorse or promote products derived from the Apple Software |
|
26 |
without specific prior written permission from Apple. Except as |
|
27 |
expressly stated in this notice, no other rights or licenses, express or |
|
28 |
implied, are granted by Apple herein, including but not limited to any |
|
29 |
patent rights that may be infringed by your derivative works or by other |
|
30 |
works in which the Apple Software may be incorporated. |
|
31 |
|
|
32 |
The Apple Software is provided by Apple on an "AS IS" basis. APPLE |
|
33 |
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION |
|
34 |
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS |
|
35 |
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND |
|
36 |
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. |
|
37 |
|
|
38 |
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL |
|
39 |
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
40 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
41 |
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, |
|
42 |
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED |
|
43 |
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), |
|
44 |
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE |
|
45 |
POSSIBILITY OF SUCH DAMAGE. |
|
46 |
|
|
47 |
Copyright (C) 2014 Apple Inc. All Rights Reserved. |
|
48 |
|
|
49 |
|
|
50 |
*/ |
|
51 |
#import <Foundation/Foundation.h> |
|
52 |
#import <StoreKit/StoreKit.h> |
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
extern NSString * const IAPPurchaseNotification; |
|
57 |
|
|
58 |
@interface StoreObserver : NSObject <SKPaymentTransactionObserver> |
|
59 |
|
|
60 |
typedef NS_ENUM(NSInteger, IAPPurchaseNotificationStatus) |
|
61 |
{ |
|
62 |
IAPPurchaseFailed, |
|
63 |
IAPPurchaseSucceeded, |
|
64 |
IAPRestoredFailed, |
|
65 |
IAPRestoredSucceeded, |
|
66 |
IAPDownloadStarted, |
|
67 |
IAPDownloadInProgress, |
|
68 |
IAPDownloadFailed, |
|
69 |
IAPDownloadSucceeded |
|
70 |
}; |
|
71 |
|
|
72 |
@property (nonatomic) IAPPurchaseNotificationStatus status; |
|
73 |
|
|
74 |
// Keep track of all purchases |
|
75 |
@property (nonatomic, strong) NSMutableArray *productsPurchased; |
|
76 |
// Keep track of all restored purchases |
|
77 |
@property (nonatomic, strong) NSMutableArray *productsRestored; |
|
78 |
|
|
79 |
@property (nonatomic, copy) NSString *message; |
|
80 |
|
|
81 |
@property(nonatomic) float downloadProgress; |
|
82 |
// Keep track of the purchased/restored product's identifier |
|
83 |
@property (nonatomic, copy) NSString *purchasedID; |
|
84 |
|
|
85 |
|
|
86 |
-(BOOL)hasPurchasedProducts; |
|
87 |
-(BOOL)hasRestoredProducts; |
|
88 |
|
|
89 |
+ (StoreObserver *)sharedInstance; |
|
90 |
// Implement the purchase of a product |
|
91 |
-(void)buy:(SKProduct *)product withOrderDict:(NSDictionary*)orderDict; |
|
92 |
// Implement the restoration of previously completed purchases |
|
93 |
-(void)restore; |
|
94 |
/** |
|
95 |
* 发送支付结果给后台 |
|
96 |
* |
|
97 |
* @param skPaymentTransaction |
|
98 |
* @param pStatus |
|
99 |
*/ |
97c340
|
100 |
-(void)postPayNotifyServer:(SKPaymentTransaction*) skPaymentTransaction withStatus:(NSInteger)pStatus isRetry:(BOOL)isRetry; |
330f2f
|
101 |
|
H |
102 |
@end |