Get date of when app was installed (iOS)

时间:2016-08-31 17:15:09

标签: ios

I was wondering if it was possible to get the installation date of the application. I am well aware you can store to NSUserDefaults when the app is first loaded, but I am looking for installation date, if possible.

Cheers

1 个答案:

答案 0 :(得分:1)

Found it through this link: How to determine the date an app is installed or used for the first time?

Im using Swift so here is the translation:

    let urlToDocumentsFolder = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).last!
    //installDate is NSDate of install
    let installDate = (try! NSFileManager.defaultManager().attributesOfItemAtPath(urlToDocumentsFolder.path!)[NSFileCreationDate])
    print("This app was installed by the user on \(installDate)")