Skip to content

"AppVersion" is a Swift utility that checks for updates of your iOS application by comparing the version on the App Store with the currently installed version. It provides an easy way to prompt users to update to the latest version, ensuring they have the best experience with your app.

Notifications You must be signed in to change notification settings

meetiosdev/CheckAppVersion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

CheckAppVersion

AppVersion AppVersion is a Swift utility that allows you to easily check for updates of your iOS application and prompt users to update to the latest version for an enhanced user experience.

Features

🔄 Seamlessly checks for updates by comparing the version on the App Store with the currently installed version.

⚡️ Simple integration with just a single line of code.

💪 Control the update behavior with the option to force users to update or provide the option to cancel.

🚀 Optimized and memory-efficient implementation.

🌟 Interactive and customizable alert presentation.

📲 Deep links users to the App Store for convenient updates.

How to Use To check for updates and prompt users to update, simply call the checkForUpdate method with the desired force update option.

Force Update: Displays an alert to users with no option to cancel. Users are forced to update.

AppVersion.checkForUpdate(forceUpdate: true)

Optional Update: Displays an alert to users with the option to cancel. Users can choose to update or dismiss the alert.

AppVersion.checkForUpdate(forceUpdate: false)

Make sure to call the update alert after setting the root view controller. This ensures that the alert is presented correctly without being dismissed when a new root view controller is set.

self.view.window?.rootViewController = rootvc
AppVersion.checkForUpdate(forceUpdate: true)

Customize the update alert presentation: ✏️ Modify the alert title, message, and button labels to suit your app's branding and messaging. ✨ Customize the alert's appearance using the provided UIAlertController methods.

private static func showUpdateAlert(forceUpdate: Bool, info: AppInfo) {
    let alertController = UIAlertController(title: "📣 Update Available", message: "🆕 A new version(\(info.version)) of the \(info.trackName) is available. Please update to the latest version.", preferredStyle: .alert)
    
    // Update action
    let updateAction = UIAlertAction(title: "📲 Update", style: .default) { (action) in
        // Open App Store for update
        if let url = URL(string: info.trackViewUrl) {
            UIApplication.shared.open(url, options: [:], completionHandler: nil)
        }
    }
    alertController.addAction(updateAction)
    
    // Cancel action (only for optional update)
    if !forceUpdate {
        let cancelAction = UIAlertAction(title: "⛔️ Cancel", style: .cancel, handler: nil)
        alertController.addAction(cancelAction)
    }

    // Present the alert on the topmost view controller
    if let topViewController = UIApplication.shared.windows.first(where: { $0.isKeyWindow })?.rootViewController?.topMostViewController() {
        topViewController.present(alertController, animated: true, completion: nil)
    }
}

Contributing 🤝 Contributions are welcome! If you have any ideas, suggestions, or bug fixes, please open an issue or submit a pull request.

License 📄 This project is licensed under the MIT License.

Credits AppVersion is developed and maintained by Swarajmeet Singh.

About

"AppVersion" is a Swift utility that checks for updates of your iOS application by comparing the version on the App Store with the currently installed version. It provides an easy way to prompt users to update to the latest version, ensuring they have the best experience with your app.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages