Basically I am trying to make the in-app purchase work, but with no luck. Here is my code for requesting a product purchase
- (void)requestProductData
{
NSSet *productIdentifiers=[NSSetsetWithObject:productid];
request5= [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject: productIdentifiers]];
request5.delegate = self;
[request5 start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
myProducts = response.products;
for (NSString *invalidProductId in response.invalidProductIdentifiers)
{
NSLog(@"Invalid product id: %@" , invalidProductId);
}
SKProduct *selectedProduct = [myProducts objectAtIndex:0];
SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
The strange thing is that both response.products and response.invalidProductId have 0 objects in them.I've already tried things like checking the Provisioning Profile, the appID, the bundle ID and so on. Also, almost 24 hours have passed since I added the in-app purchase in itunes connect. Can anyone help me?
Check the code for making the request. You have:
NSSet *productIdentifiers = [NSSet setWithObject:productid];
request5 = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject: productIdentifiers]];
It should be:
NSSet *productIdentifiers = [NSSet setWithObject:productid];
request5 = [[SKProductsRequest alloc] initWithProductIdentifiers: productIdentifiers];
You are creating a set with one object - another set with the product id.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.