<blockquote id="guj5h"><del id="guj5h"><option id="guj5h"></option></del></blockquote>
    <table id="guj5h"><blockquote id="guj5h"></blockquote></table>
    <blockquote id="guj5h"><ol id="guj5h"><big id="guj5h"></big></ol></blockquote>
        <var id="guj5h"><strike id="guj5h"></strike></var>
        <table id="guj5h"><dfn id="guj5h"><sup id="guj5h"></sup></dfn></table>
            <dfn id="guj5h"></dfn>
              <var id="guj5h"><strike id="guj5h"><table id="guj5h"></table></strike></var>

              iOS開發內購全套圖文教程

              后臺-系統設置-擴展變量-手機廣告位-內容正文頂部

               2015年最全的內購圖文教程,首先是填各種資料,最后是代碼,廢話不多說,直接上圖

              如對你有幫助,請不要吝惜打賞和喜歡,謝謝!

              ======================第一部分協議===============


              第一步.png

              第二步.jpg

              第三步.jpg

              第四步.png

              第五步.png

              第六步.png

              第七步.jpg

              第八步.jpg

              第九步.jpg

              第十步.png

              CNAPS CODE 查詢地址
              https://e.czbank.com/CORPORBANK/query_unionBank_index.jsp


              十一步.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

              賬號信息.png

              =============第四部分主要實現代碼==========

              首先導入StoreKit.framework

              .h文件

              #import <StoreKit/StoreKit.h>  enum{ IAP0p20=20, IAP1p100, IAP4p600, IAP9p1000, IAP24p6000, }buyCoinsTag;  //代理 @interface RechargeVC : UIViewController <SKPaymentTransactionObserver,SKProductsRequestDelegate >  { int buyType; }  - (void) requestProUpgradeProductData;  -(void)RequestProductData;  -(void)buy:(int)type;  - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions;  -(void) PurchasedTransaction: (SKPaymentTransaction *)transaction;  - (void) completeTransaction: (SKPaymentTransaction *)transaction;  - (void) failedTransaction: (SKPaymentTransaction *)transaction;  -(void) paymentQueueRestoreCompletedTransactionsFinished: (SKPaymentTransaction *)transaction;  -(void) paymentQueue:(SKPaymentQueue *) paymentQueue restoreCompletedTransactionsFailedWithError:(NSError *)error;  - (void) restoreTransaction: (SKPaymentTransaction *)transaction;  -(void)provideContent:(NSString *)product;  -(void)recordTransaction:(NSString *)product;  @end

              .m文件

              #import "RechargeVC.h"  //在內購項目中創的商品單號 #define ProductID_IAP0p20 @"Nada.JPYF01"//20 #define ProductID_IAP1p100 @"Nada.JPYF02" //100 #define ProductID_IAP4p600 @"Nada.JPYF03" //600 #define ProductID_IAP9p1000 @"Nada.JPYF04" //1000 #define ProductID_IAP24p6000 @"Nada.JPYF05" //6000  @interface RechargeVC ()  @end  @implementation RechargeVC  - (void)viewDidLoad {      [super viewDidLoad];      [[SKPaymentQueue defaultQueue] addTransactionObserver:self];     [self buy:IAP0p20];  }  -(void)buy:(int)type {     buyType = type;     if ([SKPaymentQueue canMakePayments]) {     [self RequestProductData];     NSLog(@"允許程序內付費購買"); } else {     NSLog(@"不允許程序內付費購買");     UIAlertView *alerView =  [[UIAlertView alloc] initWithTitle:@"提示"     message:@"您的手機沒有打開程序內付費購買"     delegate:nil cancelButtonTitle:NSLocalizedString(@"關閉",nil) otherButtonTitles:nil];      [alerView show];      } }  -(void)RequestProductData {     NSLog(@"---------請求對應的產品信息------------");     NSArray *product = nil;     switch (buyType) {         case IAP0p20:         product=[[NSArray alloc] initWithObjects:ProductID_IAP0p20,nil];         break;         case IAP1p100:         product=[[NSArray alloc] initWithObjects:ProductID_IAP1p100,nil];         break;         case IAP4p600:         product=[[NSArray alloc] initWithObjects:ProductID_IAP4p600,nil];         break;         case IAP9p1000:         product=[[NSArray alloc] initWithObjects:ProductID_IAP9p1000,nil];         break;         case IAP24p6000:         product=[[NSArray alloc] initWithObjects:ProductID_IAP24p6000,nil];         break;          default:         break; }     NSSet *nsset = [NSSet setWithArray:product];     SKProductsRequest *request=[[SKProductsRequest alloc] initWithProductIdentifiers: nsset];     request.delegate=self;     [request start];  }  //<SKProductsRequestDelegate> 請求協議 //收到的產品信息 - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{      NSLog(@"-----------收到產品反饋信息--------------");     NSArray *myProduct = response.products;     NSLog(@"產品Product ID:%@",response.invalidProductIdentifiers);     NSLog(@"產品付費數量: %d", (int)[myProduct count]);     // populate UI     for(SKProduct *product in myProduct){     NSLog(@"product info");     NSLog(@"SKProduct 描述信息%@", [product description]);     NSLog(@"產品標題 %@" , product.localizedTitle);     NSLog(@"產品描述信息: %@" , product.localizedDescription);     NSLog(@"價格: %@" , product.price);     NSLog(@"Product id: %@" , product.productIdentifier); }     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];  } - (void)requestProUpgradeProductData {     NSLog(@"------請求升級數據---------");     NSSet *productIdentifiers = [NSSet setWithObject:@"com.productid"];     SKProductsRequest* productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];     productsRequest.delegate = self;     [productsRequest start];  } //彈出錯誤信息 - (void)request:(SKRequest *)request didFailWithError:(NSError *)error{     NSLog(@"-------彈出錯誤信息----------");     UIAlertView *alerView =  [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Alert",NULL) message:[error localizedDescription]     delegate:nil cancelButtonTitle:NSLocalizedString(@"Close",nil) otherButtonTitles:nil];     [alerView show];  }  -(void) requestDidFinish:(SKRequest *)request {     NSLog(@"----------反饋信息結束--------------");  }  -(void) PurchasedTransaction: (SKPaymentTransaction *)transaction{     NSLog(@"-----PurchasedTransaction----");     NSArray *transactions =[[NSArray alloc] initWithObjects:transaction, nil];     [self paymentQueue:[SKPaymentQueue defaultQueue] updatedTransactions:transactions]; }  //<SKPaymentTransactionObserver> 千萬不要忘記綁定,代碼如下: //----監聽購買結果 //[[SKPaymentQueue defaultQueue] addTransactionObserver:self];  - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions//交易結果 {     NSLog(@"-----paymentQueue--------");     for (SKPaymentTransaction *transaction in transactions)     {         switch (transaction.transactionState)         {             case SKPaymentTransactionStatePurchased:{//交易完成             [self completeTransaction:transaction];             NSLog(@"-----交易完成 --------");              UIAlertView *alerView =  [[UIAlertView alloc] initWithTitle:@""             message:@"購買成功"             delegate:nil cancelButtonTitle:NSLocalizedString(@"關閉",nil) otherButtonTitles:nil];              [alerView show];          } break;         case SKPaymentTransactionStateFailed://交易失敗             { [self failedTransaction:transaction];             NSLog(@"-----交易失敗 --------");             UIAlertView *alerView2 =  [[UIAlertView alloc] initWithTitle:@"提示"             message:@"購買失敗,請重新嘗試購買"             delegate:nil cancelButtonTitle:NSLocalizedString(@"關閉",nil) otherButtonTitles:nil];              [alerView2 show];          }break;         case SKPaymentTransactionStateRestored://已經購買過該商品             [self restoreTransaction:transaction];             NSLog(@"-----已經購買過該商品 --------");             case SKPaymentTransactionStatePurchasing:      //商品添加進列表             NSLog(@"-----商品添加進列表 --------");             break;             default:             break;         }     } } - (void) completeTransaction: (SKPaymentTransaction *)transaction  {     NSLog(@"-----completeTransaction--------");     // Your application should implement these two methods.     NSString *product = transaction.payment.productIdentifier;     if ([product length] > 0) {      NSArray *tt = [product componentsSeparatedByString:@"."];     NSString *bookid = [tt lastObject];     if ([bookid length] > 0) {     [self recordTransaction:bookid];     [self provideContent:bookid]; } }      // Remove the transaction from the payment queue.      [[SKPaymentQueue defaultQueue] finishTransaction: transaction];  }  //記錄交易 -(void)recordTransaction:(NSString *)product{     NSLog(@"-----記錄交易--------"); }  //處理下載內容 -(void)provideContent:(NSString *)product{     NSLog(@"-----下載--------"); }  - (void) failedTransaction: (SKPaymentTransaction *)transaction{     NSLog(@"失敗");     if (transaction.error.code != SKErrorPaymentCancelled)     {      }     [[SKPaymentQueue defaultQueue] finishTransaction: transaction];  } -(void) paymentQueueRestoreCompletedTransactionsFinished: (SKPaymentTransaction *)transaction{  }  - (void) restoreTransaction: (SKPaymentTransaction *)transaction {     NSLog(@" 交易恢復處理");  }  -(void) paymentQueue:(SKPaymentQueue *) paymentQueue restoreCompletedTransactionsFailedWithError:(NSError *)error{     NSLog(@"-------paymentQueue----"); }  #pragma mark connection delegate - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {     NSLog(@"%@",  [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection{  }  - (void)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;     } }  - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {     NSLog(@"test"); }  -(void)dealloc {     [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];//解除監聽  }  @end

              2016/11/22更新

              內購項目不再是單獨提交審核了,只要app提交審核內購項目自然跟著改變狀態,不消耗物品請不要選擇 托管那一項,不然會出現問題

              Ios開發iOS開發內購全套圖文教程,轉載需保留來源!

              鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

              后臺-系統設置-擴展變量-手機廣告位-內容正文底部
              老师好紧 好湿 硬的不行