iPhone Store Kit "cannot connect to itunes store"无法连接到 iTunes 商店”

标签 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];

最佳答案

尝试以下操作:

  • 创建一个新的配置文件,安装它并使用它签署您的应用程序。有时,当您编辑旧配置文件时,它们不会真正更新,因此付款流程将无法正常工作。
  • 如果您正确收到产品并且之前安装了应用程序的 iTunes 版本,则需要从设备中删除该应用程序并通过 XCode 安装它。

编辑:

这也可以帮助你

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

关于iPhone Store Kit "cannot connect to itunes store"无法连接到 iTunes 商店”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7807099/

相关文章:

iphone - Regexkitlite 在 AppStore 被拒绝。还能用什么?

ios - swift中的swiftyjson获取不到数据

objective-c - 以编程方式从 iPhone 屏幕的某些部分裁剪图像

iphone - 计算UITabBar的高度

ios - 使用 xcode 9 编译的 SDK 在 xcode 8 中无法正常工作

objective-c - 应用内购买 "Invalid Product Identifier"错误信息

ios - Swift 3 For 循环比较和更改

ios - viewDidLoad 中的变量未填充自定义表格单元格

iphone - SKProductsRequest 委托(delegate)方法永远不会被调用

ios - 应用内结算崩溃