hi - I currently have a paid app on the App store. I'm planning to change it to a free app with ads, but with an in-app purchase option to turn the ads off. Obviously I don't want to impose any of this on the folks who've already bought the app. Is there a way to find out in-app if the app is running for the first time on a system or if it's an update? My app does create a data file the first time it runs, so I could simply just check for the presence of that file, but I'm wondering if there's any other way. Thanks.
Does an app know if it's being run for the first time, or updated?
Sep 22 2018 04:33 PM
That should be reliable as long as the app is not deleted. If you put the file in a folder the user allows to be stored in iCloud you will have something to track across installs/devices. Other than that, I don't think there is a more intelligent method than the classic "firstrun.txt" method.
system.CachesDirectory is NOT backed up by iCloud. The assumption is that if it's in system.CachesDirectory, it's content that can be re-downloaded from the Internet and there is no guarantee the file will not be deleted by the system.
You can either use a file that exists in system.DocumentsDirectory that your app creates when it runs to detect if the user has already run the app or you can use system.setPreferences() to set a "hasRun = true" flag.
Now the problem is if someone deletes the app. The sandbox files are cleared. The iCloud backups are removed and I'm pretty sure the system.setPreferences() are cleared as well. If someone deletes the app, they will lose any knowledge that they have previously purchased/ran your app.
There isn't much you can do here. One possibility that might work, but will take time and I'm not sure how well Apple would take this, but you could issue an update to your app that has a "Free" in-app purchases and notify the user, they need to get the free IAP since you plan to make the the app free with Ads in the future and by getting this free IAP then they will be assured to be able to keep the app for free in case they delete the app in the future.
Then give them a period of time (say a month or so) when that IAP becomes a paid item, then you can make the app free with paid IAP. Then after that, they can click the required "Restore Purchases" button if they do delete the app and re-install it later to get their purchase/unlock back.
Again, I have no idea if Apple would go for this or not. It might not capture everyone but it seems like it's a way to get your paid people in the IAP system.
The other thing would be recording some information about the user and their device on a remote server that you could check, but then you would have to deal with GDPR data tracking rules if you plan to have your app available to European Union customers.
Thanks for the info and suggestions. I created an in-app purchase and I see that it is in fact possible to set it to free, $0. So this could be a way to proceed. Perhaps I can release an update for current paying users which contains the free IAP, and then, a few weeks later, release the update with the ads, make the app free, and make the IAP cost money.
The other option I'm considering is just creating a brand new app with a slightly different name. I could remove the paid app, or run two apps with similar names, one paid, and the other free with ads. Then I wouldn't need any IAPs at all.
Anyway, I've just emailed Apple technical support to ask them if the IAP plan is doable. I will report back.
Update: what I've ended up doing is setting up two IAPs. One is free and the other costs money. After I update the app on the app store, there'll be two types of user: those who already bought the app, and those who are getting it for free, with ads. Folks who are updating from a previous (paid) version will see no ads, and will be offered a free IAP to restore the app to ad-free in the event they ever need to delete/reinstall. Those who are starting with the free-with-ads version will see the ads and be able to buy/restore a paid IAP to turn them off. I haven't launched this yet but so far it seems to work ok using Apple's sandbox testing environment.