/**
* Detecting the parameters to be used for version upgrade
* * Ifeverappid = @ "1076057848"; AppId; Invoke method to detect version update [selfcheckversion];
*
* Detect whether the software needs to be upgraded
*/
-(void) checkversion
{
Get the current application version number
Nsdictionary *appinfo = [[Nsbundlemainbundle] infodictionary];
NSString *currentversion = [appinfoobjectforkey:@ "Cfbundleversion"];
Use __block to change the value of a variable in a local scope
__block nsstring *newversion = @ "";
NSString *updateurlstring = [nsstringstringwithformat:@ "Http://itunes.apple.com/lookup?id=%ld", (long) [ Ifeverappidintegervalue]];
NSString * str = [updateurlstringstringbyaddingpercentescapesusingencoding:nsutf8stringencoding];
Afhttprequestoperationmanager *manager = [Afhttprequestoperationmanagermanager];
[Manager get:str Parameters:nil success:^ (afhttprequestoperation*operation, id responseobject) {
NSLog (@ "123 +%@", operation);
Nsdictionary *resultdic = Responseobject;
Nsarray *resultarray = [resultdicobjectforkey:@ "Results"];
For (Idconfig in resultarray) {
newversion = [Config valueforkey:@ "version"];
}
if (newversion) {
NSLog (@ "obtained through the App Store version number is:%@", newversion);
}
result = = 1
Nscomparisonresult result = [NewVersion compare:currentversion];
if (result = = 1) {//appstore version is greater than the current version
NSString *versionmessagestr = [NSString stringWithFormat: @ "Current version%@, the latest version is%@, please upgrade.", Currentversion,newversion];
Uialertview *alert = [[Uialertview alloc] Initwithtitle: @ "upgrade prompt!" Message:versionmessagestr delegate:self CancelB Uttontitle: @ "Next time" Otherbuttontitles: @ "Upgrade Now", Nil];
Alert. tag = Kversionneedupdatealerttag;
[Alert show];
}
} Failure: ^ ( Afhttprequestoperation *operation, Nserror *error) {
NSLog (@ "234 +%@", error);
}];
}
#pragma mark-uialertdelegate method
When the program is running in front of the push, give an alert, the user chooses to view, executes this method, and jumps to the specified page
-(void) Alertview: ( Uialertview *) Alertview Clickedbuttonatindex: ( Nsinteger) Buttonindex
{
if (Buttonindex = = 1) {
Software needs to update reminders
if (alertview. Tag = = Kversionneedupdatealerttag) {
Nsurl *url = [Nsurl urlwithstring: [NSString stringWithFormat: @] Https://itunes.apple.com/cn/app/wan-zhuan-quan-cheng /id%@?mt=8 ", Ifeverappid]]; [[Uiapplicationsharedapplication]openurl:url]; }
} }