Created
September 3, 2014 03:51
-
-
Save pilgwon/72e6fb85269421157198 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)openLink:(NSString *)link withDelay:(int64_t)delay animated:(BOOL)animated sticky:(BOOL)sticky { | |
// 일반 URL | |
if([link hasPrefix:@"http://"] || [link hasPrefix:@"https://"]) { | |
ACWebViewController *controller = [[ACWebViewController alloc] initWithUrl:link]; | |
[self showViewController:controller withDelay:delay modal:YES animated:animated]; | |
return YES; | |
} | |
NSArray *components = [link componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@":/"]]; | |
if (IS_BLANK_ARRAY(components)) | |
return NO; | |
NSString *identifier = [components objectAtIndex:0]; | |
if ([identifier isEqualToString:@"p"] || [identifier isEqualToString:@"places"]) { | |
Place *place = [[Place alloc] init]; | |
place._id = [components objectAtIndex:1]; | |
place.name= @""; | |
if (IS_BLANK_STRING(place._id)) return NO; | |
if([components count] == 3) { | |
NSString *action = [components objectAtIndex:2]; | |
if ([action isEqualToString:@"r"] || [action isEqualToString:@"reservation"]) { | |
[self showViewController:[[ReservationViewController alloc] initWithReservation:[Reservation reservationWithPlace:place]] withDelay:delay modal:YES animated:animated]; | |
return YES; | |
} | |
} | |
PlaceDetailViewController *controller = [[PlaceDetailViewController alloc] initWithPlace:place]; | |
controller.referer = @"push"; | |
[self showViewController:controller withDelay:delay modal:NO animated:animated]; | |
return YES; | |
} else if([identifier isEqualToString:@"o"] || [identifier isEqualToString:@"options"]) { | |
PlaceListViewController *controller = [PlaceListViewController viewControllerWithPushNotification:[components objectAtIndex:1] options:[components objectAtIndex:2]]; | |
if(!sticky) { | |
[self initSearchTab]; | |
[((UIViewController *)(searchRootViewController.viewControllers[0])).navigationController pushViewController:controller animated:NO]; | |
[self changeTab:MENU_SEARCH]; | |
} else { | |
[self showViewController:controller withDelay:delay modal:NO animated:animated]; | |
} | |
} else if([identifier isEqualToString:@"s"] || [identifier isEqualToString:@"searches"]) { | |
PlaceListViewController *controller = [PlaceListViewController viewControllerWithQuery:[components objectAtIndex:1] options:[components objectAtIndex:2]]; | |
if(!sticky) { | |
[self initSearchTab]; | |
[((UIViewController *)(searchRootViewController.viewControllers[0])).navigationController pushViewController:controller animated:NO]; | |
[self changeTab:MENU_SEARCH]; | |
} else { | |
[self showViewController:controller withDelay:delay modal:NO animated:animated]; | |
} | |
} else if([identifier isEqualToString:@"n"] || [identifier isEqualToString:@"notices"]) { | |
[self showViewController:[[NoticeViewController alloc] initWithNoticeId:[components objectAtIndex:1]] withDelay:delay modal:YES animated:animated]; | |
} else if([identifier isEqualToString:@"t"] || [identifier isEqualToString:@"themes"]) { | |
[self changeTab:MENU_THEME]; | |
} else if([identifier isEqualToString:@"m"] || [identifier isEqualToString:@"memos"]) { | |
if(!sticky) | |
[self changeTab:MENU_RESERVATION]; | |
} else if([identifier isEqualToString:@"l"] || [identifier isEqualToString:@"login"]) { | |
[self changeTab:MENU_SETTING]; | |
if(![[Session current] isLoggedIn]) { | |
/////sj log | |
NSLog(@"isNotLoggedIn : AppDelegate.m 486"); | |
[[settingRootViewController.viewControllers objectAtIndex:0] onLogin]; | |
} | |
} else if([identifier isEqualToString:@"contacts"]) { // 1.2에 추가됨 | |
[self changeTab:MENU_SETTING]; | |
NSString *params = [link substringFromIndex:9]; | |
NSDictionary *paramsDict = [NSDictionary gtm_dictionaryWithHttpArgumentsString:params]; | |
NSString *msg = [paramsDict objectForKey:@"msg"]; | |
if(!IS_BLANK_STRING(msg)) { | |
ContactsViewController *controller = [[ContactsViewController alloc] initWithMessage:msg title:@"친구 초대하기"]; | |
[self showViewController:controller withDelay:delay modal:YES animated:animated]; | |
} | |
} else if([identifier isEqualToString:@"u"] || [identifier isEqualToString:@"url"]) { // 1.3에 추가됨 | |
NSString *url = [(NSString *)[components objectAtIndex:1] gtm_stringByUnescapingFromURLArgument]; | |
ACWebViewController *controller = [[ACWebViewController alloc] initWithUrl:url]; | |
[self showViewController:controller withDelay:delay modal:YES animated:animated]; | |
} else if([identifier isEqualToString:@"ct"]) { // 1.6에 추가됨 | |
NSUInteger tab = (NSUInteger) [((NSString *) [components objectAtIndex:1]) integerValue]; | |
if(tab <= 4) { | |
DebugLog(@"changeTab: %d", tab); | |
[self changeTab:tab]; | |
} | |
} | |
else if([identifier isEqualToString:@"ep"]) { // event, 1.9.4에 추가됨, event -> place | |
Place *place = [[Place alloc] init]; | |
place._id = [components objectAtIndex:1]; | |
place.name= @""; | |
if (IS_BLANK_STRING(place._id)) return NO; | |
if([components count] == 3) { | |
NSString *action = [components objectAtIndex:2]; | |
if ([action isEqualToString:@"r"] || [action isEqualToString:@"reservation"]) { | |
[self showViewController:[[ReservationViewController alloc] initWithReservation:[Reservation reservationWithPlace:place]] withDelay:delay modal:YES animated:animated]; | |
return YES; | |
} | |
} | |
PlaceDetailViewController *controller = [[PlaceDetailViewController alloc] initWithPlace:place]; | |
controller.referer = @"push"; | |
[self showViewController:controller withDelay:delay modal:NO animated:animated]; | |
return YES; | |
} | |
else if([identifier isEqualToString:@"es"]) { // event, 1.9.4에 추가됨, event -> search | |
PlaceListViewController *controller = [PlaceListViewController viewControllerWithQuery:[components objectAtIndex:1] options:[components objectAtIndex:2]]; | |
[self showViewController:controller withDelay:delay modal:NO animated:animated]; | |
} | |
return NO; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment