Github:https://github.com/hellovoidworld/hvwweibo
A.app Startup Steps1. After the authorization step is added, the first thing to determine whether the app has logged into the account 2. When the program starts, first check if there is a login account appdelegate:
1-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {2 //Override point for customization after application launch.3 4 //Show status bar after startup5UIApplication *app =[UIApplication sharedapplication];6App.statusbarhidden =NO;7 8 //Set Window9Self.window =[[UIWindow alloc] init];TenSelf.window.frame =[UIScreen mainscreen].bounds; One [Self.window makekeyandvisible]; A - //Check if you have a login account -NSString *docpath =[Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES) lastobject]; theNSString *filepath = [DocPath stringbyappendingpathcomponent:@"accountinfo.plist"]; -Nsdictionary *accountinfo =[Nsdictionary Dictionarywithcontentsoffile:filepath]; - - if(!accountinfo) {//If there is no login account, authorization is needed first. +Self.window.rootViewController =[[Hvwoauthviewcontroller alloc] init]; -}Else { + /** New version features*/ A //the current version of the app at //due to the use of the core foundation stuff, bridging is required -NSString *versionkey = (__bridge nsstring*) Kcfbundleversionkey; -Nsdictionary *infodic =[[NSBundle Mainbundle] infodictionary]; -NSString *currentversion =[Infodic Objectforkey:versionkey]; - - //last-used version inNsuserdefaults *defaults =[Nsuserdefaults standarduserdefaults]; -NSString *lastversion =[Defaults stringforkey:versionkey]; to + //If the version changes, store the new version number and start the new version of the feature map - if(![lastversion isequaltostring:currentversion]) { the * //Storage $ [Defaults setobject:currentversion forkey:versionkey];Panax Notoginseng [Defaults synchronize]; - the //Open app display new features +Hvwnewfeatureviewcontroller *NEWFEATUREVC =[[Hvwnewfeatureviewcontroller alloc] init]; ASelf.window.rootViewController =NEWFEATUREVC; the}Else { + //creating the root controller -Hvwtabbarviewcontroller *TABVC =[[Hvwtabbarviewcontroller alloc] init]; $Self.window.rootViewController =TABVC; $ } - } - the returnYES; -}In the authorization controller, after the authorization has been completed to continue to enter the app:
1 //HVWOAUTHVIEWCONTROLLER.M2 /** Get Access_token according to Access_code*/3- (void) Accesstokenwithaccesscode: (NSString *) Accesscode {4 //Create HTTP Operation request Manager for AFN5Afhttprequestoperationmanager *manager =[Afhttprequestoperationmanager manager];6 7 //parameter Settings8Nsmutabledictionary *param =[Nsmutabledictionary dictionary];9param[@"client_id"] =@"3942775926";Tenparam[@"Client_secret"] =@"Cc577953b2aa3aa8ea220fd15775ea35"; Oneparam[@"Grant_type"] =@"Authorization_code"; Aparam[@"Code"] =Accesscode; -param[@"Redirect_uri"] =@"http://www.cnblogs.com/hellovoidworld/"; - the //Send Request -[Manager POST:@"Https://api.weibo.com/oauth2/access_token"Parameters:param success:^ (afhttprequestoperation *operation, Nsdictionary *AccountInfo) { - [Mbprogresshud Hidehud]; - + //returns a dictionary of user information - //Store user information, including Access_token to sandbox +NSString *docpath =[Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES) lastobject]; ANSString *filepath = [DocPath stringbyappendingpathcomponent:@"accountinfo.plist"]; at [AccountInfo Writetofile:filepath atomically:yes]; - - /** New version features*/ - //the current version of the app - //due to the use of the core foundation stuff, bridging is required -NSString *versionkey = (__bridge nsstring*) Kcfbundleversionkey; inNsdictionary *infodic =[[NSBundle Mainbundle] infodictionary]; -NSString *currentversion =[Infodic Objectforkey:versionkey]; to + //last-used version -Nsuserdefaults *defaults =[Nsuserdefaults standarduserdefaults]; theNSString *lastversion =[Defaults stringforkey:versionkey]; * $UIWindow *window =[uiapplication Sharedapplication].keywindow;Panax Notoginseng - //If the version changes, store the new version number and start the new version of the feature map the if(![lastversion isequaltostring:currentversion]) { + //Storage A [Defaults setobject:currentversion forkey:versionkey]; the [Defaults synchronize]; + - //Open app display new features $Hvwnewfeatureviewcontroller *NEWFEATUREVC =[[Hvwnewfeatureviewcontroller alloc] init]; $Window.rootviewcontroller =NEWFEATUREVC; -}Else { - //creating the root controller theHvwtabbarviewcontroller *TABVC =[[Hvwtabbarviewcontroller alloc] init]; -Window.rootviewcontroller =TABVC;Wuyi } the -} failure:^ (Afhttprequestoperation *operation, Nserror *error) { Wu [Mbprogresshud Hidehud]; -Hvwlog (@"request Access_token Failure---->%@", error); About }]; $ -}
First boot: Requires authorization + new feature display
[iOS Weibo project-2.4]-reschedule app launch steps