Code to check if there is a new version on the App Store, to determine whether an update prompt needs to be shown.
Tip
After the app is released, it will not update immediately on the App Store; it needs to wait 24 hours before it works properly.
✦ My macOS/iOS application ✦
Welcome to download DevTutor, a cheat sheet app designed to help developers quickly build excellent applications using SwiftUI.
import CheckUpdate
CheckUpdate.checkVersion { isUpdateNeeded, appStoreVersion, currentVersion in
// Here it checks whether an update prompt needs to be shown.
}
CheckUpdate.checkVersion(bundleId: "com.wangchujiang.daybar") {
isUpdateNeeded,
appStoreVersion,
currentVersion in
// appStoreVersion -> "1.0"
// currentVersion -> "2.0"
// isUpdateNeeded -> false
}
CheckUpdate.checkVersion(bundleId: "com.wangchujiang.daybar") {
isUpdateNeeded,
appStoreVersion,
currentVersion in
// appStoreVersion -> "2.0"
// currentVersion -> "1.0"
// isUpdateNeeded -> true
}
Licensed under the MIT License.