如何以迷人的屏幕形式向用户提供应用更新? [英] How to make app update available to users in the form of an attractive screen?

查看:138
本文介绍了如何以迷人的屏幕形式向用户提供应用更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用Make My Trip应用。每当我启动应用程序时,我都会发现一个非常有吸引力的应用更新弹出屏幕。它说要更新应用程序。我想在我的应用更新中加入它。请告诉我怎么做。
我附上一张截图供您考虑。

I was recently using "Make My Trip" app. I found a very attractive app update pop up screen appearing whenever I launch the app. It says to update the app. I want to incorporate that in my app update too. Please tell me how can I do it. I am attaching a screenshot here for your consideration.

推荐答案

您可以从 iTunes商店查找API http://itunes.apple.com/lookup?bundleId=YOUR_BUNDLE_ID ,在此您可以在App Store上获得App版本。

You can get all App info from iTunes store lookup API: http://itunes.apple.com/lookup?bundleId=YOUR_BUNDLE_ID, in this you can get App version on App Store.

制作您的设计屏幕,以便向App用户展示,然后在App Store和App上比较您的App版本。用户的设备,如果两个版本不相等,则显示更新版本屏幕。

Make your design screen as you want to show your App users, Then compare your App version on App store & user's device, if both version not equal then show the update version screen.

以下是在App Store和App上比较应用版本的完整实现。设备:

Below is the complete implementation to compare app version on App store & device:

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

这篇关于如何以迷人的屏幕形式向用户提供应用更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆