0

I want to ask if we have any type of notification or flag available in case an app is updated from the App Store?

E.g. When first time user opens the app after the update, we have some flag to identify in didFinishLaunchingWithOptions in AppDelegate.

schinj
  • 794
  • 4
  • 19
  • An alternative to achieve the same: You can save the previous app version in preferences and in didFinishLaunchingWithOptions compare your current app version with the preferences version. And don't forget to update the version in preferences. – Mohit Kumar Jan 22 '20 at 09:33

2 Answers2

0

You can store app version in user defaults and check if current app version is upper than the one you stored in user defaults. if so, update the user defaults to new version.

omid
  • 15
  • 5
  • That's one way of doing it. I am expecting something provided by Apple by default. – schinj Jan 23 '20 at 07:43
  • Check this out https://stackoverflow.com/questions/16899503/check-if-my-ios-application-is-updated – omid Jan 23 '20 at 12:57
-1

You can check app store version. and your current app version.

guard let info = Bundle.main.infoDictionary,
    let currentVersion = info["CFBundleShortVersionString"] as? String,
    let identifier = info["CFBundleIdentifier"] as? String,
    let url = URL(string: "http://itunes.apple.com/lookup?bundleId=\(identifier)") else {
    throw VersionError.invalidBundleInfo
}
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 {
    return version != currentVersion
}
throw VersionError.invalidResponse
Sishpal
  • 9
  • 1