简体   繁体   中英

How to check is iPhone has my app installed before?

I would like to know if a user has previously had the app installed on the same device. Is there some sort of unique id I can check?

You can use shared Keychain to store your AppId and other sensitive informations and fetch on app launch. Deleting the app will not remove/clear data from keychain. You will save and clear data programmatically. Also Apps from same family(developed by same team) only can read data from a shared keychain and data is kept in encrypted form so this is fully secured. You can follow bellow link. http://evgenii.com/blog/sharing-keychain-in-ios/

User can change identifierForAdvertising any time in Settings, identifierForVendor changes after reinstall app, if no more apps on device from this vendor.

Here is alternative and the best solution for get or persistent, cross-install Device Identifier:

description: https://blog.onliquid.com/persistent-device-unique-identifier-ios-keychain/

code: https://gist.github.com/miguelcma/e8f291e54b025815ca46

You can check that the app is currently available in the iPhone or not from the below code. Here instead of the string "yourappname://", you have to specify the url scheme of that app. You can find the tutorial of the URL Scheme from this link .

Swift code

let appInstalled = UIApplication.shared.canOpenURL(URL(string: "yourappname://"))
if(appInstalled) {
   print("It is installed")
}
else
{
   print("It is not installed")   
}

Objective-C code

BOOL isInstalled = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"yourappname://"]];

if(isInstalled){

NSLog@("It is installed");

}
else{

NSLog@("It is not installed");

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM