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.
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: "") |
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 ๐ซ๐ท๐ท