天天看點

iOS app版本更新CheckVersion_Swift

iOS app版本更新CheckVersion_Swift

前言

CheckVersion_Swift

 是一款輕量級的 

Swift

 版本的架構,架構功能:根據 

Apple

 提供的 

API

 去請求 

JSON

 ,根據 

JSON

 中的版本号決定是否去更新原生 

App

。更新提示的内容可以自定義,也可以是 

JSON

 中給的内容。

寫作 

CheckVersion_Swift

 架構初衷

通常在做 

App

 版本檢查更新功能的時候,都是背景伺服器為我們提供一個擷取 

App

 最新版本資訊的接口,并且在每次新版本更新後,都需要人工在背景更改版本資訊,這樣做其實也可以的,但是費事且不及時。

其實蘋果提供了一個很友好的 

iTunes

 接口,供我們擷取 

App Store

 中 

App

 目前的最新資訊。

Example

To run the example project, clone the repo, and run 

pod install

 from the Example directory first.

Installation

CheckVersion_Swift is available through 

CocoaPods

. To install

it, simply add the following line to your Podfile:

pod 'CheckVersion_Swift'

Use 

/// check version

///

/// - Parameters:

/// - appId: app id,eg: 414478124 of the wechat

/// - customContent: custom content,if the string is nil and the count of the string is greater 

/// than zero,use custom content;Otherwise,use the content of the request data

public class func checkVersion(_ appId: String, _ customContent: String?)

// 直接顯示接口中的更新内容

CheckVersion.checkVersion(kAppId, nil)

// 顯示自定義的更新内容

CheckVersion.checkVersion(kAppId, "自定義的更新内容...")

License

CheckVersion_Swift is available under the MIT license. See the LICENSE file for more info.

原文位址

https://www.cnblogs.com/MrXie821385843/p/10476199.html