I am attempting to implement IAP of hosted content on iOS 6.0.
Without posting a bunch of code, my code was sourced from the raywenderlich tutorials http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial and http://xinsight.ca/blog/iap-content-download-in-ios6/. This code works fine for purchasing normal non-consumable items.
I have created a new IAP item with hosted content, and uploaded it via xcode (using the method described in the second link above).
When I go to purchase the item, it brings up the alert and I click buy. Shortly after this my transaction fails, with case SKPaymentTransactionStateFailed being invoked below:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction * transaction in transactions) {
switch (transaction.transactionState){
case SKPaymentTransactionStatePurchased: {
if (transaction.downloads) {
[[SKPaymentQueue defaultQueue] startDownloads:transaction.downloads];
} else {
// unlock features
//[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
[self completeTransaction:transaction];
}
break;
}
case SKPaymentTransactionStateFailed: {
if (transaction.downloads) {
NSLog(@"transaction failed... but found downloads");
}
[self failedTransaction:transaction];
break;
}
case SKPaymentTransactionStateRestored: {
if (transaction.downloads) {
[[SKPaymentQueue defaultQueue] startDownloads:transaction.downloads];
} else {
// unlock features
//[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
[self restoreTransaction:transaction];
}
break;
}
default:
break;
}
}
}
The transaction.error.code appears to be SKErrorPaymentCancelled.
If I change the nature of this IAP item in iTunesConnect to not have hosted content then the purchase completes just fine. I am at a loss as to what would cause this.
Anyone with experience with IAP hosted content know of any pitfalls I should be aware of? Could it be to do with how I created the hosted content package? I just placed everything in the Supporting Files group in xcode when creating the package - inspecting the archive package in finder shows the contents as:
/dSYMs
/Info.plist
/Products/Library/InAppPurchaseContent/ProductIDName/Contents/#content here#
/Products/Library/InAppPurchaseContent/ProductIDName/ContentInfo.plist
Is this correct? Once uploaded it says "Waiting for Screenshot" which I understand is correct.