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 ✦
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.