How to make app update available to users in the form of an attractive screen? [closed]

独自空忆成欢 提交于 2019-12-04 07:16:00

问题


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.


回答1:


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.

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.

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
    }

Call this function in you func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool function of 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
}



回答2:


simple, first you have to create design to show new updates screen is available in each build you upload. then make api that fill info in updates screen and store flag in device locally, so whenever user open your app new update screen showed. Yes for this you need to call new version api every time when user open your app or you can use push notification to pass as well.

You have to create to API 1st) api is return currently uploaded version on app store and 2nd) api is to get data that you want to show in your new updates available screen

step 1 : create screen design of update screen in your application.

step 2 : create API that return current version in app store, call this api in your app and check version is same or not.

step 3 : if version is not same than call Data API and store them in locally.

step 4 : if new updates data is available and version not same than show your new updates available screen when user open your app.

step 5 : after user updates app then check version and remove previous loaded data.



来源:https://stackoverflow.com/questions/48717836/how-to-make-app-update-available-to-users-in-the-form-of-an-attractive-screen

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!