//
// DYFIAPHelper.h
//
// Created by dyf on 15/11/4.
// Copyright (c) 2015 dyf. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
typedef NS_ENUM(NSInteger, DYFIAPProductRequestStatus) {
DYFIAPProductFound, // Indicates that there are a valid product.
DYFIAPProductsFound, // Indicates that there are some valid products.
DYFIAPIdentifiersNotFound, // indicates that are some invalid product identifiers.
DYFIAPProductRequestResponse, // Returns valid products and invalid product identifiers.
DYFIAPRequestFailed // Indicates that the product request failed.
};
typedef NS_ENUM(NSInteger, DYFIAPPurchaseNotificationStatus) {
DYFIAPStatusPurchasing, // Indicates that the status is purchasing.
DYFIAPPurchaseFailed, // Indicates that the purchase was unsuccessful.
DYFIAPPurchaseSucceeded, // Indicates that the purchase was successful.
DYFIAPRestoredFailed, // Indicates that restoring products was unsuccessful.
DYFIAPRestoredSucceeded, // Indicates that restoring products was successful.
DYFIAPDownloadStarted, // Indicates that downloading a hosted content has started.
DYFIAPDownloadInProgress, // Indicates that a hosted content is currently being downloaded.
DYFIAPDownloadFailed, // Indicates that downloading a hosted content failed.
DYFIAPDownloadSucceeded // Indicates that a hosted content was successfully downloaded.
};
// Provides notification about the purchase.
FOUNDATION_EXPORT NSString * __nonnull const DYFIAPPurchaseNotification;
@interface DYFIAPPurchaseNotificationObject : NSObject
// Keeps track of the purchase's status.
@property (nonatomic, assign) DYFIAPPurchaseNotificationStatus status;
// The message indicates an error that occurred.
@property (nonatomic, copy, nullable) NSString *message;
// A value that indicates how much of the file has been downloaded.
@property (nonatomic, assign) float downloadProgress;
// Keeps track of the purchase's transactionIdentifier.
@property (nonatomic, copy, nullable) NSString *transactionId;
@end
@protocol DYFIAPHelperDelegate <NSObject>
// Tells the delegate that the request has completed.
- (void)productRequestDidComplete;
@end
@interface DYFIAPHelper : NSObject <SKProductsRequestDelegate, SKPaymentTransactionObserver>
// The delegate that receives the response of the request.
@property (nonatomic, weak, nullable) id<DYFIAPHelperDelegate> delegate;
// Provides the status of the product request.
@property (nonatomic, assign) DYFIAPProductRequestStatus productRequestStatus;
// Provides an `NSError` object of the product request. The error that caused the request to fail.
@property (nonatomic, strong, nullable) NSError *productRequestError;
// Keeps track of all valid products. These products are available for sale in the App Store.
@property (nonatomic, strong, nullable) NSMutableArray *availableProducts;
// Keeps track of all invalid product identifiers.
@property (nonatomic, strong, nullable) NSMutableArray *invalidProductIds;
// Keeps track of all purchases.
@property (nonatomic, strong, nullable) NSMutableArray *purchasedProducts;
// Keeps track of all restored purchases.
@property (nonatomic, strong, nullable) NSMutableArray *restoredProducts;
// Returns an `DYFIAPHelper` instance.
+ (nullable instancetype)helper;
// Queries the App Store about the given product identifier.
- (void)requestProductForId:(nullable NSString *)productId;
// Queries the App Store about the given product identifiers.
- (void)requestProductForIds:(nullable NSArray *)productIds;
// Returns the product by matching a given product identifier.
- (nullable id)getProduct:(nullable NSString *)productId;
// Returns the localized price of product by matching a given product identifier.
- (nullable NSString *)getLocalePrice:(nullable NSString *)productId;
// NO if this device is not able or allowed to make payments.
- (BOOL)canMakePayments;
// Returns whether there are purchased products.
- (BOOL)hasPurchasedProducts;
// Returns whether there are restored products.
- (BOOL)hasRestoredProducts;
// Implements the purchase of a product.
- (void)buyProduct:(nullable SKProduct *)product;
// Implements the purchase of more products.
- (void)buyProduct:(nullable SKProduct *)product quantity:(NSInteger)quantity;
// Implements the restoration of previously completed purchases.
- (void)restoreProducts;
// Removes the transaction from the queue for purchased and restored statuses.
- (void)finishTransaction:(nullable SKPaymentTransaction *)transaction;
@end
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
InAppPurchase-for-iOS.zip (21个子文件)
InAppPurchase-for-iOS-master
InAppPurchase-for-iOS.xcodeproj
project.xcworkspace
xcshareddata
IDEWorkspaceChecks.plist 238B
contents.xcworkspacedata 166B
project.pbxproj 16KB
AppStore
DYFIAPHelper.h 6KB
DYFReceiptVerifier.m 7KB
DYFReceiptVerifier.h 2KB
DYFIAPHelper.m 18KB
Example
DYFVendedModel.h 609B
DYFStoreManager.m 18KB
DYFStoreManager.h 727B
DYFVendedModel.m 1KB
Basic Files
ViewController.m 343B
Info.plist 1KB
main.m 334B
Base.lproj
LaunchScreen.storyboard 2KB
Main.storyboard 2KB
ViewController.h 215B
AppDelegate.h 277B
Assets.xcassets
AppIcon.appiconset
Contents.json 2KB
Contents.json 62B
AppDelegate.m 2KB
共 21 条
- 1
资源评论
gbass
- 粉丝: 5
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功