Skip to content

Instantly share code, notes, and snippets.

Created January 14, 2014 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8418498 to your computer and use it in GitHub Desktop.
Save anonymous/8418498 to your computer and use it in GitHub Desktop.
インストールされているTwitterクライアントに飛ばす【iOS】
#define UserID @"Kan_Kikuchi" //TwitterID
-(void)TwitterLinkPush{
//URLスキーム配列
NSArray *ClientKeyArray = [NSArray arrayWithObjects:
@"com.tapbots.Tweetbot3:",
@"tweetbot:",
@"echofon:"
@"Twitter:",
@"None",
nil];
//リンク先配列
NSArray *ClientLinkeArray = [NSArray arrayWithObjects:
[NSString stringWithFormat:@"com.tapbots.Tweetbot3://%@/user_profile/%@",UserID,UserID],
[NSString stringWithFormat:@"tweetbot://%@/user_profile/%@",UserID,UserID],
[NSString stringWithFormat:@"echofon:///user_timeline?%@",UserID],
[NSString stringWithFormat:@"Twitter:@%@",UserID],
[NSString stringWithFormat:@"http://twitter.com/%@",UserID],
nil];
for(int ClientNo = 0; ClientNo < [ClientKeyArray count]; ClientNo++){
//URLスキームを使ってアプリがインストールされているか調べる
NSString* Keystr = [ClientKeyArray objectAtIndex:ClientNo];
if ([Keystr isEqualToString:@"None"] || [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:Keystr]]) {
//インストールされていればそのアプリに飛ばす
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[ClientLinkeArray objectAtIndex:ClientNo]]];
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment