How to determine the date an app is installed or used for the first time?

后端 未结 10 580
慢半拍i
慢半拍i 2020-12-03 01:40

I\'m planning on opening up an in app store and I\'d like to give existing users some of the items for free.

I thought of releasing an update which would store some

10条回答
  •  一整个雨季
    2020-12-03 02:00

    Swift solution:

    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)")
    

提交回复
热议问题