Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting programmatically an installed app

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 ?

like image 245
iOS.Lover Avatar asked Jul 30 '26 22:07

iOS.Lover


2 Answers

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)

like image 200
borrrden Avatar answered Aug 01 '26 13:08

borrrden


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

like image 24
Alex Terente Avatar answered Aug 01 '26 13:08

Alex Terente



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!