iPhone Store Kit 返回无效产品 ID 错误
我正在尝试在 iPhone 上测试应用内购买,但遇到了一个问题:我请求信息的产品 ID 最终在“didRecieveResponse”方法中作为无效产品 ID 返回给我。
我已经:
- 创建了与此应用程序关联的店内产品。它的包 ID 与其他所有内容相匹配。该物业已获开发商批准并可出售。
- 确保我的新配置文件已启用商店应用程序购买,并且具有完整的应用程序名称:“com.domain.appname”
- 确保这是用于将应用程序签名到我的 iPhone 的配置文件。
- 确保“com.domain.appname”是用于构建配置文件的应用程序 ID。
- 确保在我的 plist 文件中使用“com.domain.appname”作为包标识符。
一切似乎都已就绪,但我的产品仍然以无效 ID 的形式退回给我。
这是我正在使用的代码:
- (void)requestProductData {
SKProductRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject: @"com.domain.appname.productid"]];
request.delegate = self;
[request start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *myProducts = response.products;
NSArray *myInvalidProducts = response.invalidProductIdentifiers;
for(int i = 1; i < myInvalidProducts.count; ++i)
{
std::cout <<"invalid product id = " << [[myInvalidProducts objectAtIndex:i] UTF8String] << std::endl;
}
for(int i = 0; i < myProducts.count; ++i)
{
SKProduct * myProduct = [myProducts objectAtIndex:i];
std::cout << "Product Info:" << std::endl;
std::cout << "\tlocalizedTitle = " << [[myProduct localizedTitle] UTF8String] << std::endl;
std::cout << "\tlocalizedDescription = " << [[myProduct localizedDescription] UTF8String] << std::endl;
std::cout << "\tproductIdentifier = " << [[myProduct productIdentifier] UTF8String] << std::endl;
std::cout << "\tprice = " << [[myProduct price] doubleValue] << std::endl;
std::cout << "\tpriceLocale = " << [myProduct priceLocale] << std::endl;
}
[request autorelease];
}
我的所有产品 ID 都显示在无效的打印输出中,并且没有一个显示在“产品信息:”打印输出中。
任何建议将不胜感激...
PS 是的,这是作为 Objective-c/c++ 构建的。
I am trying to test In App Purchases on my iPhone and running into a problem where the product IDs I request information for end up being returned to me as invalid product IDs in the "didRecieveResponse" method.
I have:
- Created an in store product associated with this app. It's bundle ID matches everything else. It has been cleared for sale and approved by the developer.
- Made sure my new provisioning profile has in store app purchases enabled and it has the full app name: "com.domain.appname"
- Made sure this is the provisioning profile being used to sign the app to my iPhone.
- Made sure that "com.domain.appname" is the app ID used to build the provisioning profile.
- Made sure that "com.domain.appname" is used in my plist file as the bundle identifier.
Everything seems to be in place, however I still get my products returned to me as invalid IDs.
This is the code I am using:
- (void)requestProductData {
SKProductRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject: @"com.domain.appname.productid"]];
request.delegate = self;
[request start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *myProducts = response.products;
NSArray *myInvalidProducts = response.invalidProductIdentifiers;
for(int i = 1; i < myInvalidProducts.count; ++i)
{
std::cout <<"invalid product id = " << [[myInvalidProducts objectAtIndex:i] UTF8String] << std::endl;
}
for(int i = 0; i < myProducts.count; ++i)
{
SKProduct * myProduct = [myProducts objectAtIndex:i];
std::cout << "Product Info:" << std::endl;
std::cout << "\tlocalizedTitle = " << [[myProduct localizedTitle] UTF8String] << std::endl;
std::cout << "\tlocalizedDescription = " << [[myProduct localizedDescription] UTF8String] << std::endl;
std::cout << "\tproductIdentifier = " << [[myProduct productIdentifier] UTF8String] << std::endl;
std::cout << "\tprice = " << [[myProduct price] doubleValue] << std::endl;
std::cout << "\tpriceLocale = " << [myProduct priceLocale] << std::endl;
}
[request autorelease];
}
All my product IDs show up in the invalid printouts and none of them show up in the "Product Info:" printouts.
Any suggestions would be greatly appreciated...
P.S. Yes, this is built as Objective-c/c++.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我尝试了苹果论坛和此处建议的所有内容,但仍然无法正常工作。找到了解决方案 - 您的应用程序需要通过 Xcode 传输才能启用沙箱。
很明显,对吧?那么,如果您正在对现有帐户进行更新,设备仍会将其视为 App Store 安装的应用程序。
删除它,然后再次传输。现在应该可以工作了:)
I tried everything suggested in the Apple forums and here, and still couldn't get it to work. Found the solution - your app needs to be transferred by Xcode for the sandbox to be enabled.
Obvious, right? Well, if you are working with an update to an existing account, the device will still treat it as an App Store-installed app.
Delete it, then transfer it again. It should work now :)
删除测试 iPhone 上的应用程序并重新安装它可以正常工作。另外,自从提交应用内购买项目以来,我也等了 8 个小时。
Deleting the app on the testing iPhone and reinstalling it worked. Also I had also waited 8 hours since submitting the in-app purchase item.
请执行以下步骤:
使用您的开发者帐户登录 iTunes connect ( https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/)。
转到选项卡 - “合同、税务和银行业务”
检查“请求合同”和“流程中的合同”部分。
查看“iOS付费应用程序”,需要设置联系信息、银行信息和税务信息。
当“iOS 付费应用程序”单元格移动到“生效合同”部分时,我将能够使用产品进行应用内购买。
请通过以下链接了解更多信息:
http://developer.apple.com/library/ios/#technotes /tn2259/_index.html
Please Go through the steps below:
Log in to iTunes connect using your developer account (https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wo/).
Go to the Tab - "Contracts, Tax, and Banking"
Check the Request Contracts and Contracts in Process sections.
Check out the "iOS Paid Applications" and there Contact Info , Bank Info and Tax Info are need to Set up.
When "iOS Paid Applications" cell will move to Contracts in Effect section, I will be able to use Products for in App Purchase.
Please go through the link below for more information:
http://developer.apple.com/library/ios/#technotes/tn2259/_index.html
请注意,当 iPhone 越狱时,AppSync 数据包会完全破坏应用内购买测试。
AppSync 使用 Install0us 作为依赖项进行安装。
您不必完全恢复 iOS,只需在 Cydia 中卸载 AppSync 即可成功测试应用内购买。
在我删除 AppSync 之前,来自所有论坛、教程和有关修复“无效产品”的评论的所有提示对我都不起作用。
Please note that when iPhone is jailbroken the AppSync packet breaks in-app-purchasing testing completely.
AppSync is installed with Install0us as a dependency.
You don't have to restore iOS completely, just uninstall AppSync in Cydia to test in-app-purchases with success.
All tips from all forums, tutorials and comments about fixind 'invalid product' did not work for me until I removed AppSync.
我在使用新应用程序(v1.0 尚未在商店中发布)时也遇到了类似的问题,我也尝试在应用程序中添加购买功能。我设置了一切,添加了产品等,当我执行 SKProductsRequest 时,我的产品始终返回为无效。
当我在苹果开发者论坛上看到一篇与此无关的帖子时,我正准备放弃整个过程。它建议从测试设备中删除该应用程序,然后进行全新的构建+安装。这就成功了。
为了确定这一点,我在另一台给我带来同样麻烦的设备上尝试了它,它也修复了该问题。
这只是一种猜测,但我认为,如果设备上有一个使用在添加 IAP 之前创建的配置文件创建的版本,则需要删除该版本并使用 IAP 配置文件安装一个新的版本。 (也就是说,简单地替换应用程序并不能解决问题。)
I've been having a similar problem with a new app (v1.0 not yet released in store) that I was trying to add in app purchases too. I set everything up, added products, etc. and my products ALWAYS came back as invalid when I did an SKProductsRequest.
I was about to give up on the entire process, when I saw a tangentially-related post on the Apple developer forums. It suggested deleting the app from the test device and and doing a fresh build+install. That did the trick.
Just to be sure, I tried it on another device that was giving me the same trouble, and it fixed it there too.
It's just a guess, but I think that if the device has a build on it that was made with a provisioning profile that was created BEFORE you add IAP, you need to remove that build and put on a fresh one using the IAP profile. (That is, simply replacing the app in place won't do the trick.)
如果你的代码没有问题,
有时它会返回无效的productId
只是因为,您可能需要 10 个小时以上的时间来更改信息。生效。
或者,productId 无效,因为您的设备上仍然存在错误,因此您可以再次尝试删除应用程序并重新构建它。
以我的经验,
希望它会有所帮助。
if nothing wrong in your code,
sometime it has return invalid productId
just because, you may need a time over 10 hour for your changing info. taking effect.
Or, the productId invalid because something wrong are remained on your device, so you can try once more with delete your app and build it again.
with my experience,
hope it will helps.
好吧,在做了我能想到的所有事情并阅读了每个论坛之后,这就是有效的方法:
重做所有事情。
这就是我的商店正常运转所需要的。我最好的猜测是苹果后端服务器有时会搞砸,你只需要从头开始。
希望这对大家有帮助!
OK, so after doing everything I could possibly think of and reading every forum out there, here is what worked:
Redo EVERYHING.
This is what it took to get my store working. My best guess is that the Apple back end servers get screwed up sometimes and you just need to start from scratch.
Hope this helps everyone!
IAP 的 iTunes Connect 界面最近已更新,可能会导致无效:<产品编号>错误。
您现在可以在 iTunes connect 中添加 IAP,而无需设置价格(默认为 0 美元),它会让您保存该条目。
如果您没有事先编辑价格字段,旧版本的 UI 会在您按“保存”时抱怨。
很容易完全忽略此字段,并且任何通过任何 iOS 调用使用该产品 ID 获取信息的尝试都会导致 Invalid : <产品编号>而不是告诉你它发现了<产品编号>售价为 0 美元。
iTunes Connect interface for IAP has recently been updated that can cause Invalid : < Product ID > error.
You can now add an IAP in iTunes connect without setting the price which is defaulted to USD 0 and it'll let you save that entry.
The old version of the UI would complain when you press save if you didn't edit the price field beforehand.
It is very easy to miss this field out completely and any attempt to get information using that Product ID via any iOS call would result in Invalid : < Product ID > rather than telling you it found < Product ID > priced at USD 0.