Created
January 14, 2014 13:45
-
-
Save anonymous/8418498 to your computer and use it in GitHub Desktop.
インストールされているTwitterクライアントに飛ばす【iOS】
This file contains 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
#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