commit | author | age
|
330f2f
|
1 |
/* |
H |
2 |
File: StoreManager.h |
|
3 |
Abstract: Retrieves product information from the App Store using SKRequestDelegate, |
|
4 |
SKProductsRequestDelegate,SKProductsResponse, and SKProductsRequest. |
|
5 |
Notifies its observer with a list of products available for sale along with |
|
6 |
a list of invalid product identifiers. Logs an error message if the product request failed. |
|
7 |
|
|
8 |
Version: 1.0 |
|
9 |
|
|
10 |
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple |
|
11 |
Inc. ("Apple") in consideration of your agreement to the following |
|
12 |
terms, and your use, installation, modification or redistribution of |
|
13 |
this Apple software constitutes acceptance of these terms. If you do |
|
14 |
not agree with these terms, please do not use, install, modify or |
|
15 |
redistribute this Apple software. |
|
16 |
|
|
17 |
In consideration of your agreement to abide by the following terms, and |
|
18 |
subject to these terms, Apple grants you a personal, non-exclusive |
|
19 |
license, under Apple's copyrights in this original Apple software (the |
|
20 |
"Apple Software"), to use, reproduce, modify and redistribute the Apple |
|
21 |
Software, with or without modifications, in source and/or binary forms; |
|
22 |
provided that if you redistribute the Apple Software in its entirety and |
|
23 |
without modifications, you must retain this notice and the following |
|
24 |
text and disclaimers in all such redistributions of the Apple Software. |
|
25 |
Neither the name, trademarks, service marks or logos of Apple Inc. may |
|
26 |
be used to endorse or promote products derived from the Apple Software |
|
27 |
without specific prior written permission from Apple. Except as |
|
28 |
expressly stated in this notice, no other rights or licenses, express or |
|
29 |
implied, are granted by Apple herein, including but not limited to any |
|
30 |
patent rights that may be infringed by your derivative works or by other |
|
31 |
works in which the Apple Software may be incorporated. |
|
32 |
|
|
33 |
The Apple Software is provided by Apple on an "AS IS" basis. APPLE |
|
34 |
MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION |
|
35 |
THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS |
|
36 |
FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND |
|
37 |
OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. |
|
38 |
|
|
39 |
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL |
|
40 |
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
41 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
42 |
INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, |
|
43 |
MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED |
|
44 |
AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), |
|
45 |
STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE |
|
46 |
POSSIBILITY OF SUCH DAMAGE. |
|
47 |
|
|
48 |
Copyright (C) 2014 Apple Inc. All Rights Reserved. |
|
49 |
|
|
50 |
|
|
51 |
*/ |
|
52 |
|
|
53 |
#import <Foundation/Foundation.h> |
|
54 |
#import <StoreKit/StoreKit.h> |
|
55 |
|
|
56 |
@protocol StoreManagerDelegate <NSObject> |
|
57 |
|
|
58 |
- (void)queryAppleProductsDidCompleteWithResult:(NSArray<SKProduct *>*)appleProducts; |
|
59 |
- (void)queryAppleProductsDidError:(NSError *)error; |
|
60 |
|
|
61 |
@end |
|
62 |
|
|
63 |
|
|
64 |
@interface StoreManager : NSObject |
|
65 |
typedef NS_ENUM(NSInteger, IAPProductRequestStatus) |
|
66 |
{ |
|
67 |
IAPProductsFound,// Indicate that there are some valid products |
|
68 |
IAPIdentifiersNotFound, // indicate that are some invalid product identifiers |
|
69 |
IAPRequestFailed // Indicate that the product request failed |
|
70 |
}; |
|
71 |
|
|
72 |
@property (nonatomic, strong) id<StoreManagerDelegate> delegate; |
|
73 |
// Provide the status of the product request |
|
74 |
@property (nonatomic) IAPProductRequestStatus status; |
|
75 |
|
|
76 |
// Keep track of all valid products. These products are available for sale in the App Store |
|
77 |
@property (nonatomic, strong) NSMutableArray *availableProducts; |
|
78 |
|
|
79 |
// Keep track of all invalid product identifiers |
|
80 |
@property (nonatomic, strong) NSMutableArray *invalidProductIds; |
|
81 |
|
|
82 |
// Indicate the cause of the product request failure |
|
83 |
@property (nonatomic, copy) NSString *errorMessage; |
|
84 |
|
|
85 |
+ (StoreManager *)sharedInstance; |
|
86 |
|
|
87 |
// Query the App Store about the given product identifiers |
|
88 |
-(void)fetchProductInformationForIds:(NSArray *)productIds; |
|
89 |
|
|
90 |
// Return the product's title matching a given product identifier |
|
91 |
-(NSString *)titleMatchingProductIdentifier:(NSString *)identifier; |
|
92 |
|
|
93 |
@end |