问题
I'm trying to test In App Purchase within the sandbox environment.
In order to test the code I did the following:
Created an In App Purchase Test User account under 'Manage Users' in iTunes Connect
Created some in app purchase products under 'Manage Your In App Purchases'. I used numeric values and alpha-numeric values for the Product IDs.
Loaded the app onto the iPhone, went to Settings->Store and logged out of the regular store and into the test account created in step 1
Set a breakpoint in the (
void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
callback
All the submitted Product ID's are in the response.invalidProductIdentifiers
property.
When submitting the request I first tried the exact Product IDs created during step 2. I also tried prefixing them with the Bundle ID:
NSString *id2 = @"com.super.duper.8";
NSSet *productList = [NSSet setWithObjects:id2, @"8", nil];
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:productList];
Am I missing something obvious? Any help is appreciated.
Achim
回答1:
If you are still getting invalid product ids, I've been accumulating a checklist of all of the various causes:
http://troybrant.net/blog/2010/01/invalid-product-ids/
回答2:
I spent two days struggling with all my productsRequest (for AppID) ended up in response.invalidProductIdentifiers list, instead of in response.products list. Apple definitely did an F grade job in dealing with their storekit. It is confusing, intertwined and complex.
I did finally resolved it. One very important lesson I learned as indicated by few in the forums: It may take many hours for what you entered on the itunesconnect.apple.com to take affect.
There are two parts: application name and AppID in your xcode and what you entered in itunesconnection, they have to match exactly (case sensitive). If you registered or modified your in-App AppleID (I also completed all my contracts and bank information as suggested by some that the purchase actions won't work without getting this part done), you may as well go to bed before testing it again because it really takes hours in my case to take affect. I was so frustrated battling with this issue before my 9 year old dragged me for bed time story then surprised to find the issue disappeared when I woke up.
I found the suggestions by Eddy71 in http://www.iphonedevsdk.com/forum/iphone-sdk-development/21035-problems-creating-test-user-app-purchase.html really helpful. Before resolving it I did everything I possibly could do in Eddy's check list and still got zero products, one of my fears was that whether without uploading the binary code to complete the application registration in itunesconnect was ok (no need to go live as taught in http://blog.mugunthkumar.com/coding/iphone-tutorial-%E2%80%93-in-app-purchases/). It is indeed ok. Make sure the "cleared for sale" is check and in the icon is green (you need an extra step to approve it after filling out the form). The other fear was that whether I can use developer provisional (not distribution provisional) in debug mode, it is also indeed ok. I hope this may help some of you. Good luck and have faith. It will work eventually.
回答3:
Our issue was the last bullet point from Apple's FAQ, "Why are my product identifiers being returned in the invalidProductIdentifiers array?":
- You did not complete all the financial requirements (see the "Contracts, Tax, and Banking Information" section of this document).
- You did not use an explicit App ID.
- You did not use the Provisioning Profile associated with your explicit App ID.
- You did not use the correct product identifier in your code. See Technical Q&A, QA1329, 'In App Purchase Product Identifiers' for more information about product identifiers.
- You did not clear your In App Purchase products for sale in iTunes Connect.
- You might have modified your products, but these changes are not yet available to all the App Store servers.
- If you or App Review rejected your most recent binary in iTunes Connect.
I changed the most recent version (which had been rejected) to "Waiting for Upload" by clicking "Ready to Upload Binary" in iTunes Connect and the problem was resolved after about 10 minutes.
回答4:
it's OK that the phone is jailbroken, you just have to uninstall appSync in Cydia, then it works
回答5:
Apple has a fantastic document which is not well known that covers this at the end. It also dispels some myths about things that don't help (eg. submitting a binary).
Technote 2259 "Adding In-App Purchase to your iOS and Mac Applications"
回答6:
We ended up creating a new provisioning profile, there was a line somewhere (can't recall where, not in the docs for in app purchase) that stated that you have to enable in app purchase in the provisioning profile. We couldn't do that with our existing profile, so we created a new one and then we could enable it.
回答7:
Try resetting the iphone settings and delete the app from iphone and use the request product id directly without the Bundle ID
回答8:
For anyone else that has these issues, I highly recommend reading this thread on the Apple Forum.
回答9:
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 application, the device will still treat it as an App Store-installed app.
So delete the app from your device. Then install the app back onto the device using Build & Run with your device tethered to your Mac. It should work now :)
回答10:
In my case, I didn't complete the bank info, tax info, and contact info.Once I finish this, I can get my productID, hope this will help someone.
回答11:
This is where you are going wrong, you need this in your code:
NSSet *productList = [NSSet setWithObjects:product id]
You can get this product id from iTunes connect.
And you need to make sure that you have created a test user, and have signed out of your original iTunes account. Please see do not sign in with test user account, regardless of what apple documentation says, just use it when a pop up appears.
回答12:
What's that @"8" for? your product is named as com.super.duper.8 right?
http://blog.mugunthkumar.com/coding/iphone-tutorial-%e2%80%93-in-app-purchases/
回答13:
Another issue I had was that I had to go to Window > Organizer in Xcode and delete my app and the provisioning profile(s) and re-add my development provisioning profile. I restarted the device and xcode as an extra measure.
回答14:
I have tried every solution that available on the internet, and nothing worked, absolutely nothing. My problem: My device was jailbroken and had Cydia on it. I restored the device to factory defaults (Not jailbroken) and it worked the first time and returned the product ID no problem.
回答15:
For me the problem was that I had chosen "Turn on Content Hosting" when set up the In-App purchase. So I had to turn it off and the problem was resolved.
回答16:
It takes the store some time to make the products available to all server (see documentation). So you might experience a delay between creating a product in iTunes Connect and seeing that product id as a valid one when testing on device. For me it took around 12 hours till my products showed up.
回答17:
A note for others: do not use an NSMutableSet for the product IDs. It has to be an NSSet!
回答18:
If you want to keep your app data but you want to try deleting your app to fix this issue, sync your device first. Then delete your app and reinstall from Xcode -- this fixed the issue for me. Once it's working, you can restore your device from its backup -- this only takes a few minutes and the product requests still work after the restore.
回答19:
Not exactly sure why, but when I changed the request's product ID from 'com.mycompany.myapp.product' to 'product' it started working. Maybe it's because of how I have the product configured in iTunes Connect.
Give it a try, might work for some of you...
回答20:
replace:
NSSet *productList = [NSSet setWithObjects:id2, @"8", nil];
with:
NSSet *productList = [NSSet setWithObjects:@"8", nil];
回答21:
Another problem that might be. If the name of your xCode project is not written of English, or has other characters in it, bundle ID will have "------" where the name of your app should be. I thought it is just a convention for bundle id, to have this in xCode. Turns out, this was my problem, so name your xCode project on English ) I know this is not the case for the most, but anyway)
回答22:
I tried everything everyone is talking about. I ended up making a guest account first to see if the product ID could be found.... It was. So then I started quitting everything in activity monitor and found the problem. I had to quit the "store" processes below. All of a sudden I stopped getting the invalid product ID. Hope that helps someone out there.
来源:https://stackoverflow.com/questions/1041656/iphone-storekit-invalid-product-ids