How iOS knows the app version has been updated

Source: Internet
Author: User

It is mainly used for program upgrade, whether to show the new features two aspects after opening the program.

1. Apple app version

Apple rules that the version of the program can only rise and fall. For example 1.0->1.1 can, 1.1->1.0 can not, do not allow shelves.

2.app Version Storage location

The version information is stored in the Info.plist file and can be seen in the general section of the project. When the app is updated, the version information here is automatically modified, so getting the version information in Info.plist is the latest version. If you want to artificially modify them at any point in both places.

3. Code implementation (Swift)

  The last version is saved in the sandbox and then compared to the latest. The implementation is as follows:

1 ///returns True if the program has just been updated2     PrivateFunc isupdated ()Bool {3         4         //get the current version of the program from Info.plist5Let Currentversionstr = Nsbundle.mainbundle (). infodictionary! ["cfbundleshortversionstring"] as!String6Let CurrentVersion = Nsnumberformatter (). numberfromstring (CURRENTVERSIONSTR)!. Doublevalue7         8         //get the version in the sandbox9Let Versionkey ="Sandboxkey"TenLet Userdefaults =nsuserdefaults.standarduserdefaults () OneLet sandboxversion =Userdefaults.doubleforkey (Versionkey) A          -         //record the current version into a sandbox - userdefaults.setdouble (CurrentVersion, Forkey:versionkey) the userdefaults.synchronize () -          -         //returns true only if it is greater than -         returnCurrentVersion >sandboxversion +}

How iOS knows the app version has been updated

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.