Search code examples
objective-ctestingin-app-purchaseitunesstorekit

Could not connect to iTunes Store issue inapp purchase objective c


I am working on inApp purchase in objective c. I setup almost everything fine in itunesconnect and write code on my project. Here's my code

-(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
for (SKPaymentTransaction *transaction in transactions) {
    switch (transaction.transactionState) {
        case SKPaymentTransactionStatePurchased:[self UnlockPurchase];
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
            break;

        case SKPaymentTransactionStateFailed:NSLog(@"Transaction Failed");
            [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
            NSLog(@"error: %@", transaction.error.localizedDescription);
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry"
                                                            message:transaction.error.localizedDescription
                                                           delegate:self
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
            [alert show];
    }
}

}

When I press Buy button it ask to sign in with "Use Existing Apple ID" and is working fine if sandbox user id is entered. But If I have signed in with free apple ID on my phone settings in both 'iCloud' and 'iTunes & App Store' the above code goes to SKPaymentTransactionStateFailed case. At the same time if I try to buy something on other apps it ask to purchase from App Store with pop up from bottom. Screenshot of another app

Please anyone show me the way to ask for purchase as shown on above screenshot even if the user has signed in iTunes & App Store. Thanks in advance.


Solution

  • Don't worry about that, it's the behavior with sandbox and apple. In prod, you'll have a popup from the bottom. Thanks to apple