iPhone商店套件“无法连接到iTunes商店”无法连接到iTunes商店“

时间:2011-10-18 12:20:21

标签: iphone ios storekit

您已经在我的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];

请帮助:)

2 个答案:

答案 0 :(得分:1)

购买失败是因为交易在技术上失败了,而这并不是因为它无法连接......这可能是由于多种原因造成的。仔细检查产品标识符是否正确。我认为您的问题很可能是您没有使用与应用程序使用的应用程序ID相关联的开发证书对您的应用程序进行签名。在iTunes Connect中,您的应用链接到哪个应用ID?它必须是该应用程序特定的应用程序ID(即com.ChillySky.InAppPurchaseApp,而不是com.ChillySky。*),没有通配符!此外,您需要生成一个特殊的开发证书,以在您的设备上测试此应用程序。它必须链接到正确的APP ID!如果其中任何一项不正确,您的应用内购买将无法通过。这对我来说是最大的问题。希望这有帮助!

答案 1 :(得分:1)

由于这个问题已在一年前被问到,我想问题已经解决了,但我还是会试试运气。

尝试以下事项:

  • 创建新的配置文件,安装它并使用它对您的应用进行签名。有时,旧的配置文件在编辑时不会真正更新,因此付款流程无效。
  • 如果您正确收到产品并且之前已经安装了应用的iTunes版本,则需要从设备中删除该应用并通过XCode进行安装。

希望有所帮助

修改

这也可以帮到你

Error Domain=SKErrorDomain Code=0 “Operation could not be completed. (SKErrorDomain error 0.)”