I am trying to check whether user has installed this app on his iOS device before or not.
For example I install app X , then Uninstall it, and again Install it.
I want that app X be able to detect that the device had installed this app before and this is a re-installation.
Update
By thanks to all friends that shared solutions like keychain, vendor Id and etc. The main subject that I should notice (as mentioned in comments) is that; Is there a solution that works even after system restore or system factory reset? According to @Andrea's answer using receipts may work but what about the cases that we want to publish the app in enterprises account? Or what if user uses a jailbreak device and install the app with and IPA? Some times because of security problems we want to detect that whether this app is installed before or not? So how we can detect it?