Manthan
Manthan

Reputation: 3914

Having problems with auto renewable subscription in app purchase in ios

I am having an app in which I am implementing Auto Renewable Subscription In App Purchase.

I am following this link link

With that, I am getting the alert successfully to purchase but when I press it again, it asks me every time to purchase.

There are two methods mentioned in it about checking an expiration date and if the product is expired.

But I am unable to found the proper solution from that.

Can anyone please help me???

Any help will be appreciated.

Thanks in advance.

Upvotes: 2

Views: 1414

Answers (1)

Jen Jose
Jen Jose

Reputation: 4045

Check this link

https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html

Apple suggests that the receipt validation should be done at the server side.

The status code received if the subscription has expired is 21006.


For RESTORING PURCHASES

- (IBAction)retoreinApp:(id)sender
{
    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

    self.restoringInAppStatusLabel.hidden = NO;

}

It will call the method after getting restore details :

- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {

    UIAlertView *alert ;
    if(queue.transactions.count >0)
    {
        for (SKPaymentTransaction *transaction in queue.transactions)
        {
            NSString *temp = transaction.payment.productIdentifier;

          NSLog(@"Product Identifier string is %@",temp);

        }

        alert = [[UIAlertView alloc ] initWithTitle:@"Restore Transactions" message:@"All your previous transactions are restored successfully." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
    }
    else
    {
        alert = [[UIAlertView alloc ] initWithTitle:@"Restore Transactions" message:@"No transactions in your account to be restored." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];

    }
    [alert show];

}

Upvotes: 3

Related Questions