Get installation Date and Version of the App In Swift 3

Posted By : Gunjan Gumber | 20-Nov-2017

Here below i have explained how to get the installation date , last update Date, version of app and build of app in Swift 3.

 

 

1. Installation Date

With the help of swift 3 programming language now it is possible to know the installation date of ios aap.To get the installation date of app you have to find out the creation date of documents folder. Have a look on the code below;-

 let urlToDocumentsFolder: URL? = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last
 let installDate = try? FileManager.default.attributesOfItem(atPath: (urlToDocumentsFolder?.path)!)[.creationDate] as? Date
 print("Install Date of app is \(installDate)")

 

 

2. Updation Date

Apart from installation date, you will also get to know about the date of ios app update with the help of swift 3 programming language. You just need to insert the following code for this purpose. To get the last update date of app you have to find out the modification date of App Bundle.

 let pathToInfoPlist: String? = Bundle.main.path(forResource: "Info", ofType: "plist")
 let pathToAppBundle: String = URL(fileURLWithPath: pathToInfoPlist!).deletingLastPathComponent().absoluteString
 let updateDate = try? FileManager.default.attributesOfItem(atPath: pathToAppBundle)[.modificationDate] as? Date
 print("Last Update date of App is \(updateDate)")

 

 

3. Version of App

The version of ios application keep on changing every now and then for making it more user specific. So if you are eager to know about the latest version of a particular app you can take the help of swift 3 easily. To get the version of app inside the code , you can use the below method as it will return the current version of your ios app ;-

     func version() -> String {
        let dictionary = Bundle.main.infoDictionary!
        let version = dictionary["CFBundleShortVersionString"] as! String
        return "\(version)"
    }

 

4. Build of App

In case you are a curious person and have a zeal to know about the latest movements in the world of technology, especially related to the renowned brand, take the help of this programming language. It is easy to use and all kind of technical languages could be used here for programming.To get the build info of app , use the below method  :-

    func build() -> String {
        let dictionary = Bundle.main.infoDictionary!
        let build = dictionary["CFBundleVersion"] as! String
        return "\(build)"
    }

Thanks.

About Author

Author Image
Gunjan Gumber

Gunjan is a bright IOS developer with good knowledge in Swift ,Json, quite good at building user interface.

Request for Proposal

Name is required

Comment is required

Sending message..