Hi all am trying to open instagram app on a button click but am not able to i set Url scheme as instagram in plist also
NSString *instagramURL = @"instagram://app"; NSURL *ourURL = [NSURLURLWithString:instagramURL]; if ([[UIApplication sharedApplication]canOpenURL:ourURL]) { [[UIApplication sharedApplication]openURL:ourURL]; } else { //The App is not installed. It must be installed from iTunes code. NSString *iTunesLink = @"//Some other Url goes here"; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]]; UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"URL error" message:[NSString stringWithFormat: @"No custom URL defined for %@", ourURL] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show];
i did like this but app not opening am new to iOS any help can be appreciated
Asked
Active
Viewed 6,698 times
2

Nirav D
- 71,513
- 12
- 161
- 183
-
Please answer this question, I can not open the instagram. NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@",[[assetURL absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding],caption]]; – Arpit B Parekh Jul 10 '17 at 07:07
2 Answers
4
You can open instagram app by username like,
NSURL *instagramURL = [NSURL URLWithString:@"instagram://user?username=USERNAME"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
[[UIApplication sharedApplication] openURL:instagramURL];
}
You can refer iPhone Hooks of Instagram for more ways and details about api!!!
Update :
Replace below line,
NSString *instagramURL = @"instagram://app";
with
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
You are assigning directly string as url!!

Ketan Parmar
- 27,092
- 9
- 50
- 75
-
hello ketan but there is no login in required in my app normally app should open if user taps on instagram button in my app and still i dint fixed it how to open with out login and i did not write any thing in this method – Aug 06 '16 at 12:21
-
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options{ return YES; } – Aug 06 '16 at 12:21
-
yes i did tried and i think i did same thing but still dint worked for me and noramlly what are the steps to do this task how plist should be and what are the area to be cover to get this job done – Aug 08 '16 at 05:11
3
Add key Value In Info.plist File
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram</string>
<string>twitter</string>
</array>

SBK
- 101
- 5