如何检查特定的应用程序是否已安装在iPhone设备上? 我们如何才能实现这个想法?如何检查特定应用程序是否已安装在iphone设备上?
0
A
回答
1
canOpenURL
本质上是检查是否安装了注册到该特定URL方案的应用程序,换句话说,如果该应用程序存在,如果是,我们可以打开该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方案:
http://wiki.akosma.com/IPhone_URL_Schemes
自定义URL方案:使用下面的代码
http://mobiledevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
0
可以检索所有应用程序的列表。
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];
0
如果是否存在这样的应用程序有一个注册的URL,您可以检查
[[UIApplication sharedApplication] canOpenURL:url]
URL是一样的东西skype://
如果没有,您需要的所有文件夹循环。
这里如何:Getting a list of files in a directory with a 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];
应用位于/var/application/APPNAME.app
(如果我记得很清楚)。
0
下面是测试facebook应用程序是否已安装的示例。
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://"]]) {
// Facebook app is installed
}
相关问题
- 1. 如何在iPhone设备上检查已安装的应用程序
- 2. 检查应用程序是否安装在配对设备中
- 3. 如何检查设备上是否安装了任何应用程序?
- 4. 如何在设备上找到特定的已安装应用程序?
- 5. 检查设备上是否安装了特定证书
- 6. 如何检查应用程序是否已安装?
- 7. 如何检查之前是否安装了iPhone应用程序?
- 8. 如何检查应用程序是否已安装或正在首次安装
- 9. 是否可以检查设备上是否安装了特定的应用程序?
- 10. 如何在iPhone设备上安装rhomobile应用程序
- 11. Xamarin:检查是否安装在iOS设备上任何特定的应用程序
- 12. 检查应用程序是否安装在诺基亚设备上?
- 13. 如何检查在iPhone设备安装的应用程序在IOS SDK 4.0
- 14. 如何确定Dropbox是否已安装在iOS设备上?
- 15. 如何检测,如果Android应用程序已经安装在设备上?
- 16. 如何查找应用程序是否安装在网络中的设备上?
- 17. 钛:检查设备上安装的应用程序(安卓)
- 18. 如何检测用户已安装应用程序的独特设备
- 19. 在iPhone设备中打开已安装的应用程序
- 20. 如何检测iPhone应用程序是否在iPhone 4设备上运行?
- 21. 检查用户是否已安装我的Facebook应用程序
- 22. 如何检查是否使用Ant安装了特定的Django应用程序?
- 23. 如何确定在Android设备上安装的应用程序?
- 24. 我如何知道应用程序是否已经安装在iPhone上从Safari
- 25. 检查应用程序是否已更新或新安装
- 26. iphone - 检查是否安装了应用程序
- 27. Ajax调用以检查设备上是否存在本机iPhone应用程序?
- 28. flipkart等应用程序如何检查设备中安装的应用程序
- 29. 如何检查已安装的应用程序是我的?
- 30. 在真实设备上调试已安装的应用程序
你会详细说明吗?如果安装了另一个应用程序,您想从一个应用程序中检查吗? – netigger 2012-07-31 09:15:07