xcode 应用内购买沙盒问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7078222/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:44:36  来源:igfitidea点击:

In App Purchase sandbox problem

iphoneiosxcodein-app-purchaseapp-store-connect

提问by Tom Baranowicz

currently I am developing iOS application, which needs In App Purchase.

目前我正在开发 iOS 应用程序,需要应用程序内购买。

As in many tutorials (like this: http://www.raywenderlich.com/2797/introduction-to-in-app-purchases). I've created new app in iTunesConnect, uploaded binary and rejected it. After that i added few in app purchase products. In next step I added Storekit to my Xcode project and after that I wrote this code in my UIViewController:

与许多教程一样(例如:http: //www.raywenderlich.com/2797/introduction-to-in-app-purchases)。我在 iTunesConnect 中创建了新应用程序,上传了二进制文件并拒绝了它。之后,我添加了一些应用内购买产品。在下一步中,我将 Storekit 添加到我的 Xcode 项目中,之后我在 UIViewController 中编写了以下代码:

- (void)buyPressed
{
    SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObjects: @"com.mycompany.appliaction_name.levelpack",nil]];
    request.delegate = self;
    [request start];
    NSLog(@"request started");
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray *products = response.products;
    for (int i=0; i<[products count]; i++) 
    {
        SKProduct *proUpgradeProduct = [products objectAtIndex:i];
        if (proUpgradeProduct)
        {
            NSLog(@"Valid product id: %@" , proUpgradeProduct.price);
            NSLog(@"Product title: %@" , proUpgradeProduct.localizedTitle);
            NSLog(@"Product description: %@" , proUpgradeProduct.localizedDescription);
            NSLog(@"Product price: %@" , proUpgradeProduct.price);
            NSLog(@"Product id: %@" , proUpgradeProduct.productIdentifier);
        }
    }

    for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        NSLog(@"Invalid product id: %@" , invalidProductId);
        UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Apple connection error!" message:nil delegate:self cancelButtonTitle:@"CLOSE" otherButtonTitles:nil];
        [myAlertView show];
        [myAlertView release];
    }
}

And I still receive info that all my in app products have invalid product id. Today I've found this: http://developer.apple.com/library/ios/#technotes/tn2259/_index.html

而且我仍然收到我的所有应用内产品的产品 ID 无效的信息。今天我发现了这个:http: //developer.apple.com/library/ios/#technotes/tn2259/_index.html

And one important thing: "Important: DO NOT upload the development binary to iTunes Connect until the application is ready for App Review approval. If the binary is present in iTunes Connect and it is not fully functional, App Review will review the binary and likely reject the development binary. Testing In App Purchase will fail if you or App Review reject your most recent binary in iTunes Connect. The workaround in this case is to upload a binary without In App Purchase features that can get approved by App Review. Once the binary is approved, resume testing the binary with In App Purchase features."

还有一件重要的事情:“重要:在应用程序准备好接受 App Review 批准之前,不要将开发二进制文件上传到 iTunes Connect。如果二进制文件存在于 iTunes Connect 中并且它没有完全发挥作用,App Review 将二进制文件并且很可能拒绝开发二进制文件。如果您或 App Review 拒绝您在 iTunes Connect 中的最新二进制文件,则在 App Purchase 中测试将失败。在这种情况下,解决方法是上传一个没有 App Review 批准的 App 内购买功能的二进制文件。一旦二进制文件已获批准,请继续使用应用内购买功能测试二进制文件。”

So I have to create new app in iTunes once again, or should I build and submit my app without in app purchase and when app will appear in iTunes develop new version with in app purchase?

所以我必须再次在 iTunes 中创建新的应用程序,或者我应该在没有应用程序内购买的情况下构建和提交我的应用程序,以及应用程序何时出现在 iTunes 中开发新版本并在应用程序内购买?

Thanks for answers!

感谢您的回答!

回答by Praveen-K

invalidProductIdentifiers(An array of product identifier strings that were not recognized by the Apple App Store. (read-only))

invalidProductIdentifiers(Apple App Store 无法识别的产品标识符字符串数组。(只读))

So make sure you are not using the same product identifier which was rejected

因此,请确保您没有使用被拒绝的相同产品标识符

Run Xcode after disconnecting your device, and run a Build->Clean All Targets.

Run Xcode->Empty Caches, and then quit and re-launch Xcode.

After Xcode is re-launched and your device has restarted, re-connect it to you machine.

Create an entirely new iTunes Test Account on the iTunesConnect portal.

Build and Run your application from XCode to your device using a Development profile and then attempt to purchase the product using the new iTunes Test Account.

断开设备连接后运行 Xcode,然后运行 ​​Build->Clean All Targets。

运行 Xcode->Empty Caches,然后退出并重新启动 Xcode。

重新启动 Xcode 并且您的设备重新启动后,将其重新连接到您的机器。

在 iTunesConnect 门户上创建一个全新的 iTunes 测试帐户。

使用开发配置文件从 XCode 构建和运行您的应用程序到您的设备,然后尝试使用新的 iTunes 测试帐户购买产品。

If you submit an application and the binary is rejected for any reason In-App Purchase may cease to function correctly in the sandbox. Apple states that the only way to restore this is to re-submit an app binary without IAP functionality and get it approved first (but not necessarily released).

如果您提交应用程序并且二进制文件因任何原因被拒绝,则应用程序内购买可能会停止在沙箱中正常运行。Apple 表示,恢复这种情况的唯一方法是重新提交没有 IAP 功能的应用程序二进制文件,并首先获得批准(但不一定发布)。

Look at my another related [ANSWER]

看看我的另一个相关[ ANSWER]

回答by f055

Just at this moment another thing helped for me: making a change (any change) in the Version Information of the New Version of the app. But I did the above cache cleaning/device restart as well.

就在此时,另一件事对我有所帮助:在应用程序新版本的版本信息中进行更改(任何更改)。但是我也做了上面的缓存清理/设备重启。