The ability to check for updates in iOS opens app implementation

Source: Internet
Author: User


Check the update page

-(void) renew{

Nsdictionary *infodic = [[NSBundle mainbundle]infodictionary];

NSString *version = [infodic valueforkey:@ "cfbundleshortversionstring"];

NSString *ipstr = [NSObject deviceipadress];

NSString *PARAMIP = ipstr;

Nstimeinterval time = [[NSDate date]timeintervalsince1970];

Long i = time;

NSString *paramtime = [NSString stringwithformat:@ "%ld", I];

NSString *signstr = [NSString stringwithformat:@ "%@%@%@%@", paramtime,paramip,@ "Phone_ios", @ " d556bd3337cd909b49eb5e33f46ad65c "];

NSString *md5str = [Signstr Md5hash];

NSString *mdstr = [Md5str lowercasestring];

NSString *sign = mdstr;

NSString *key = @ "Phone_ios";

Nsdictionary *param = @{
@ "type": @2,

@ "Version": Version

};

Nsdictionary *dict = @{

@ "Paramtime": Paramtime,

@ "PARAMIP": PARAMIP,

@ ' sign ': sign,

@ "key": Key,

@ "param":p Aram

};

Afhttprequestoperationmanager *manager = [Afhttprequestoperationmanager manager];

Manager.requestserializer = [Afjsonrequestserializer serializer];

Manager.responseserializer = [Afjsonresponseserializer serializer];

Manager.responseSerializer.acceptableContentTypes = [Nsset setwithobject:@ "Application/json"];

[Manager Post:renewurl Parameters:dict success:^ (afhttprequestoperation *operation, id responseobject) {

Nsdictionary *resultdic = responseobject[@ "Result"];

_upgradeurl = resultdic[@ "Upgradeurl"];

_force = resultdic[@ "Isforce"];
NSLog (@ "_force--------%@", _force);

NSLog (@ "%@", resultdic);

if ([resultdic[@ "Isforce"]compare:@0]!=nsorderedsame) {

Uialertview *isforceview = [[Uialertview alloc]initwithtitle:@ "Special hints" message:@ "discover new version" Delegate:self CancelButtonTitle : @ "Cancel" otherbuttontitles:@ "Download", nil];


[Isforceview show];

}else if ([resultdic[@ "version"]compare:version]! = nsorderedsame) {

Uialertview *resultview = [[Uialertview alloc]initwithtitle:@ ' hint ' message:@ ' discover new version ' Delegate:self cancelButtonTitle:@ ' Cancel "otherbuttontitles:@" Download "nil";

[Resultview show];

}else{

return;
}

} failure:^ (Afhttprequestoperation *operation, Nserror *error) {

Uialertview *errorview = [[Uialertview alloc]initwithtitle:@ ' hint ' message:@ ' network problematic ' delegate:self cancelButtonTitle:@ ' Cancel "otherbuttontitles:@" OK ", nil";

[Errorview show];

NSLog (@ "%@", error);
}];
}

The ability to check for updates in iOS opens app implementation

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.