![]() |
Ignite Tools
|
00001 /* 00002 Copyright 2009-2011 Urban Airship Inc. All rights reserved. 00003 00004 Redistribution and use in source and binary forms, with or without 00005 modification, are permitted provided that the following conditions are met: 00006 00007 1. Redistributions of source code must retain the above copyright notice, this 00008 list of conditions and the following disclaimer. 00009 00010 2. Redistributions in binaryform must reproduce the above copyright notice, 00011 this list of conditions and the following disclaimer in the documentation 00012 and/or other materials provided withthe distribution. 00013 00014 THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC ``AS IS'' AND ANY EXPRESS OR 00015 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00016 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 00017 EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00018 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00019 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00020 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00021 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00022 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00023 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 */ 00025 00026 #import <StoreKit/StoreKit.h> 00027 #import "UAGlobal.h" 00028 #import "UAirship.h" 00029 #import "UAStoreFrontDelegate.h" 00030 #import "UAStoreFrontAlertProtocol.h" 00031 00032 #define STOREFRONT_UI_CLASS @"UAStoreFrontUI" 00033 00034 UIKIT_EXTERN NSString *const UAContentsDisplayOrderTitle; 00035 UIKIT_EXTERN NSString *const UAContentsDisplayOrderID; 00036 UIKIT_EXTERN NSString *const UAContentsDisplayOrderPrice; 00037 00038 typedef enum { 00039 UAInventoryStatusUnloaded = 0, 00040 UAInventoryStatusPurchaseDisabled, 00041 UAInventoryStatusDownloading, 00042 UAInventoryStatusApple, 00043 UAInventoryStatusLoaded, 00044 UAInventoryStatusFailed, 00045 } UAInventoryStatus; 00046 00047 typedef enum { 00048 ProductTypeAll = 0, 00049 ProductTypeInstalled = 1, 00050 ProductTypeUpdated = 2, 00051 ProductTypeOrigin = 10 00052 } ProductType; 00053 00054 UA_VERSION_INTERFACE(StoreFrontVersion) 00055 00056 @protocol UAStoreFrontUIProtocol 00057 @required 00058 + (void)quitStoreFront; 00059 + (void)displayStoreFront:(UIViewController *)viewController animated:(BOOL)animated; 00060 + (id<UAStoreFrontAlertProtocol>)getAlertHandler; 00061 @end 00062 00063 @protocol UAStoreFrontObserverProtocol 00064 @optional 00065 // will notify this method if restoring status changed 00066 - (void)restoreStatusChanged:(NSNumber*)inRestoring; 00067 // will notify this method if inventory groups updated 00068 - (void)inventoryGroupUpdated; 00069 // will notify this method if inventory loading status changed 00070 - (void)inventoryStatusChanged:(NSNumber *)status; 00071 // will notify this method if anyone of products in the inventory been changed. 00072 // always can be used to control inventory level ui elements (not related to a 00073 // specified product), such as 'restore all' button 00074 - (void)inventoryProductsChanged:(UAProductStatus*)status; 00075 @end 00076 00077 @protocol UAProductObserverProtocol 00078 @optional 00079 - (void)productStatusChanged:(NSNumber*)status; 00080 - (void)productProgressChanged:(NSNumber*)progress; 00081 @end 00082 00083 @class UAInventory; 00084 @class UAStoreKitObserver; 00085 @class UAStoreFrontDownloadManager; 00086 00087 @interface UAStoreFront : NSObject { 00088 UAStoreKitObserver* sfObserver; 00089 UAInventory* inventory; 00090 UAStoreFrontDownloadManager* downloadManager; 00091 00092 NSObject<UAStoreFrontDelegate> *delegate; 00093 NSMutableDictionary* purchaseReceipts; 00094 } 00095 00096 @property (nonatomic, retain, readonly) UAStoreKitObserver* sfObserver; 00097 @property (nonatomic, retain, readonly) UAStoreFrontDownloadManager* downloadManager; 00098 @property (nonatomic, assign) NSObject<UAStoreFrontDelegate> *delegate; 00099 @property (nonatomic, retain) UAInventory* inventory; 00100 @property (nonatomic, retain) NSMutableDictionary* purchaseReceipts; 00101 00102 SINGLETON_INTERFACE(UAStoreFront) 00103 00104 + (void)useCustomUI:(Class)customUIClass; 00105 + (void)quitStoreFront; 00106 00107 /* 00108 Present the store front as modalViewController over viewController 00109 */ 00110 + (void)displayStoreFront:(UIViewController *)viewController animated:(BOOL)animated; 00111 + (void)displayStoreFront:(UIViewController *)viewController withProductID:(NSString *)ID animated:(BOOL)animated; 00112 00113 /* 00114 Set the displaying order of the product items in content tab 00115 Default is order by product ID, descending 00116 */ 00117 + (void)setOrderBy:(NSString *)key; 00118 + (void)setOrderBy:(NSString *)key ascending:(BOOL)ascending; 00119 00120 /* 00121 Directly purchase a specific product 00122 */ 00123 + (void)purchase:(NSString *)productIdentifier; 00124 + (void)land; 00125 00126 /* 00127 inverntory/payment observer registration 00128 */ 00129 + (void)registerObserver:(id)observer; 00130 + (void)unregisterObserver:(id)observer; 00131 00132 - (void)addReceipt:(UAProduct *)product; 00133 - (BOOL)hasReceipt:(UAProduct *)product; 00134 - (BOOL)directoryExistsAtPath:(NSString *)path orOldPath:(NSString *)oldPath; 00135 + (BOOL)setDownloadDirectory:(NSString *)path; 00136 + (BOOL)setDownloadDirectory:(NSString *)path withProductIDSubdir:(BOOL)makeSubdir; 00137 - (Class)uiClass; 00138 00139 /* 00140 load inventory 00141 */ 00142 + (void)loadInventory; 00143 + (void)resetAndLoadInventory; 00144 + (void)reloadInventoryIfFailed; 00145 00146 /* 00147 operations on products 00148 */ 00149 + (NSArray*)productsForType:(ProductType)type; 00150 + (void)updateAllProducts; 00151 + (void)restoreAllProducts; 00152 00153 @end