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才干加哦

发表评论

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