¿Cómo verificar que una aplicación en particular ya esté instalada en el dispositivo iPhone o no?

How to check particular app is already installed on iphone device or not? How we can achieve this any idea?

preguntado el 31 de julio de 12 a las 10:07

Would you elaborate? Do you want to check from one app if another app is installed? -

4 Respuestas

canOpenURL is the essentially checks whether the app that is registered to that particular URL scheme is installed or in other words if the app exists, and if it is, we can open the URL.

- (BOOL) appExists: (NSURL*)url{
    if ([[UIApplication sharedApplication] canOpenURL:url]) {        
        return YES;

    } else {
        return NO;
    }
}


NSURL *urlApp = [NSURL URLWithString:@"fb://profile/73728918115"];// facebook app

NSURL *urlApp = [NSURL URLWithString: [NSString stringWithFormat:@"%@", @"twitter:///user?screen_name=INNOVA_ET_BELLA"]];//tweeter app

if ([self appExists:urlApp]) {
        [[UIApplication sharedApplication] openURL:urlApp];
} 

IPhone URL Schemes:

http://wiki.akosma.com/IPhone_URL_Schemes

Custom URL Schemes:

http://mobiledevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html

Respondido 31 Jul 12, 10:07

This only works if the app has a registered and known URL scheme set up. - Martin

what do you bother to register it? mobiledevelopertips.com/cocoa/… - Alexey

If the app has a registered URL you can check if exist in this way

[[UIApplication sharedApplication] canOpenURL:url]

URL es algo así como skype://

if not, you need to loop in all folders.
Here how to: Obtener una lista de archivos en un directorio con un glob

NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
NSFileManager *fm = [NSFileManager defaultManager];
NSArray *dirContents = [fm contentsOfDirectoryAtPath:bundleRoot error:nil];
NSPredicate *fltr = [NSPredicate predicateWithFormat:@"self ENDSWITH '.app'"];
NSArray *onlyAPPs = [dirContents filteredArrayUsingPredicate:fltr];

Applications are located in /var/application/APPNAME.app (if i remember well).

contestado el 23 de mayo de 17 a las 13:05

using below code you can retrieve the list of all applications.

 NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
 NSString *sandBoxPath = [bundleRoot stringByDeletingLastPathComponent];
 NSString *appFolderPath = [sandBoxPath stringByDeletingLastPathComponent];

 NSFileManager *fm = [NSFileManager defaultManager];
 NSArray *dirContents = [fm contentsOfDirectoryAtPath:appFolderPath error:nil];

 NSMutableArray *appNames = [[NSMutableArray alloc]init];
 for(NSString *application in dirContents)
 {
      NSString *appPath = [appFolderPath stringByAppendingPathComponent:application];
      NSArray *appcontents = [fm contentsOfDirectoryAtPath:appPath error:nil];
      NSPredicate *fltr = [NSPredicate predicateWithFormat:@"self ENDSWITH '.app'"];
      NSArray *onlyApps = [appcontents filteredArrayUsingPredicate:fltr];
      if(onlyApps.count > 0)
           [appNames addObject:[onlyApps objectAtIndex:0]];
 }

 NSLog(@"%@", [appNames description]);
 [appNames release];

Respondido 31 Jul 12, 11:07

Here's an example to test if the facebook app is installed.

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]) {
// Facebook app is installed
 }

Respondido el 24 de enero de 13 a las 04:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.