您已经在我的ios应用中实现了storeKit,这是代码:
-(IBAction)Purchase:(id)sender{
SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"month"];
[[SKPaymentQueue defaultQueue]addTransactionObserver:self];
[[SKPaymentQueue defaultQueue]addPayment:payment];
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
SKProduct *VailProduct = nil;
int count = [response.products count];
if (count>0) {
VailProduct = [response.products objectAtIndex:0];
} else if (!VailProduct){
UIAlertView *theAlert = [[UIAlertView alloc]initWithTitle:@"LOG" message:@"No Products Are Availble!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
}
}
-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for (SKPaymentTransaction *transaction in transactions) {
switch (transaction.transactionState) {
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
[self EnableEmergencyCenter];
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
UIAlertView *theAlert = [[UIAlertView alloc]initWithTitle:@"LOG" message:[NSString stringWithFormat:@"%@",transaction.error] delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
}
[[SKPaymentQueue defaultQueue]finishTransaction:transaction];
break;
}
}
}
来自viewDidLoad:
if ([SKPaymentQueue canMakePayments])
{
// Display a store to the user.
UIAlertView *theAlert = [[UIAlertView alloc]initWithTitle:@"LOG" message:@"Device Can Make Payments!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
SKProductsRequest *ProductRequst = [[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObject:@"month"]];
ProductRequst.delegate = self;
[ProductRequst start];
}
else {
// Warn the user that purchases are disabled.
UIAlertView *theAlert = [[UIAlertView alloc]initWithTitle:@"LOG" message:@"Device Can't Make Payments!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
}
产品标识符是当前的但我仍然从switch语句
调用此错误 case SKPaymentTransactionStateFailed:
if (transaction.error.code != SKErrorPaymentCancelled) {
UIAlertView *theAlert = [[UIAlertView alloc]initWithTitle:@"LOG" message:[NSString stringWithFormat:@"%@",transaction.error] delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
请帮助:)
答案 0 :(得分:1)
购买失败是因为交易在技术上失败了,而这并不是因为它无法连接......这可能是由于多种原因造成的。仔细检查产品标识符是否正确。我认为您的问题很可能是您没有使用与应用程序使用的应用程序ID相关联的开发证书对您的应用程序进行签名。在iTunes Connect中,您的应用链接到哪个应用ID?它必须是该应用程序特定的应用程序ID(即com.ChillySky.InAppPurchaseApp,而不是com.ChillySky。*),没有通配符!此外,您需要生成一个特殊的开发证书,以在您的设备上测试此应用程序。它必须链接到正确的APP ID!如果其中任何一项不正确,您的应用内购买将无法通过。这对我来说是最大的问题。希望这有帮助!
答案 1 :(得分:1)
由于这个问题已在一年前被问到,我想问题已经解决了,但我还是会试试运气。
尝试以下事项:
希望有所帮助
修改强>
这也可以帮到你
Error Domain=SKErrorDomain Code=0 “Operation could not be completed. (SKErrorDomain error 0.)”