A super easy way to check if the installed app has an update available. It is built with simplicity and customisability in mind and comes with pre-written tests.

Overview

UpdateAvailableKit

This is UpdateAvailableKit: a super easy way to check if the installed app has an update available. It is built with simplicity and customisability in mind and comes with pre-written tests.

Installation

UpdateAvailableKit is available via Swift Package Manager. To add UpdateAvailableKit simply add this repo’s URL to your project’s package file. You can choose to use one of the stable releases (tagged) or you can point your package file to the main branch of this project. Although, I would not merge broken code into the main branch, if you prefer stability, it’s recommended to use a tagged version.

https://github.com/SwapnanilDhol/UpdateAvailableKit

Usage

UpdateAvailableKit operates using a singleton class named UpdateAvailableManager. This class contains two publicly exposed methods. The important driver is this method:

public func checkForVersionUpdate(
    with bundleID: String = Bundle.main.bundleIdentifier,
    currentVersion: String = Bundle.main.releaseVersionNumber,
    useCache: Bool = true,
    completion: @escaping((Result<UpdateAvailableResult, Error>) -> Void)
)

checkForVersionUpdate is self describing. It checks the current version that’s installed on the device and compares it to the version that’s live on the AppStore. It returns a Swift Result where Success is UpdateAvailableResult and failure is a generic Error for now.

The function accepts a few parameters. Most of them have a default value attached to them but can be overridden when necessary.

  • bundleID: Pass a Bundle Identifier here. It defaults to your target’s Bundle.main.bundleIdentifer value.
  • currentVersion: Pass the current version of your app in a String format (XX.XX.XX). This, again, defaults to the current version of the app using values from Bundle.main.
  • useCache: Flag to decide if the completion handler returns values from a cached response or a newly fetched result from iTunes. More about Caching in UpdateAvailableKit towards the end of this file.

Use it in your projects like this

UpdateAvailableManager.shared.checkForVersionUpdate { result in
    switch result {
    case .success(let result):
        switch result {
        case .updateAvailable(let newVersion):
            print("Update Available. New Verison is \(newVersion)")
        case .noUpdatesAvailable:
            print("No updates available")
        }
    case .failure(let error):
        print("Error did Occur. Error was \(error)")
    }
}

UpdateAvailableResult

UpdateAvailableResult is an enum conforming to Equtable with two cases:

case updateAvailable(newVersion: String)

This case will be returned by the checkForVersionUpdate method’s completion handler when there’s a new version available. The associated value is the latest AppStore version in String type.

case noUpdatesAvailable

This case will be returned when the current installed version is equal to or greater than the AppStore version.

Async Alternative

UpdateAvailableKit support Swift's new concurrency features. If you’re using iOS 15 and above, you can choose to use the async await alternative. Thanks to Rudrank Riyam for this contribution.

switch try await UpdateAvailableManager.shared.checkForVersionUpdate() {
case .updateAvailable(let newVersion):
    print("New Version is available. \(newVersion)")
case .noUpdatesAvailable:
    print("No updates available")
}

Caching

To fetch the current AppStore version, UpdateAvailableKit performs a GET request to the ITunesLookup end point. The URL is https://itunes.apple.com/lookup?bundleID=yourBundleID.
The response is then cached for 3600 seconds so as to not make repeated calls to the API and to trigger the completion super fast. 🚀 The response is encoded and stored in UserDefaults. No external cache solution is used. In the future, I’d like to move it to a solution based on SwiftCache.

Like the framework?

If you like UpdateAvailableKit please consider buying me a coffee 🥰

Contributions

Contributions are always welcome. Please follow the following convention if you’re contributing:

  • NameOfFile: Changes Made
  • One commit per feature
  • For issue fixes: #IssueNumber NameOfFile: ChangesMade

License

This project is licensed under the MIT License - see the LICENSE file for details

You might also like...
iOS utility classes for asynchronous rendering and display.

YYAsyncLayer iOS utility classes for asynchronous rendering and display. (It was used by YYText) Simple Usage @interface YYLabel : UIView @property NS

An iOS framework for easily adding drawings and text to images.
An iOS framework for easily adding drawings and text to images.

jot is an easy way to add touch-controlled drawings and text to images in your iOS app. What's jot for? Annotating Images jot is the easiest way to ad

Display and interact with SVG Images on iOS / OS X, using native rendering (CoreAnimation)

SVGKit SVGKit is a Cocoa framework for rendering SVG files natively: it's fast and powerful. Some additional info and links are on the wiki Versions:

Create gradients and blur gradients without a single line of code
Create gradients and blur gradients without a single line of code

EZYGradientView is a different and unique take on creating gradients and gradients with blur on the iOS platform. The default CAGradientLayer implemen

The application is develop in Objective IOS. kids can draw whatever they want and also kids can save the drawing as well as undo erase the drawing.
The application is develop in Objective IOS. kids can draw whatever they want and also kids can save the drawing as well as undo erase the drawing.

IOSObjC_KidsBoard The application is develop in Objective IOS. kids can draw whatever they want and also kids can save the drawing as well as undo era

When you scan the clothing tag, a 3D character appears and informs you of the clothing information.
When you scan the clothing tag, a 3D character appears and informs you of the clothing information.

1. Introduction When you scan the clothing tag, a 3D character appears and tells you the information on the clothes. You can select necessary informat

3D Touch Application for Weighing Plums (and other small fruit!)

Plum-O-Meter ###3D Touch Application for Weighing Plums (and other small fruit!) Companion project to this blog post: http://flexmonkey.blogspot.co.uk

A Swift playground that comes pre-loaded with Plot, that can be used to explore the new component API.

PlotPlayground A Swift playground that comes pre-loaded with Plot, so that you can quickly try out the library and its new, SwiftUI-like API for build

A tool to check which keychain items are available to an attacker once an iOS device has been jailbroken

Keychain Dumper Usage All that should be needed to use keychain_dumper is the binary that is checked in to the Keychain-Dumper Git repository. This bi

This projects shows how we can server-side add/update "ANY" custom font in a live iOS App without needing to update the app.

Server-side-Dynamic-Fonts This projects shows how we can server-side add/update "ANY" custom font in a live iOS App without needing to update the app.

A repository that demonstrates the difficulty to run async tests with Xcode 13.2 beta on pre iOS-15 simulators

A repository that demonstrates the difficulty to run async tests with Xcode 13.2 beta on pre iOS-15 simulators This demonstration uses an iOS 13.7 sim

Launches unc0ver in a way that works when it's installed through TrollStore

u0Launcher Normally when you install unc0ver through TrollStore and try to jailbreak with it, it fails with a "Failed to disable codesigning" error be

Disk is a powerful and simple file management library built with Apple's iOS Data Storage Guidelines in mind
Disk is a powerful and simple file management library built with Apple's iOS Data Storage Guidelines in mind

Disk is a powerful and simple file management library built with Apple's iOS Data Storage Guidelines in mind

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind
A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.

Check and update  app's version for both AppStore & Fir
Check and update app's version for both AppStore & Fir

VersionUpdate Check and update app's version for both AppStore & Fir How to use Add Channel in info.plist Now we only support two channels "AppStore"

OctopusKit is a simplicity but graceful solution for invoke RESTful web service APIs
OctopusKit is a simplicity but graceful solution for invoke RESTful web service APIs

OctopusKit OctopusKit is a simplicity but graceful solution for invoke RESTful web service APIs,it can help coder develop app based MVC pattern, it ca

Fetch the update available status for iOS or macOS apps based on the bundle identifier.

AppUpdately Fetch the update status for a given app bundle identifier, without the need of any remote configuration. Simply provide your app's bundle

Simple class to check if app has been cracked, being debugged or enriched with custom dylib

iOS-App-Security-Class Simple class to check if iOS app has been cracked, being debugged or enriched with custom dylib and as well detect jailbroken e

Releases(UpdateAvailableKit-1.0.1)
Owner
Swapnanil Dhol
21, WWDC '21, '20, '19 Scholar, GSoC 2020 with VideoLAN (VLC), iOS Developer, Aviation enthusiast.
Swapnanil Dhol
NXDrawKit is a simple and easy but useful drawing kit for iPhone

⚠️ To use with Swift 5.0 please ensure you are using >= 0.8.0 ⚠️ ⚠️ To use with Swift 4.2 please ensure you are using >= 0.7.1 ⚠️ ⚠️ To use with Swift

Nicejinux 1.3k Dec 31, 2022
Powerful and easy-to-use vector graphics Swift library with SVG support

Macaw Powerful and easy-to-use vector graphics Swift library with SVG support We are a development agency building phenomenal apps. What is Macaw? Mac

Exyte 5.9k Jan 2, 2023
Crafter - Xcode project configuration CLI made easy.

How do you setup your Cocoa projects? Do you always set same warnings, clone configurations and do bunch of other stuff? Or maybe you work in a big co

Krzysztof Zabłocki 548 Nov 28, 2022
SVG parser and renderer written in SwiftUI

SVGView SVG parser written in SwiftUI We are a development agency building phenomenal apps. Overview The goal of this project is to bring the full pow

Exyte 269 Jan 4, 2023
A lightweight XMLParser for assembling and parsing XML values written for iOS 8+ in Swift 2.

Overview Description Requirements Installation Usage Author License Description XMLParser lets you convert a pure Swift dictionary into XML string and

Eugene Mozharovsky 75 Feb 2, 2022
QEMU-Manager is a macOS graphical frontend to QEMU, written in Swift.

QEMU-Manager About QEMU-Manager is a macOS graphical frontend to QEMU, written in Swift. Screenshots General Configuration: Hardware Configuration: Di

Jean-David Gadina 212 Jan 6, 2023
Conical (angular) gradient for iOS written in Swift

AEConicalGradient Conical (angular) gradient in Swift I hope that somebody will find this useful. And nice. Usage AEConicalGradient is a minion which

Marko Tadić 82 Dec 27, 2022
it's simple drawing app.

IOSObjC_KidsBoard The application is develop in Objective IOS. kids can draw whatever they want and also kids can save the drawing as well as undo era

Vnnovate Solutions Pvt Ltd 0 Oct 28, 2021
it's simple drawing app

IOSObjC_KidsBoard The application is develop in Objective IOS. kids can draw whatever they want and also kids can save the drawing as well as undo era

Jiten Engineer 0 Oct 28, 2021
A simple, performant, and lightweight SVG parser

Key Features Parsing performance that meets or beats other popular SVG Frameworks A simple architecture, optimized for extension, flexibility and deve

Michael Choe 1.8k Dec 29, 2022