Change paid app to free but know if user previously purchased it

I am considering changing my paid iOS app to be free, making it ad based, and having an in-app purchase option to remove the ads.

This sounds like a good idea if I was just launching the app, but we have over 30k paid downloads, and I don't want those users to ever see the ads when they update to the new version which is free.

Do I have any options here?


As of iOS 7, this can be done using proper receipt validation. Under iOS 7 you can obtain a receipt for the purchased app. Part of the data in the receipt includes information about the original purchase version of the app by the user. You can look at that version and if it is from before the release of your update to free with IAP, you can choose to give the user the full functionality without the user needing to purchase the upgrade again.

Of course if you wish your updated app to work under iOS 6, this is not an option.

See the Receipt Validation Programming Guide for details on receipt validation.


try fetch all receipt & analyse them by following data:

"expires_date" = "2017-09-24 11:25:19 Etc/GMT";
"original_purchase_date" = "2017-09-24 11:20:21 Etc/GMT";
"product_id" = "com.yourapp.service";

1. Get all user's receipts from the app store

+ (NSArray*)all_receipts{
    // Load the receipt from the app bundle.
    NSURL *receiptURL = [[NSBundle mainBundle]appStoreReceiptURL];
    NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
    if(!receipt){
        //no receipts yet...
        return nil;     
    }

    NSError *error;
    NSDictionary *requestContents = @{@"receipt-data": [receipt base64EncodedStringWithOptions:0],
                                      @"password":YOUR_SECRED_SHARED};
    NSData *requestData = [NSJSONSerialization dataWithJSONObject:requestContents
                                                          options:0
                                                            error:&error];
    if (!requestData) {
        return [NSArray array];
    }

    // Create a POST request with the receipt data.
    //get current qa / production url
    BOOL sandbox = [[receiptURL lastPathComponent]isEqualToString:@"sandboxReceipt"];
    NSURL *storeURL = [NSURL URLWithString:@"https://buy.itunes.apple.com/verifyReceipt"];
    if (sandbox) {
        storeURL = [NSURL URLWithString:@"https://sandbox.itunes.apple.com/verifyReceipt"];
    }
    NSDictionary *jsonResponse = [LTServer postUrl:storeURL.absoluteString attach:requestContents];
    NSLog(@"jsonResponse %@",jsonResponse);
    if(!jsonResponse){
        return [NSArray array];
    }
    NSArray *receipts_data = jsonResponse[@"latest_receipt_info"];
    return [receipts_data mutableCopy];
}

2. Each receipt will contain a dictionary:

    "expires_date" = "2017-09-24 11:25:19 Etc/GMT";
    "expires_date_ms" = 1506252319000;
    "expires_date_pst" = "2017-09-24 04:25:19 America/Los_Angeles";
    "is_trial_period" = true;
    "original_purchase_date" = "2017-09-24 11:20:21 Etc/GMT";
    "original_purchase_date_ms" = 1506252021000;
    "original_purchase_date_pst" = "2017-09-24 04:20:21 America/Los_Angeles";
    "original_transaction_id" = 1000000339209266;
    "product_id" = "com.yourapp.service";
    "purchase_date" = "2017-09-24 11:20:19 Etc/GMT";
    "purchase_date_ms" = 1506252419000;
    "purchase_date_pst" = "2016-11-27 04:20:19 America/Los_Angeles";
    quantity = 1;
    "transaction_id" = 1000000337203266;
    "web_order_line_item_id" = 1000000030161297;

If your current app has any data in user defaults or the keychain then that can be the indicator. When the app is first opened (in your new version) run a bit of code which:

  1. Checks for the data in defaults / keychain
  2. If found, enable the paid content / disable the ads
  3. Migrate that data to a new key (so you don't upgrade again / give away free stuff)