ForceUpdateKit
ForceUpdateKit |
---|
![]() |
SWIFT
ForceUpdateKit This repo is for checking the force update of app and handle the force update flow.
Features
- Force Update without implementing server and client
- Variety of style and configuration.
- Compatible with all platforms
Demos
- Demo1 - FullScreen1
- Demo2 - FullScreen2
- Demo3 - FullScreen3
- Demo4 - FullScreen4
- Demo5 - Popover1
- Demo6 - Popover2
Demo1 - FullScreen1
FullScreen1 |
---|
![]() |
e.g.
Task {
await ForceUpdateKit().configure()
}
Demo2 - FullScreen2
FullScreen2 |
---|
![]() |
e.g.
Task {
let config = UpdateServiceConfig()
config.viewConfig.style = .fullscreen2
await ForceUpdateKit().configure(config: config)
}
Demo3 - FullScreen3
FullScreen3 |
---|
![]() |
e.g.
Task {
let config = UpdateServiceConfig()
config.viewConfig.style = .fullscreen3
await ForceUpdateKit().configure(config: config)
}
Demo4 - FullScreen4
FullScreen4 |
---|
![]() |
e.g.
Task {
let config = UpdateServiceConfig()
config.viewConfig.style = .fullscreen4
await ForceUpdateKit().configure(config: config)
}
Demo5 - Popover1
Popover1 |
---|
![]() |
e.g.
Task {
let config = UpdateServiceConfig()
config.viewConfig.style = .popover1
config.viewConfig.contentViewBackColor = .black
config.viewConfig.popupViewBackColor = .black
config.viewConfig.headerTitleColor = .white
config.viewConfig.updateImageType = .gear
config.viewConfig.updateImageColor = .orange
config.viewConfig.updateButtonBackColor = .orange
config.viewConfig.versionTextColor = .orange
await ForceUpdateKit().configure(config: config)
}
e.g.
Task {
let config = UpdateServiceConfig()
config.viewConfig.style = .popover1
config.viewConfig.contentViewBackColor = .clear
config.viewConfig.popupViewBackColor = .black
config.viewConfig.headerTitleColor = .white
config.viewConfig.updateImageType = .gear
config.viewConfig.updateImageColor = .orange
config.viewConfig.updateButtonBackColor = .orange
config.viewConfig.versionTextColor = .orange
await ForceUpdateKit().configure(config: config)
}
Demo6 - Popover2
Popover2 |
---|
![]() |
e.g.
Task {
let config = UpdateServiceConfig()
config.viewConfig.style = .popover2
config.viewConfig.contentViewBackColor = .black
config.viewConfig.popupViewBackColor = .black
config.viewConfig.headerTitleColor = .white
config.viewConfig.updateImageType = .gear
config.viewConfig.updateImageColor = .orange
config.viewConfig.updateButtonBackColor = .orange
config.viewConfig.versionTextColor = .orange
await ForceUpdateKit().configure(config: config)
}
e.g.
Task {
let config = UpdateServiceConfig()
config.viewConfig.style = .popover2
config.viewConfig.contentViewBackColor = .clear
config.viewConfig.popupViewBackColor = .black
config.viewConfig.headerTitleColor = .white
config.viewConfig.updateImageType = .gear
config.viewConfig.updateImageColor = .orange
config.viewConfig.updateButtonBackColor = .orange
config.viewConfig.versionTextColor = .orange
await ForceUpdateKit().configure(config: config)
}
Service Configuration
this is the default value Service configuration class that you configure all items that you want custom:
public struct UpdateServiceConfig {
public var route: String = "https://my.api.mockaroo.com/forceupdate.json?key=2202ab40"
public var appId: String = Bundle.main.bundleIdentifier ?? String()
public var version: String = Bundle.main.releaseVersionNumber ?? String()
public var viewConfig: ForceUpdateViewConfig = ForceUpdateViewConfig()
}
that you can define or pass a new value for the route or use the default for using from our service.
e.g.
Task {
let config = UpdateServiceConfig()
config.route = "https://myapi.enpoint/forceupdate"
await ForceUpdateKit().configure(config: config)
}
View and Style Configuration
this is the default value for View configuration class that you configure all items that you want custom:
public class ForceUpdateViewConfig {
public var style: ForceUpdateViewStyle = .fullscreen1
public var updateButtonNortmalTitle: String = "Update New Version"
public var updateButtonSelectedTitle: String = "Update New Version"
public var updateButtonImage: UIImage = UIImage(named: "") ?? UIImage()
public var contentViewBackColor: UIColor = .white
public var popupViewBackColor: UIColor = .black
public var popupViewCornerRadius: CGFloat = 15.0
public var contentBackGroundImage: UIImage = UIImage(named: "",
in: Bundle.module,
compatibleWith: nil) ?? UIImage()
public var updateImageType: ImageType = .spaceship1
public var updateImage: UIImage?
public var updateImageColor: UIColor?
public var updateButtonFont = UIFont.systemFont(ofSize: 12, weight: .medium)
public var headerTitleFont = UIFont.systemFont(ofSize: 13, weight: .bold)
public var headerTitle = "It's time to update"
public var headerTitleColor: UIColor = .black
public var descriptionFont = UIFont.systemFont(ofSize: 12, weight: .medium)
public var descriptionText = "It's time to update The version you are using is old, need to update the latest version in order to experience new features."
public var descriptionTextColor: UIColor = .gray
public var versionFont = UIFont.systemFont(ofSize: 10, weight: .bold)
public var versionText = "Up to 12.349 version Apr 2024."
public var versionTextColor: UIColor = .gray
public var updateButtonBackColor: UIColor = .blue
public var lineColor: UIColor = .lightGray
public var updateButtonTitleColor: UIColor = .white
public var updateButtonCornerRadius: CGFloat = 20.0
public var updateButtonBorderWidth: CGFloat = 0.0
public var updateButtonBorderColor: UIColor = .clear
}
e.g.
Task {
let config = UpdateServiceConfig()
config.viewConfig.style = .popover2
config.viewConfig.contentViewBackColor = .clear
config.viewConfig.popupViewBackColor = .black
config.viewConfig.headerTitle = "my header title"
config.viewConfig.updateButtonCornerRadius = 30
config.viewConfig.updateButtonBorderWidth = 1
config.viewConfig.updateButtonBorderColor = .yellow
config.viewConfig.headerTitleColor = .white
config.viewConfig.updateImageType = .gear
config.viewConfig.updateImageColor = .orange
config.viewConfig.updateButtonBackColor = .orange
config.viewConfig.versionTextColor = .orange
await ForceUpdateKit().configure(config: config)
}
Installation
- Manually
- Cocoapods
- SPM (Swift Package Manager)
Manually
- Download the source code.
- Extract the zip file, simply drag folder Sources into your project.
- Make sure Copy items if needed is checked.
Cocoapods
use_frameworks!
target '<Your Target Name>' do
pod 'ForceUpdateKit'
end
Swift Package Manager
Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
To integrate ForceUpdateKit into your Xcode project using Swift Package Manager, add it to the dependencies value of your Package.swift
:
dependencies: [
.package(url: "https://github.com/maziar/ForceUpdateKit.git")
]
Tutorial
1. Getting started
- Getting started with code
in Appdelegate or SceneDelegate or wherever you need it you can call:
import ForceUpdateKit
Task {
await ForceUpdateKit().configure()
}