check and update an application through code when a new version is available in appstore

时光怂恿深爱的人放手 提交于 2019-12-22 14:08:53

问题


Within my application, I want to check if there is any updated version of my application is in the app store. If there is any, then have to inform the user through an alert message and if he/she opt for upgrade I want to update the new version.I want to do all this through my application. Is this possible?


回答1:


You can store the most current application version string on your server. When the app is activated, request this information from the server and compare it to the version string that is contained in your applications Info.plist.

You can get the version in Info.plist like this

[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]

If the string differs, you can show an alert that a newer version is available in the app store. You can also link directly to the app store from the alert.




回答2:


You could do something like this: let's say you just started making an app. You hardcode its version (1.0) inside the app's configuration file or something similar.

Then, you can use an universal xml configuration file, which is read by the app everytime it starts and connects to the internet. Inside that xml, make a field named "lastest_version", where you set that value.

When the app starts you can check the xml. If your hardcoded value is 1.0 and inside the xml you get 1.1, this means you need an update.

This is how we do it and, just like Philippe said, we also use an plist to store the original version value.



来源:https://stackoverflow.com/questions/10749842/check-and-update-an-application-through-code-when-a-new-version-is-available-in

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