Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sentryco/upgradealert
ð Easily update your app
https://github.com/sentryco/upgradealert
appstore appupgrade beta check-for-update checkupgrade checkversion nsalert prompt release required security-update soft-brick testflight uialertcontroller updatewall upgrade upgradewall
Last synced: 1 day ago
JSON representation
ð Easily update your app
- Host: GitHub
- URL: https://github.com/sentryco/upgradealert
- Owner: sentryco
- Created: 2023-03-31T07:37:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-19T03:46:22.000Z (29 days ago)
- Last Synced: 2024-11-13T23:48:25.011Z (3 days ago)
- Topics: appstore, appupgrade, beta, check-for-update, checkupgrade, checkversion, nsalert, prompt, release, required, security-update, soft-brick, testflight, uialertcontroller, updatewall, upgrade, upgradewall
- Language: Swift
- Homepage:
- Size: 513 KB
- Stars: 9
- Watchers: 0
- Forks: 2
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![mit](https://img.shields.io/badge/License-MIT-brightgreen.svg)
![platform](https://img.shields.io/badge/Platform-iOS/macOS-blue.svg)
[![SPM compatible](https://img.shields.io/badge/SPM-compatible-4BC51D.svg?style=flat)](https://github.com/apple/swift)
[![Tests](https://github.com/sentryco/UpgradeAlert/actions/workflows/Tests.yml/badge.svg)](https://github.com/sentryco/UpgradeAlert/actions/workflows/Tests.yml)
[![codebeat badge](https://codebeat.co/badges/3cf70bb0-e669-4ad2-b772-e76175cd23c1)](https://codebeat.co/projects/github-com-sentryco-upgradealert-main)# ð UpgradeAlert
> Easily update your app
## Table of Contents
- [Problem](#problem)
- [Solution](#solution)
- [Screenshots](#screenshots)
- [Example](#example)
- [FAQ](#faq)
- [Gotchas](#gotchas)
- [Todo](#todo)
- [License](#license)### Problem:
- ðĨ macOS app does not auto update by default, unless user has set this specifically in app-store.
- ðē iOS auto update by default, but a few might have turned it off.
- ðļ Users might be stuck on old OS. that we no longer support. In that case we need to "soft-brick" the app
- ðŠĶ Supporting 6+ month old app versions in your backend
- ðĨķ Supporting multiple versions of your app you will result in bloated app code that is hard to iterate on
- ðĪŽ Users will stop complaining about issues that are already fixed in the last update
- ðĨĩ Users will stop giving bad reviews because of errors with old software
- ðĨ Avoid crashes by staying compatible with the latest device API changes and platform updates
- ðĻ Getting urgent security updates out to as many users as possible as quickly as possible### Solution:
- When the current app version is outdated. The user is prompted with a link to AppStore where the user can update
- Two different alerts can be prompted. One where there is an option to update later and one where the user required to update
- You can customize alert title, message and button text> **Warning**
> Setting `isRequired = true` bricks the app until it's updated### Screenshots:
**For iOS:**
**For macOS:**
### Example:
```swift
import UpgradeAlertguard Bundle.isBeta else { Swift.print("App is beta or simulator, skip checking for update"); return }
UpgradeAlert.config = UAConfig( // Config the alert
isRequired: false, // Require users to update
alertTitle: "Update required", // alert title
alertMessage: { version in "Version: \(version) is out!" }, // alert msg
laterButtonTitle: "Later", // skip button title
updateButtonTitle: "Update Now" // go to appstore btn
)
UpgradeAlert.checkForUpdates { outcome in // check apple endpoint if there is a new update
if case .err(let err) = outcome {
Swift.print("Err: \(err.localizedDescription)")
} else { // opportunity to track user action here with GA etc
swift.print("Outcome: \(String(describing: outcome))") // notNow, notNeeded, appStoreOpened
}
}
```
**For debugging**```swift
// UA prompt alert test. so we can see how it looks etc.
UpgradeAlert.showAlert(appInfo: .init(version: "1.0.1", trackViewUrl: "https://apps.apple.com/app/id/com.MyCompany.MyApp"))
```### FAQ:
**Q:** What is an Upgrade-Wall?
**A:** Upgrade-Wall or Update-Wall is a system/service that prevents mobile app users from using the app who are still using the older versions of the app.**Q:** Why do we need Upgrade-Wall?
**A:** A required upgrade may be required when there are breaking changes in the backend API which will result in an app crash or when there are security issues in older apps and a new version of the app is released and you may want to require users to update to the newly released version. Also in cases where you want to encourage users to update your app to the newly released versions because you have launched a new cool feature and want users to explore and use it. In these scenarios, Upgrade-Wall is necessary to have in place.**Q:** How to Implement Upgrade-Wall?
**A:** Upgrade-Wall can be implemented with two strategies, hard and soft Upgrade-Walls. A Hard Upgrade-Wall completely restricts the users from using the app and requires them to update the app. A Soft Upgrade-Wall offers greater flexibility to users, generally giving users the freedom to either update the app or skip the update to a later time. Both the strategies can be implemented by showing a popup/alert to users. When the user opens the app, Hard Upgrade-Wall will show a non-dismissible popup with only an update button. Users cannot skip the popup and will have only one option to update the app. On pressing the update button the app should open the play store or AppStore of the app from where the user can update the app to the latest version. Soft Upgrade-Wall will show a dismissible popup to the user with options to either update the app or skip. Users can skip and continue using the app. An example of Hard Upgrade-Wall and Soft Upgrade-Wall. You can skip the pain of building an Upgrade-Wall yourself and use solutions which are already there.### Gotchas:
- For macOS `applicationDidBecomeActive` will be called after dismissing the UpgradeAlert, make sure you init UpgradeAlert from another method or else it will create an inescapable loop. This does not apply for iOS.### Todo:
- Add screenshot from a test app? â
- Add support for testflight. There is a repo in issues with a link to another repo that recently added support for this
- Add country-code to json. en -> english etc. (later)
- Add localization support
- Add support for: SKStoreProductViewController allowing the update to be initiated in-app. see https://github.com/rwbutler/Updates/ for code
- Maybe add 1 day delay to showing update alert: to avoid an issue where Apple updates the JSON faster than the app binary propogates to the App Store. https://github.com/amebalabs/AppVersion/blob/master/AppVersion/Source/%20Extensions/Date%2BAppVersion.swift
- Doc params
- Clean up comments
- Add support for swiftui
- Error Handling and Reporting: The current implementation of error handling in various parts of the codebase could be improved for better clarity and functionality. For instance: UpgradeAlert.swift: The method checkForUpdates uses a simple closure that returns an optional error. This could be enhanced by using a Result type to make the success and error handling paths clearer and more robust.
- UIAlertController+Ext.swift: The present method does not handle the scenario where there is no view controller available to present the alert. This could lead to silent failures in presenting critical update alerts.
- Refactoring and Code Simplification_ Refactoring some parts of the code could improve readability and maintainability. For example: UpgradeAlert+Variables.swift: The method for generating the request URL could be simplified or made more robust by handling potential errors more gracefully.
- NSAlert+Ext.swift: The method for presenting alerts in macOS could be refactored to reduce duplication and improve error handling.
- Testing and Coverage Improving tests to cover edge cases and error scenarios would enhance the reliability of the application. For instance:
- UpgradeAlertTests.swift: The test cases could be expanded to cover more scenarios, including error handling and user interaction outcomes.