2

I am trying to detect installed Instagram on my device , formerly I used this code to detect an app , but it seems it does not work with iOS 6 or non-JB devices :

NSString *filePath = @"/Applications/Instagram.app";
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath])
{

    [self checkingInstalledApp];
}

else

{

NSLog(@"no instagram installed");

}

I check this question but his answer gives me a lot errors ! any solution ?

Community
  • 1
  • 1
iOS.Lover
  • 5,923
  • 21
  • 90
  • 162

2 Answers2

5

This is invalid code for two reasons.

1) It attempts to interact with an area outside of its sandbox.

2) It relies on an undocumented implementation detail (Perhaps the install location has moved or the application name has changed?)

What you need to do is use the canOpenURL: method on UIApplication to determine if the system can launch an application via its custom scheme (note: If the App has no custom scheme then you are out of luck)

borrrden
  • 33,256
  • 8
  • 74
  • 109
5

Custom URL Scheme Opening instagram://, followed by one of the following parameters, will open our app and perform a custom action. For example, for camera, you would direct users on the iPhone to the custom URL instagram://camera.

NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"];
    if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
        [[UIApplication sharedApplication] openURL:instagramURL];
    }

From Instagram iPhone Hooks

Alex Terente
  • 12,006
  • 5
  • 51
  • 71