Skip to content

Latest commit

 

History

History
119 lines (81 loc) · 5.11 KB

README.md

File metadata and controls

119 lines (81 loc) · 5.11 KB

AppStoreVersion

Because it is not always easy to maintain some features depending on the versions installed, especially if you have a REST API that is evolving with the app you are developing, I decide to create this framework to check if the users have the latest version available.

Version Build Status License Platform Swift

Install

AppStoreVersion is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AppStoreVersion'

Usage

The usage of this framework is very simple. You have two ways to check if the installed version is the latest available.

The easiest way 😎

If you want to let the framework manage the prompt alert to your users, just call in your code where you want to check the version:

AppStoreVersion.check(bundle: Bundle.main)

If the installed version of your app is the latest, it will do nothing. If it is not the latest, it will prompt an UIAlertViewController with an UIAlertAction to redirect yours users to the page of your app in the AppStore.

The freedom way 🚀

If you want to manage the display to your users, it is also very simple, you just need to call:

AppStoreVersion.check(bundle: Bundle.main) { (upToDate, error) in
    if error != nil {
        print(error!.localizedDescription)
    } else if !upToDate {
	    //TODO: Display to the users that their not using the latest version.
    }
}

Localization

This framework is based on the current device localization and will display, if there is no localization translations for the current locale, the english version will be used.

Available

🇬🇧 🇫🇷

Add a localization

Looking for a translation? Create a pull request or open an issue.

Key Example
AppStoreVersion.NewVersionTitle New Version Available ! 
AppStoreVersion.NewVersionMessage The version %@ is available on the AppStore.
AppStoreVersion.Download Download
AppStoreVersion.Later Later

Config

In order to be a very flexible framework, you can configure some features and data directly from your code.

For example, by default, the prompt alert displayed by the framework give to the users a "Later" button which will hide the UIAlertViewController. If you want to force your users to download the latest version, just say it:

AppStoreVersion.Config.optional = false

You can also configure the localization yourself:

AppStoreVersion.Config.Alert.title = "New version!"
AppStoreVersion.Config.Alert.message = "Find out our new features."
AppStoreVersion.Config.Alert.downloadActionTitle = "Let's do it!"
AppStoreVersion.Config.Alert.laterActionTitle = "No, thanks."

Default values

Config Default
AppStoreVersion.Config.optional true
AppStoreVersion.Config.Alert.title NSLocalizedString("AppStoreVersion.NewVersionTitle", comment: "")
AppStoreVersion.Config.Alert.message NSLocalizedString("AppStoreVersion.NewVersionMessage", comment: "")
AppStoreVersion.Config.Alert.downloadActionTitle NSLocalizedString("AppStoreVersion.Download", comment: "")
AppStoreVersion.Config.Alert.laterActionTitle NSLocalizedString("AppStoreVersion.Later", comment: "")

Errors

The framework extends Error in order to notify the followings errors:

Case Description
invalidAppStoreResponseCode Returned if the request to the App Store lookup API returns an invalid response code.
unableToReadAppStoreResponse Returned if the framework is unable to read the JSON returned from the App Store lookup API.
mandatoryKeysNotFound Returned if the framework is not able to find the mandatory keys in the JSON returned from the App Store lookup API.
appStoreVersionNotFound Returned if the framework is not able to find the App Store version of your app in the JSON returned from the App Store lookup API.

Contribute

This framework is very simple, and I want it to stay like this. But any new features or suggestions are always welcome, so feel free to create a pull request or open an issue.

Author

Made with ❤️ by iMac0de from Bordeaux, France 🇫🇷🍷

Apps using this framework

Elyot