userMod2
userMod2

Reputation: 9000

iOS - Restore in app purchase if app itself was already purchased

An iOS app was a initially paid app, then later became free with an in app purchase option.

For a user who has already purchased the app would the restore code below, actually restore it? Or does that restore only app specifically to the in app purchase?

If it's only to the in app purchase how can I ensure users who actually paid for the app are also 'restored':

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{

    for (SKPaymentTransaction *transaction in transactions)
    {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                NSLog(@"Purchased Case");
                [defaultQueue finishTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                NSLog(@"Failed Case");
                [defaultQueue finishTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                NSLog(@"Restored Case");
                [defaultQueue restoreCompletedTransactions];
                break;                
            default:
                break;
        }
    }

}

And I get the in-app purchased product itself using:

- (void) getProductInfo
{
    if ([SKPaymentQueue canMakePayments])
    {
        NSSet *productID = [NSSet setWithObject:@"myoneoffid"];
        SKProductsRequest *request = [[SKProductsRequest alloc]initWithProductIdentifiers:productID];
        request.delegate = self;
        [request start];
    }
}

Thanks.

Upvotes: 1

Views: 193

Answers (1)

rmaddy
rmaddy

Reputation: 318944

No, you can't use the "restore purchases" functionality to grant access to users who originally purchased your non-free app prior to adding in-app purchases. Of course you need that functionality in your updated app for newer users that do purchase the in-app purchases.

To handle the case of earlier purchasers of your app, you need to do receipt validation. You can get the receipt and check the original purchase version. If that version is older than whatever version you switched to free with in-app purchases, then you can grant the user access to those features without making them pay for anything.

See Change paid app to free but know if user previously purchased it for more details.

Upvotes: 3

Related Questions