Karthik_S
Karthik_S

Reputation: 119

In App Purchase returns no response

I have implemented In App Purchase for my App. It was working fine but now I am not able to get response after SKProductsRequest.

Attaching my Code

[self.delegate showProgressHUDWithTitle:@"Loading Product"];
// select from IPA Items //

// Check if Parental Control is enabled so that purchase will fail //
if ([SKPaymentQueue canMakePayments])
{
 SKProductsRequest *Prequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"Item 1"]];

  Prequest.delegate = self;
  [Prequest start];
  request = Prequest;

}

This method is also not getting called ---> -(void)request:(SKRequest *)request didFailWithError:(NSError *) error

-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{ 

    [self.delegate hideProgressHUD];

    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];

    SKProduct *validProduct = nil;

    int count = [response.products count];

    if (count>0)
    {
             validProduct = [response.products objectAtIndex:0];
            if ([validProduct.productIdentifier isEqualToString:purchasingItem])
            {
                SKPayment *payment = [SKPayment paymentWithProduct:validProduct];
                [[SKPaymentQueue defaultQueue] addPayment:payment];
            }
            else
            {
                NSLog(@"No Valid Products");
            }    

      }
  } 

Upvotes: 1

Views: 1724

Answers (1)

focused4success
focused4success

Reputation: 433

This problem is still occuring. It is the subject of many discussions on the Apple Developer Forums see: SKProductsRequest does not work. I added the following code suggested from the thread to verify I was seeing the same problem, I recommend you do the same.

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"In-App Store unavailable" message:@"The In-App Store is currently unavailable, please try again later." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];

}

I don't plan to put this code in production, instead I'll disable the In-App Purchase buttons if this happens, then check again later.

This appears to be a problem with the Xcode 5 simulator for the past few weeks. I don't know where to check the status of getting it fixed. IAP works on the device, so you can test there for the time being.

Upvotes: 2

Related Questions