如何以吸引人的屏幕形式向用户提供应用程序更新?
How to make app update available to users in the form of an attractive screen?
我最近在使用 "Make My Trip" 应用程序。每当我启动应用程序时,我都会发现一个非常吸引人的应用程序更新弹出屏幕。它说要更新应用程序。我也想将其合并到我的应用程序更新中。请告诉我该怎么做。
我在这里附上截图供您考虑。
很简单,首先您必须创建设计以在您上传的每个版本中显示新的更新屏幕。
然后使 api 在更新屏幕中填写信息并将标志存储在本地设备中,因此每当用户打开您的应用程序时都会显示新的更新屏幕。
是的,每次用户打开您的应用程序时,您都需要调用新版本 api,或者您也可以使用 push notification
来传递。
您必须创建 API
1st) api 是 return 当前在应用商店上传的版本,2nd) api 是获取您想要的数据在您的可用更新屏幕
中显示
第 1 步:在您的应用程序中创建更新屏幕的屏幕设计。
第 2 步:在应用商店中创建 API
return 当前版本,在您的应用中调用此 api 并检查版本是否相同。
第 3 步:如果版本不同,则调用数据 API 并将它们存储在本地。
第 4 步:如果有新的更新数据可用且版本不同,则在用户打开您的应用程序时显示 可用的新更新屏幕。
第 5 步:用户更新应用程序后检查版本并删除以前加载的数据。
您可以从iTunes store lookup API获取所有应用信息:http://itunes.apple.com/lookup?bundleId=YOUR_BUNDLE_ID
,在此您可以获取App Store上的应用版本。
制作您想要向应用用户展示的设计屏幕,然后在应用商店和用户设备上比较您的应用版本,如果两个版本不相等则显示更新版本屏幕。
以下是在应用商店和设备上比较应用版本的完整实现:
func isUpdateAvailableOnStore() -> Bool {
let infoDictionary = Bundle.main.infoDictionary
let bundleId = infoDictionary!["CFBundleIdentifier"] as! String
let url = URL(string: "http://itunes.apple.com/lookup?bundleId=\(bundleId)")
let infoData = try? Data(contentsOf: url!)
let appInfo = (try? JSONSerialization.jsonObject(with: infoData! , options: [])) as? [String: Any]
if let resultCount = appInfo!["resultCount"] as? Int, resultCount == 1 {
if let results = appInfo!["results"] as? [[String:Any]] {
if let appStoreVersion = results[0]["version"] as? String{
let currentAppVersion = infoDictionary!["CFBundleShortVersionString"] as? String
if !(appStoreVersion == currentAppVersion) {
return true
}
}
}
}
return false
}
在你的func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
函数中调用这个函数AppDelegate
。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Your code here
if self.isUpdateAvailableOnStore(){
// SHOW YOUR UPDATE SCREEN TO USER'S
}else{
// APP VERSION IS UPDATED ON DEVICE
}
return true
}
我最近在使用 "Make My Trip" 应用程序。每当我启动应用程序时,我都会发现一个非常吸引人的应用程序更新弹出屏幕。它说要更新应用程序。我也想将其合并到我的应用程序更新中。请告诉我该怎么做。 我在这里附上截图供您考虑。
很简单,首先您必须创建设计以在您上传的每个版本中显示新的更新屏幕。
然后使 api 在更新屏幕中填写信息并将标志存储在本地设备中,因此每当用户打开您的应用程序时都会显示新的更新屏幕。
是的,每次用户打开您的应用程序时,您都需要调用新版本 api,或者您也可以使用 push notification
来传递。
您必须创建 API
1st) api 是 return 当前在应用商店上传的版本,2nd) api 是获取您想要的数据在您的可用更新屏幕
第 1 步:在您的应用程序中创建更新屏幕的屏幕设计。
第 2 步:在应用商店中创建 API
return 当前版本,在您的应用中调用此 api 并检查版本是否相同。
第 3 步:如果版本不同,则调用数据 API 并将它们存储在本地。
第 4 步:如果有新的更新数据可用且版本不同,则在用户打开您的应用程序时显示 可用的新更新屏幕。
第 5 步:用户更新应用程序后检查版本并删除以前加载的数据。
您可以从iTunes store lookup API获取所有应用信息:http://itunes.apple.com/lookup?bundleId=YOUR_BUNDLE_ID
,在此您可以获取App Store上的应用版本。
制作您想要向应用用户展示的设计屏幕,然后在应用商店和用户设备上比较您的应用版本,如果两个版本不相等则显示更新版本屏幕。
以下是在应用商店和设备上比较应用版本的完整实现:
func isUpdateAvailableOnStore() -> Bool {
let infoDictionary = Bundle.main.infoDictionary
let bundleId = infoDictionary!["CFBundleIdentifier"] as! String
let url = URL(string: "http://itunes.apple.com/lookup?bundleId=\(bundleId)")
let infoData = try? Data(contentsOf: url!)
let appInfo = (try? JSONSerialization.jsonObject(with: infoData! , options: [])) as? [String: Any]
if let resultCount = appInfo!["resultCount"] as? Int, resultCount == 1 {
if let results = appInfo!["results"] as? [[String:Any]] {
if let appStoreVersion = results[0]["version"] as? String{
let currentAppVersion = infoDictionary!["CFBundleShortVersionString"] as? String
if !(appStoreVersion == currentAppVersion) {
return true
}
}
}
}
return false
}
在你的func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
函数中调用这个函数AppDelegate
。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Your code here
if self.isUpdateAvailableOnStore(){
// SHOW YOUR UPDATE SCREEN TO USER'S
}else{
// APP VERSION IS UPDATED ON DEVICE
}
return true
}