Nic Hubbard
Nic Hubbard

Reputation: 42139

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?

Upvotes: 43

Views: 11486

Answers (7)

Ofir Malachi
Ofir Malachi

Reputation: 1286

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;

Upvotes: 3

mtozsahin
mtozsahin

Reputation: 1

In itunes connect you can generate promotion codes for in app purchases. You may create an IAP item for premium features, and give it as a promotion to the purchasers manually. Not an automatic solution though, it might save you from some headache.

Upvotes: -2

rmaddy
rmaddy

Reputation: 318794

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.

Upvotes: 69

Jason Mirk
Jason Mirk

Reputation: 313

Woudnt it be easier to just offer a free inanpp purchase at launch on the paid app. A button saying something like "Upgrade". And then switch that free inapp to paid on the next update?

Upvotes: -1

Wain
Wain

Reputation: 119031

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)

Upvotes: 2

neilco
neilco

Reputation: 8012

The only option is to release two updates. The first will write a value to NSUserDefaults identifying them as a purchaser. The second update is your ad-supported version which can read this purchaser-identifying value and hide the ads.

Upvotes: -4

RyanR
RyanR

Reputation: 7758

Not really, no. Best you can do is publish an update while it's still a paid app that writes some value to NSUserDefaults (or a file in the app data directory, doesn't matter which) that indicates it was purchased. Wait a week or however long you want, then publish an update that removes that code, timed to be released the same day the price changes to free.

Upvotes: -5

Related Questions