iPhone Store Kit“无法连接到 itunes 商店”无法连接到 itunes 商店”

发布于 2024-12-10 16:31:56 字数 3319 浏览 0 评论 0原文

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

I have implemented storeKit in my iOS app, this is the code:

-(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;
        }
    }
}

this comes on the 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];
}

the product identifier are currect but i keep gettin this error called from the switch statement

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哽咽笑 2024-12-17 16:31:56

尝试以下操作:

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

编辑:

这也可以帮助您

错误域=SKErrorDomain代码=0“操作无法完成。 (SKErrorDomain 错误 0。)”

Try following things:

  • create a new provisioning profile, install it and sign your app with it. Sometimes the old profiles won't really be updated when you edit them and therefore the payment process wont work.
  • If you receive the products correctly and you previously have installed a iTunes Version of your app, than you need to delete the app from your device and install it via XCode.

EDIT:

This could also help you

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

蓝眼睛不忧郁 2024-12-17 16:31:56

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

The purchase is failing because the transaction is technically failing, and this is not specifically due to the fact that it cannot connect... it can be due to a number of reasons. Double check that the product identifier is correct. I think that your issue is most likely that you are not signing your app with a development certificate that is linked to the App ID used for your app. In iTunes Connect, what app ID is your app linked to? It needs to be an app ID SPECIFICALLY for that app (i.e. com.ChillySky.InAppPurchaseApp, NOT com.ChillySky.*), no wildcards! Also, you need to generate a special development certificate to test this app on your device. IT MUST BE LINKED TO THE CORRECT APP ID!! If any of this is not correct, your in app purchase will not go through. This was the biggest issue for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文