IOS app Frame Check Update avoid audit rejected __ios

Source: Internet
Author: User

I. Preface

1. The first time to write a blog, you can say that the summary of online resources, the similarities are more magnanimous.

2. The official review of app shelves in March 15 does not allow you to be prompted to update the words for upgrades. But the rule is dead, and the man is alive. There are still free to drill.

Two. Two ways to prompt for version updates

There are basically two kinds of tips for updating:

1. In the settings have "check the update", check the version, do not focus on the introduction (PS: Android screenshot, iOS temporarily do not want to, but also can let the background control, the review period to hide the background, the audit passed after the show. However, when the upgrade version of the time is not very good control. Comprehensive consideration: or not this ... The App Store has an out-of-the-box prompt to update it. )


2. Launch the app when the window is the form of the balloon update (focus on)


Three. Implementation method logic mechanism and the original code

1. The realization of the idea: A. Take the version number of the App Store version number C. The comparison of the version number D. Frame display E. Jump App Store Update

2. Code implementation

A. Take your version number, Xcode version (this is 1.0.3)

Get the app itself version number
    nsstring *localversion = [[[NSBundle mainbundle]infodictionary]objectforkey:@] Cfbundleshortversionstring "];

B. Access to the App Store version number

1. First get the AppID of the app (the Red Arrow refers to it.) PS: Graffiti sense)


The defined app address nsstring *url = [NSString stringwithformat:@ "http://itunes.apple.com/lookup?id=%@", AppID]; AppID is the AppID//ps as shown in the Red Arrows: Sometimes the data may not be requested, but AppID is right, it is possible that the app is the area of the shelves, it is recommended to use the end of COM with "/CN"///Example: nsstring *url = [


NSString stringwithformat:@ "http://itunes.apple.com/cn/lookup?id=%@", AppID];
    Network Request app Information (we take version is enough) Nsurl *url = [Nsurl Urlwithstring:url];
                                                           Nsmutableurlrequest *request = [Nsmutableurlrequest requestwithurl:url Cachepolicy:nsurlrequestreloadignoringcachedata Timeoutinte
    
    RVAL:10];
    
    [Request sethttpmethod:@ "POST"];
    Nsurlsession *session = [Nsurlsession sharedsession]; Nsurlsessiondatatask *task = [Session datataskwithrequest:request completionhandler:^ (NSData * _Nullable data, Nsurlresponse * _nullable response, Nserror * _nullable error) {nsmutabledictionary *receivestatusdic=[[nsmutable
        Dictionary Alloc]init]; if (datA) {//data is having all the information about the app nsdictionary *receivedic = [Nsjsonserialization jsonobjectwit
            Hdata:data options:nsjsonreadingmutableleaves Error:nil]; if ([[[Receivedic valueforkey:@ "Resultcount"] intvalue]>0) {[Receivestatusdic SetValue
                : @ "1" forkey:@ "status"]; [Receivestatusdic setvalue:[[[receivedic valueforkey:@ "results"] objectatindex:0] valueforkey:@ "version"] forKey:@ "
                
                Version "]; Requested data, version comparison [self performselectoronmainthread: @selector (receivedata:) withobject:receivestatusdic wait
            Untildone:no];
            }else{[Receivestatusdic setvalue:@ "-1" forkey:@ "status"];
        }}else{[Receivestatusdic setvalue:@ "-1" forkey:@ "status"];
    
    }
        
    }];
    
 [Task resume];

C

1. Window comparison

-(void) Receivedata: (ID) Sender {//Get App version number NSString *localversion = [[NSBundle mainbundle]infodictionary]object
    
    forkey:@ "Cfbundleshortversionstring"];
    Nsarray *localarray = [Localversion componentsseparatedbystring:@ "."];
    
    
    Nsarray *versionarray = [sender[@ "version"] componentsseparatedbystring:@ "."]; if ((Versionarray.count = 3) && (Localarray.count = = Versionarray.count)) {if ([localarray[0] I
        Ntvalue] < [versionarray[0] intvalue]) {[Self updateversion]; }else if ([localarray[0] intvalue] = = [Versionarray[0] intvalue]) {if ([localarray[1] intvalue] < [versi
            ONARRAY[1] Intvalue]) {[Self updateversion]; }else if ([localarray[1] intvalue] = = [versionarray[1] intvalue]) {if ([localarray[2] intvalue] < [ve
                RSIONARRAY[2] Intvalue]) {[Self updateversion]; }
            }
        }
    }
}


D,e Upgrade tips and jumps

-(void) updateversion{
    nsstring *msg = [NSString stringwithformat:@] new version, quickly update it! "];
    
    Uialertcontroller *alertcontroller = [Uialertcontroller alertcontrollerwithtitle:@ "upgrade hint" message:msg PreferredStyle: Uialertcontrollerstylealert];
    
    Create the actions.
    Uialertaction *cancelaction = [Uialertaction actionwithtitle:@ "Next time" Style:uialertactionstylecancel Handler:nil];
    Uialertaction *otheraction = [uialertaction actionwithtitle:@ "Upgrade Now" Style:uialertactionstyledestructive handler:^ ( uialertaction*action) {
        Nsurl *url = [Nsurl urlwithstring:[nsstring Stringwithformat:kbuyerappupdateurl]];
        [[[UIApplication Sharedapplication]openurl:url];
    }];
    
    Add the actions.
    [Alertcontroller addaction:cancelaction];
    [Alertcontroller addaction:otheraction];
    
    [Self.window.rootViewController Presentviewcontroller:alertcontroller Animated:yes completion:nil];

}



Four. Conclusion

At this point, about the window tip upgrade is over. PS: Here Compare version number is not the same as prompted to update the upgrade. Instead, the current version number prompts the frame to upgrade if it is smaller than the App Store edition. The best thing about this is that Apple won't be prompted to upgrade when it comes to auditing apps. Of course, if your version number is smaller than the App Store setup (impossible), then you ...



Related Article

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.