iOS开发内购全套图文教程

2015年最全的内购图文跑过,基本的件事是填写杂多的书信。,末尾是行为准则,消灭不多说,直接地上图

以防它对你有扶助,请毫不犹豫地授予赏金和享用,谢谢你!

======================基本的使分裂礼仪===============

基本的步:PNG

第二份食物步.jpg

第三步.jpg

第四音级步.png

第五步.png

第六感觉步.png

第七步.jpg

八号步.jpg

第九步.jpg

第十步.png

CNAPS CODE 查询地址

十一步.jpg

十二步.jpg

十三个的步.png

十四的记号步.png

十五个人组成的橄榄球队步.jpg

十七步.jpg

十八步.jpg

十九点钟步.png


2016/11/18号翻新

十九点钟步(1)PNG

十九点钟步(2)PNG

领地未显示的都不被打包。,次要是钩子 title Self的后头

二十步.png

=============第二份食物使分裂发觉内购使受协议条款的约束============

1.png

2.png

3.png

4.png

5.png

6.png

7.png

===========第三使分裂贴加内购使受协议条款的约束测得归结为账号==========

发觉一任一某一测得归结为认为

沙盒测得归结为员.png

账号书信.png

第四音级使分裂次要实施行为准则。

率先导入

.h提出


#import 

enum{
IAP0p20=20,
IAP1p100,
IAP4p600,
IAP9p1000,
IAP24p6000,
}buyCoinsTag;

//代劳
@interface RechargeVC : UIViewController 

{
int buyType;
}

- (奈何) requestProUpgradeProductData;

-(奈何)RequestProductData;

-(奈何)buy:(int)type;

- (奈何)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions;

-(奈何) PurchasedTransaction: (SKPaymentTransaction *)transaction;

- (奈何) completeTransaction: (SKPaymentTransaction *)transaction;

- (奈何) failedTransaction: (SKPaymentTransaction *)transaction;

-(奈何) paymentQueueRestoreCompletedTransactionsFinished: (SKPaymentTransaction *)transaction;

-(奈何) paymentQueue:(SKPaymentQueue *) paymentQueue restoreCompletedTransactionsFailedWithError:(NSError *)error;

- (奈何) restoreTransaction: (SKPaymentTransaction *)transaction;

-(奈何)provideContent:(NSString *)product;

-(奈何)recordTransaction:(NSString *)product;

@end

.m提出

#import ""

//在内购使受协议条款的约束中创的商品单号
#define ProductID_IAP0p20 @""//20
#define ProductID_IAP1p100 @"" //100
#define ProductID_IAP4p600 @"" //600
#define ProductID_IAP9p1000 @"" //1000
#define ProductID_IAP24p6000 @"" //6000

@interface RechargeVC ()

@end

@implementation RechargeVC

- (奈何)viewDidLoad {

    [非常 viewDidLoad];

    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
    【自 buy:IAP0p20];

}

-(奈何)buy:(int)type
{
    buyType = type;
    if ([SKPaymentQueue canMakePayments]) {
    【自 RequestProductData];
    NSLog(@容许结清顺序)
}
else
{
    NSLog(@不容许结清顺序)
    UIAlertView *alerView =  [[UIAlertView 分派] initWithTitle:@"点明"
    书信:@你的蜂窝式便携无线电话缺乏翻开付费顺序。
    代表:无 cancelButtonTitle:NSLocalizedString(@"使靠近",无) otherButtonTitles:零]

    [alerView 展]

    }
}

-(奈何)RequestProductData
{
    NSLog(@"---------召唤对应的引起书信------------");
    NSArray *product = nil;
    switch (buyType) {
        case IAP0p20:
        product=[[NSArray 分派] initWithObjects:ProductID_IAP0p20,零]
        break;
        case IAP1p100:
        product=[[NSArray 分派] initWithObjects:ProductID_IAP1p100,零]
        break;
        case IAP4p600:
        product=[[NSArray 分派] initWithObjects:ProductID_IAP4p600,零]
        break;
        case IAP9p1000:
        product=[[NSArray 分派] initWithObjects:ProductID_IAP9p1000,零]
        break;
        case IAP24p6000:
        product=[[NSArray 分派] initWithObjects:ProductID_IAP24p6000,零]
        break;

        default:
        break;
}
    NSSet *nsset = [NSSet setWithArray:product];
    SKProductsRequest *request=[[SKProductsRequest 分派] initWithProductIdentifiers: nsset];
    
    [召唤 开端]

}

// 召唤礼仪
收到的引起书信
- (奈何)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{

    NSLog(@"-----------收到引起反应书信--------------");
    NSArray *myProduct = response.products;
    NSLog(@引起 身份证:%@,);
    NSLog(@结清算术的引起 %d", (int)[myProduct 计数]
    // populate UI
    for(SKProduct *product in myProduct){
    NSLog(@"product 书信)
    NSLog(@"SKProduct 叙述书信%@", 【引起 阐明]
    NSLog(@引起冠军的 %@" , );
    NSLog(@引起叙述书信 %@" , );
    NSLog(@"价钱: %@" , );
    NSLog(@"Product id: %@" , );
}
    SKPayment *payment = nil;
    switch (buyType) {
        case IAP0p20:
        payment  = [SKPayment paymentWithProductIdentifier:ProductID_IAP0p20];    结清25
        break;
        case IAP1p100:
        payment  = [SKPayment paymentWithProductIdentifier:ProductID_IAP1p100];    //结清108
        break;
        case IAP4p600:
        payment  = [SKPayment paymentWithProductIdentifier:ProductID_IAP4p600];    //结清618
        break;
        case IAP9p1000:
        payment  = [SKPayment paymentWithProductIdentifier:ProductID_IAP9p1000];    //结清1048
        break;
        case IAP24p6000:
        payment  = [SKPayment paymentWithProductIdentifier:ProductID_IAP24p6000];    //结清5898
        break;
        default:
        break;
}
    NSLog(@"---------发送依靠机械力移动召唤------------");
    [[SKPaymentQueue defaultQueue] addPayment:payment];

}
- (奈何)requestProUpgradeProductData
{
    NSLog(@信息晋级需求)
    NSSet *productIdentifiers = [NSSet setWithObject:@""];
    SKProductsRequest* productsRequest = [[SKProductsRequest 分派] initWithProductIdentifiers:productIdentifiers];
    productsRequest.delegate = self;
    【引起sRequest 开端]

}
//突然呈现弄错书信
- (奈何)request:(SKRequest *)request didFailWithError:(NSError *)error{
    NSLog(@弄错音讯--)
    UIAlertView *alerView =  [[UIAlertView 分派] initWithTitle:NSLocalizedString(@"Alert",null) 音讯:[弄错] localizedDescription]
    代表:无 cancelButtonTitle:NSLocalizedString(@"Close",无) otherButtonTitles:零]
    [alerView 展]

}

-(奈何) requestDidFinish:(SKRequest *)request
{
    NSLog(@"----------反应书信完毕--------------");

}

-(奈何) PurchasedTransaction: (SKPaymentTransaction *)transaction{
    NSLog(@"-----PurchasedTransaction----");
    NSArray *transactions =[[NSArray 分派] initWithObjects:transaction, 零]
    【自 paymentQueue:[SKPaymentQueue defaultQueue] updatedTransactions:transactions];
}

// 别忘了绑定,行为准则列举如下:
监控推销归结为
//[[SKPaymentQueue defaultQueue] addTransactionObserver:self];

- (奈何)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray 事务/事务归结为
{
    NSLog(@"-----paymentQueue--------");
    for (SKPaymentTransaction *transaction in 市)
    {
        switch ()
        {
            case SKPaymentTransactionStatePurchased:{//市走完
            【自 completeTransaction:市]
            NSLog(@ -----走完市 --------");

            UIAlertView *alerView =  [[UIAlertView 分派] initWithTitle:@""
            书信:依靠机械力移动成
            代表:无 cancelButtonTitle:NSLocalizedString(@"使靠近",无) otherButtonTitles:零]

            [alerView 展]

        } break;
        case SKPaymentTransactionStateFailed://市走慢
            { 【自 failedTransaction:市]
            NSLog(@ -----运输量走慢 --------");
            UIAlertView *alerView2 =  [[UIAlertView 分派] initWithTitle:@"点明"
            书信:@依靠机械力移动走慢,请再买一次。
            代表:无 cancelButtonTitle:NSLocalizedString(@"使靠近",无) otherButtonTitles:零]

            [alerView2 展]

        }break;
        case SKPaymentTransactionStateRestored://早已依靠机械力移动过该商品
            【自 restoreTransaction:市]
            NSLog(@ -——-——买了商品 --------");
            case SKPaymentTransactionStatePurchasing:      添加到列表打中使受协议条款的约束列表
            NSLog(@————-一任一某一列表项添加到列表 --------");
            break;
            default:
            break;
        }
    }
}
- (奈何) completeTransaction: (SKPaymentTransaction *)transaction

{
    NSLog(@"-----completeTransaction--------");
    // Your application should implement these two 办法.
    NSString *product = transaction.payment.productIdentifier;
    if (【引起 巨大] > 0) {

    NSArray *tt = 【引起 componentsSeparatedByString:@"."];
    NSString *bookid = 【TT lastObject];
    if ([bookid 巨大] > 0) {
    【自 recordTransaction:bookid];
    【自 provideContent:bookid];
}
}

    // Remove the transaction from the payment 队列。

    [[SKPaymentQueue defaultQueue] finishTransaction: 市]

}

打破记载的市
-(奈何)recordTransaction:(NSString *)product{
    NSLog(@"-----记载市--------");
}

处置下载的愿意的
-(奈何)provideContent:(NSString *)product{
    NSLog(@"-----下载--------");
}

- (奈何) failedTransaction: (SKPaymentTransaction *)transaction{
    NSLog(@"走慢");
    if ( != SKErrorPaymentCancelled)
    {

    }
    [[SKPaymentQueue defaultQueue] finishTransaction: 市]

}
-(奈何) paymentQueueRestoreCompletedTransactionsFinished: (SKPaymentTransaction *)transaction{

}

- (奈何) restoreTransaction: (SKPaymentTransaction *)transaction
{
    NSLog(@" 事务回复处置

}

-(奈何) paymentQueue:(SKPaymentQueue *) paymentQueue restoreCompletedTransactionsFailedWithError:(NSError *)error{
    NSLog(@"-------paymentQueue----");
}

#pragma mark connection delegate
- (奈何)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    NSLog(@"%@",  [[NSString 分派] initWithData:data encoding:NSUTF8StringEncoding]);
}
- (奈何)connectionDidFinishLoading:(NSURLConnection *)connection{

}

- (奈何)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
    switch([(NSHTTPURLResponse *)response statusCode]) {
        case 200:
        case 206:
        break;
        case 304:
        break;
        case 400:
        break;
        case 404:
        break;
        case 416:
        break;
        case 403:
        break;
        case 401:
        case 500:
        break;
        default:
        break;
    }
}

- (奈何)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
    NSLog(@"test");
}

-(奈何)dealloc
{
    [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];//破除监听

}

@end

2016/11/22翻新

内购使受协议条款的约束不再是独自适用于复核了,如果app适用于复核内购使受协议条款的约束天理跟着换衣服连箱的,请不要选择消耗使受协议条款的约束 托管那一,或许会呈现成绩

更多阅历请点击
技术交流群:534926022(收费) 511040024(每人付费) 蜂窝式便携无线电话QQ才干加哦

发表评论

电子邮件地址不会被公开。 必填项已用*标注