Determine if your app was installed before in iOS

Viewed 249

I need to check if my app was installed before on the device.

I had a method that stored some data on the keychain and then in the first launch, checked if the data exists and therefore determined if the app was installed before.

Unfortunately, like everyone I encountered the "Export Compliance Information" regarding the use of encryption in your app that Apple ask for when uploading the build. It's not clear if using the keychain is legaly included in the use of encryption that we are being asked for, it's just a huge headache and not something in the field of experties for a developer to determine..

Is there any other way to determine if an app was installed before ?

3 Answers

Storing info in the keychain is the only reliable way at the moment, until Apple finally decides to remove this (mis)feature.

"Export Compliance Information" does not play a role here, this question is related to encryption like in https. Unless you implement custom encryption schemes, you can usually answer "No" to the question (or add ITSAppUsesNonExemptEncryption with your answer to your Info.plist).

Apple has disabled all access to device unique identifiers over the years: UDID, MAC address, ...

So the answer is: No, there is no other way to uniquely identify a device between app installs.

The only thing that may work sometimes is storing the push notification token on a server. I don't know how things are now, but a few years back this token didn't change after app reinstalls. But according to Apple documentation, the push notification token is not guaranteed to remain the same. Ergo, it may or may not work.

To check if the app was installed before using the push token, you need to store both the push token and any unique ID (e.g. most obviously a UUID) on your server. This unique ID must also be stored in your apps disk space (e.g. most obviously UserDefaults). Then when the app starts up, you can check if the unique ID is already present or not, ... etc.. I guess it's clear now.

Alternative way

Start by asking the user. For example, give them a button to skip that long introduction (and an easy way to get back there).

If it's a time-consuming step, allow them to email or export that data and give them a very easy way to get it back in there.

It would be helpful to know exactly what you're trying to achieve.

Clarification

Keychain will not function without encryption. All users having ICloud keychain storage enabled are transmitting your data in encrypted form over the Internet.

Currently (2022) when you assign an uploaded build to your app publication on Apple's appstoreconnect.apple.com, the Export Compliance Information dialog box asks:

Does your app qualify for any of the exemptions provided in Category 5, Part 2 of the U.S. Export Administration Regulations?

You can select Yes for this question if the encryption of your app is: ... (a) Specially designed for medical end-use (b) Limited to intellectual property and copyright protection (c) Limited to authentication, digital signature, or the decryption of data or files (d) Specially designed and limited for banking use or “money transactions”; or (e) Limited to “fixed” data compression or coding techniques

If your usage isn't exempt per the above (etc.) then you'd need to submit the form.

Here's a discussion on this...

https://getonthestore.com/export-compliance/

...and a helpful form generator...

https://github.com/annual-self-classification-report/annual-self-classification-report.github.io

Lobbying

Further, why not contact Apple to request them to clarify the clearcut case of Keychain (etc.) and for them to lobby the US Government on behalf of developers to publish a more full list of scenarios, if you believe this is relevant? Be clear that you're not after legal advice per se.

https://developer.apple.com/contact/topic/select  ⬅ The rabbit warren starts here.

https://www.apple.com/public-policy-advocacy/  ⬅ An overview of Apple's public policy advocacy.

Related