我在itune connect(非耗材)中创建IAP以访问视图控制器,但我在iPhone中测试它没有弹出购买页面
我的IAP产品ID是“Egayov”
我的应用ID是“my.com.th.myapp”
这是我的代码
- (void)viewDidLoad {
[super viewDidLoad];
if([SKPaymentQueue canMakePayments]){
NSLog(@"can buy all IAP");
SKProductsRequest *productRequest = [[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObject:@"my.com.th.myapp"]];
productRequest.delegate = self;
[productRequest start];
}
else{
NSLog(@"Parental controll on");
}
}
-(IBAction)Buyvoyage{
SKPayment *vo = [SKPayment paymentWithProductIdentifier:@"my.com.th.myapp"];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] addPayment:vo];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
SKProduct *vaildproduct = nil;
int count = [response.products count];
if (count>0) {
vaildproduct = [response.products objectAtIndex:0];
}
if (!vaildproduct){
NSLog(@"no iap %@",vaildproduct);
}
}
-(void)paymentQueue:(SKPaymentQueue *)queue removedTransactions:(NSArray *)transactions{
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
[self checkiap];
break;
case SKPaymentTransactionStateRestored:
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
NSLog(@"Payment Failed");
}
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
}
}
}
在productrequest函数中,它会转到其他条件
答案 0 :(得分:0)
我有同样的问题,老实说它没有解决。使用Parse实现IAP要容易得多。它只需几行代码就可以了。阅读本文,我相信它会对你有所帮助: http://blog.parse.com/announcements/in-app-purchase/