iosobjective-cin-app-purchaseapp-store-connectskproduct

How to test In-app purchase in Sandbox mode iOS?


Am new to In-app purchase integration in iOS application. I have done the coding in the project level and I have created a Sandbox user in iTunes Connect. I read many tutorials and Apple Document to test the In-App purchase in DEV mode. As per the document I have removed the APPLE ID from iPad Settings and launched the app from Xcode. But, I didn't received the Account Alert from the app. Also, my products are returning empty in SKProductRequest delegate method didReceiveResponse. I have posted my code for your reference. Can you please help me on this? Am working since last two days. Please help me. Thanks in advance.

- (void) getAvailProducts
{
    NSLog(@"Fetching Available Products");
    NSSet *productIdentifiers = [NSSet setWithObjects:@"com.test.testios.monthly", @"com.test.testios.yearly" ,nil];

    self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];

    self.productsRequest.delegate = self;

    [self.productsRequest start];
}

-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    //SKProduct *validProduct = nil;

    DebugLog(@"\n Products: %@", response.products);

    NSUInteger count = [response.products count];

    NSLog(@"Request Count: %lu", (unsigned long)count);

    if (count > 0)
    {
        self.validatedProducts = response.products;
        DebugLog(@“\n Products: %@", response.products);

        self.validationCheck = TRUE;

        [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];

        [[SKPaymentQueue defaultQueue] addTransactionObserver:self];

        // Check subscription        
    }
    else            
    {
      // No products found….              
    }
}

Also, I tried with "monthly and yearly" instead of "com.test.testios.monthly and com.test.testios.yearly". But, no results.

Edit: Am getting the mentioned ProductIds are invalid in the following code,

for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        NSLog(@"Invalid product id: %@" , invalidProductId);
    }

Solution

  • Thank you all.

    Fixed the issue and tested the In-App purchase in Sandbox environment. Following items fixed my issue,

    1. iTunes Agreement was not accepted.
    2. Tax and Payment details was not added.
    3. Added correct Product Identifier in project.