How to show the Update application for latest version functionality in iOS app (swift 3)

Updated 26 October 2021

Save

Update application for latest version

Many times we need to update the application in app store (version update) but user did not get a proper information regarding the updation of application, when he/she opens the application.

so now we can give a functionality like when user open application and any updation in app store then user will get pop up message to update the application.

for this we need to follow some steps:

1: we need to find the app store application version and current application version ,

get application version:

get application version in app store:

2: Now combine this two and write a common method to check like that:

3: Now on your first view controller write this code on viewdidload()

4: if the user click on update then move to app store.

Note:

copy the url of your application in app store and write like that.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


8 comments

  • Amir Thapa
    VersionError.invalidresponse in not working on swift 4.2
    • kunal prasad (Moderator)
      enum VersionError: Error {
      case invalidResponse, invalidBundleInfo
      }
      • Akshay
        thanks
  • vivekananda
    where is globalObjectHome.getAppStoreVersion() present in the code
    • kunal prasad (Moderator)
      Actually this is an object of class where we have defined all the methods , you can write in same place & use “self”.
      • vivekananda
        Thanks For the Reply
      • Arjun
        What methods have been written? Could you share that file?
  • phani
    Hi,

    let data = try Data(contentsOf: url)
    guard let json = try JSONSerialization.jsonObject(with: data, options: [.allowFragments]) as? [String: Any] else {
    throw VersionError.invalidResponse
    }
    if let result = (json[“results”] as? [Any])?.first as? [String: Any], let version = result[“version”] as? String {
    print(“version in app store”, version,currentVersion);

    return version != currentVersion
    }

    I am using Swift 4.2

    // After debugging, it is directly coming out here but why I donot Know why ? I think this is not working (let data = try Data(contentsOf: url) ) .Kindly Help me

    throw VersionError.invalidResponse
    }

  • Start a Project


      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home