Skip to content

This repo is for checking the force update of app and handle the force update flow. (force update kit)

License

Notifications You must be signed in to change notification settings

maziar/ForceUpdateKit

Repository files navigation

ForceUpdateKit

ForceUpdateKit

Languages
Platform Version SPM compatible

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

Installation

  • Manually
  • Cocoapods
  • SPM (Swift Package Manager)

Manually

  1. Download the source code.
  2. Extract the zip file, simply drag folder Sources into your project.
  3. Make sure Copy items if needed is checked.

Cocoapods

use_frameworks!
target '<Your Target Name>' do
    pod 'ForceUpdateKit'
end

https://cocoapods.org/pods/ForceUpdateKit

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()
 }

Demos

Demo1 - FullScreen1

FullScreen1

e.g.

Task {
    await ForceUpdateKit().configure()
 }

Demo2 - FullScreen2

FullScreen2

e.g.

Task {
    let config = UpdateServiceConfig(style: .fullscreen2)
    await ForceUpdateKit().configure(config: config)
 }

Demo3 - FullScreen3

FullScreen3

e.g.

Task {
    let config = UpdateServiceConfig(style: .fullscreen3)
    await ForceUpdateKit().configure(config: config)
 }

Demo4 - FullScreen4

FullScreen4

e.g.

Task {
    let config = UpdateServiceConfig(style: .fullscreen4)
    await ForceUpdateKit().configure(config: config)
 }

Demo5 - Popover1

Popover1

e.g.

Task {
    let config = UpdateServiceConfig(style: .popover1)
    await ForceUpdateKit().configure(config: config)
 }

e.g.

Task {
    let config = UpdateServiceConfig(style: .popover1)
    config.viewConfig.contentViewBackColor = .clear
    await ForceUpdateKit().configure(config: config)
 }

Demo6 - Popover2

Popover2

e.g.

Task {
    let config = UpdateServiceConfig(style: .popover2)
    await ForceUpdateKit().configure(config: config)
 }

e.g.

Task {
    let config = UpdateServiceConfig(style: .popover2)
    config.viewConfig.contentViewBackColor = .clear
    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.

Configuration Custom Server and Endpoint

Task {
    let config = UpdateServiceConfig()
    config.route = "https://myapi.enpoint/forceupdate"
    await ForceUpdateKit().configure(config: config)
 }

If you change the API endpoint for calling your server you should make the response that is expected from the Kit:

{
  "version": "Up to 12.349 version Apr 2024.",
  "forceUpdate": true,
  "title": "It's time to update",
  "description": "It's time to update The version you are using is old, need to update to the latest version in order to experience new features.",
  "iconUrl": "http://dummyimage.com/231x100.png/5fa2dd/ffffff.png",
  "linkUrl": "https://apps.apple.com/us/app/telegram/id747648890",
  "buttonTitle": "Update New Version"
}

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)
 }

About

This repo is for checking the force update of app and handle the force update flow. (force update kit)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published