检查 iphone 是否安装某 app
来源:互联网 发布:mock.js 参考文档 编辑:程序博客网 时间:2024/06/05 20:19
转载自:http://blog.csdn.net/zengconggen/article/details/7714514
开发中遇到一个问题:公司多个产品时,希望在一个产品A中可以直接打开另外的某个产品B。如果用户尚未安装产品B, 则打开app store下载页面。
对于这个问题:有3个技术点:
1、产品B是否已安装的检测。
2、应用内打开其他app的技术:参考:https://developer.apple.com/library/IOs/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW18
3、从应用跳转至app下载页面的技术:参考:http://blog.csdn.net/zengconggen/article/details/6789420
对于第2、3点,本文略过不讲。现提供第1技术点方案:(说明:技术有风险,有可能导致app被拒。不过app store有类似上线作品。看RP)
解决方案1:(经验证:该方案真机ios5无效,模拟器可以)
- // Declaration
- BOOL APCheckIfAppInstalled(NSString *bundleIdentifier); // Bundle identifier (eg. com.apple.mobilesafari) used to track apps
- // Implementation
- BOOL APCheckIfAppInstalled(NSString *bundleIdentifier)
- {
- static NSString *const cacheFileName = @"com.apple.mobile.installation.plist";
- NSString *relativeCachePath = [[@"Library" stringByAppendingPathComponent: @"Caches"] stringByAppendingPathComponent: cacheFileName];
- NSDictionary *cacheDict = nil;
- NSString *path = nil;
- // Loop through all possible paths the cache could be in
- for (short i = 0; 1; i++)
- {
- switch (i) {
- case 0: // Jailbroken apps will find the cache here; their home directory is /var/mobile
- path = [NSHomeDirectory() stringByAppendingPathComponent: relativeCachePath];
- break;
- case 1: // App Store apps and Simulator will find the cache here; home (/var/mobile/) is 2 directories above sandbox folder
- path = [[NSHomeDirectory() stringByAppendingPathComponent: @"../.."] stringByAppendingPathComponent: relativeCachePath];
- break;
- case 2: // If the app is anywhere else, default to hardcoded /var/mobile/
- path = [@"/var/mobile" stringByAppendingPathComponent: relativeCachePath];
- break;
- default: // Cache not found (loop not broken)
- return NO;
- break; }
- BOOL isDir = NO;
- if ([[NSFileManager defaultManager] fileExistsAtPath: path isDirectory: &isDir] && !isDir) // Ensure that file exists
- cacheDict = [NSDictionary dictionaryWithContentsOfFile: path];
- if (cacheDict) // If cache is loaded, then break the loop. If the loop is not "broken," it will return NO later (default: case)
- break;
- }
- NSDictionary *system = [cacheDict objectForKey: @"System"]; // First check all system (jailbroken) apps
- if ([system objectForKey: bundleIdentifier]) return YES;
- NSDictionary *user = [cacheDict objectForKey: @"User"]; // Then all the user (App Store /var/mobile/Applications) apps
- if ([user objectForKey: bundleIdentifier]) return YES;
- // If nothing returned YES already, we'll return NO now
- return NO;
- }
解决方案2:参考:http://blog.csdn.net/zengconggen/article/details/7714466
本方案有限制:只能获取到用户最近运行过的app。对于已安装但是不在最近有运行的app。不适用。
解决方案3:
- BOOL isExsit = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"rumtel://com.rumtel.AudioManager"]];
- NSLog(@"App %@ installed", identifier);
- if (isExsit)
- {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"rumtel://com.rumtel.AudioManager?a=1&b=2#sect"]];
- }
- else
- {
- //打开app store下载页面
- }
方案3需要知道B的打开地址。可用。最终方案确定为3
附:目前公开的app相关资料:http://wiki.akosma.com/IPhone_URL_Schemes
- 检查iphone是否安装某app
- 检查 iphone 是否安装某 app
- 检查iphone是否安装某app
- 检查 iphone 是否安装某 app
- 检查app是否已经安装
- iOS 检查手机是否安装了某一APP
- 检查ios设备上是否安装了某些app
- 苹果iOS系统下检查第三方APP是否安装
- ADB检查APP已安装列,是否已安装,获取已安装APP的版本号,
- 检查应用是否安装
- 检查ndk是否安装
- iphone模拟器安装app
- 如何检查用户的ios设备上是否安装了某些app?
- 苹果iOS系统下检查第三方APP是否安装及跳转启动
- iOS系统下检查第三方APP是否安装及跳转启动
- iOS系统下检查第三方APP是否安装及跳转启动
- 苹果iOS系统下检查第三方APP是否安装及跳转启动
- html 5检查Mobile App是否在线
- hashmap hashtable 的区别
- 设计模式简单总结
- ScrollView内的控件改变之后自动滚动的问题
- Algs4-2.2.17链表归并排序
- Delphi中Chrome Chromium、Cef3学习笔记(一)
- 检查 iphone 是否安装某 app
- 下拉刷新XListView的简单分析
- 63.给一个整数取出偶数位组成一个新的数
- 重大事件网站整体灰度处理代码
- 自动布局之autoresizingMask使用详解(Storyboard&Code)
- java基础—网络编程———聊天窗口的建立
- 怎样解析GRE作文题目
- SAT语法常见难点之并列句
- 大数据工程人员知识图谱