本文介绍iOS SrpintBoard框架的部分私有API,具体包括:

  • 获取ios上当前正在运行的所有App的bundle id(不管当前程序是在前台还是后台都可以)
  • 获取ios上当前前台运行的App的bundle id(不管当前程序是在前台还是后台都可以)
  • 根据ios app的bundle id得到其App名称、图标(不管当前程序是在前台还是后台都可以)
  • 直接通过App 的bundle id来运行该App,无需使用url scheme(仅限当前程序在前台时,假如程序在后台能随便运行其他App,那就无敌了@_@)

(1)初始化

    void * uikit = dlopen("/System/Library/Framework/UIKit.framework/UIKit", RTLD_LAZY);
int (*SBSSpringBoardServerPort)() =
dlsym(uikit, "SBSSpringBoardServerPort");
p = (mach_port_t *)SBSSpringBoardServerPort();
dlclose(uikit);
sbserv = dlopen(SBSERVPATH, RTLD_LAZY);

(2)获取iphone上所有正在运行的app的bundle id列表

NSArray* (*SBSCopyApplicationDisplayIdentifiers)(mach_port_t* port, BOOL runningApps,BOOL debuggablet) =

                    dlsym(sbserv, "SBSCopyApplicationDisplayIdentifiers");

NSArray *currentRunningAppBundleIdArray= SBSCopyApplicationDisplayIdentifiers(p,NO,YES);

(3)得到iphone 前台运行的app的bundle id

void* (*SBFrontmostApplicationDisplayIdentifier)(mach_port_t* port,char * result) = dlsym(sbserv, "SBFrontmostApplicationDisplayIdentifier");
char topapp[256];
SBFrontmostApplicationDisplayIdentifier(p,topapp);
currentTopAppBundleId=[NSStringstringWithFormat:@"%s",topapp];

(4)根据iphone app的bundle id得到其app名称

 NSString * (*SBSCopyLocalizedApplicationNameForDisplayIdentifier)(NSString* ) =   dlsym(sbserv, "SBSCopyLocalizedApplicationNameForDisplayIdentifier");

NSString *strAppName = SBSCopyLocalizedApplicationNameForDisplayIdentifier(strBundleId);

(5)根据iphone app 的bundle id得到其图标

 NSData* (*SBSCopyIconImagePNGDataForDisplayIdentifier)(NSString * bundleid) =
dlsym(sbserv, "SBSCopyIconImagePNGDataForDisplayIdentifier");
UIImage *icon = nil;
NSData *iconData = SBSCopyIconImagePNGDataForDisplayIdentifier(bundleid);
if (iconData != nil) {
icon = [UIImage imageWithData:iconData];
}
return icon;

(6)直接通过app 的bundle id来运行该app

在ios中,一个app调起另一个app的方式通常是用url scheme,但是用这个 私有app,可以在不需要url scheme的情况下运行任何app

-(void)openAppByBundleId:(NSString*)bundleId
{
void* sbServices = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_LAZY);
int (*SBSLaunchApplicationWithIdentifier)(CFStringRef identifier, Boolean suspended) = dlsym(sbServices, "SBSLaunchApplicationWithIdentifier");
const char *strBundleId = [bundleId cStringUsingEncoding:NSUTF8StringEncoding];
int result = SBSLaunchApplicationWithIdentifier((__bridge CFStringRef)bundleId, NO);
dlclose(sbServices);
}

iphone SprintBoard部分私有API总结(不支持iOS8)的更多相关文章

  1. 使用私有api实现自己的iphone桌面,并根据app的使用次数对app排序

    使用<iphone SprintBoard部分私有API总结>中提到的api,除了能对app运行次数进行监控以外,还可以实现自己的iphone桌面,并根据app 的使用次数对app图标进行 ...

  2. 使用私有api统计ios app运行时间及次数

    利用<iphone SprintBoard部分私有API总结>中提到的私有API,可以做很多越狱以前实现不了的事情. 比如,利用一个后台运行的app,监控该iphone上所有app的运行次 ...

  3. iPhone私有API

    一.基本知识 iPhone中的API除了公开的API:Published API外(或者叫文档中记录的API:Documented API),还有两类API:私有API:Private API和未公开 ...

  4. 坑爹的私有API

    iOS私有API扫描工作总结 背景 苹果提供的iOS开发框架分PrivateFramework和Framework,PrivateFramework下的库是绝对不允许在提交的iOS应用中使用的,只允许 ...

  5. ios中通过调试来使用私有api

    转自:http://blog.csdn.net/cubepeng/article/details/11284173 OS不允许使用ios私有api,使用私有api可以获得意想不到的效果 ,同时使用私有 ...

  6. class-dump获取iOS私有api

    转自:http://blog.csdn.net/sunyuanyang625/article/details/41440167 获取各类iOS私有api 安装工具class-dump 资源地址http ...

  7. 怎么获取iOS的私有API

    前言 作为iOS开发人员,相信大多数伙伴都对怎么获取iOS的私有API很有兴趣,最近通过查找资料,总结了以下三种方法,希望对你有用. 第一种(class-dump) 不得不说这是一个很棒的工具,安装和 ...

  8. Apple 如何知道你使用了私有API

    大约有三种方式 otool -L这个工具可以清晰的列出你链接所有的库 像IO.Kit是不允许使用的 nm -u 这个工具可以清晰的列出你所有链接符号如 C方法 OC方法 检查所有Selecter的字符 ...

  9. (iOS)私有API的使用(原创)

    最近在做企业级程序,需要搞设备的udid等信息,但是ios7把udid私有化了,不公开使用.所以研究了一下ios的私有api. 调查了一下文章,发现这方面的文章不多,国内更是不全,高手们都懒得写基础教 ...

随机推荐

  1. Smarty 获取当前日期时间和格式化日期时间

    在Smarty 中获取当前日期时间和格式化日期时间与PHP中有些不同的地方,这里就为您详细介绍: 首先是获取当前的日期时间:在PHP中我们会使用date函数来获取当前的时间,实例代码如下:date(& ...

  2. 常见的RSA套路脚本

    工具 rsatool https://github.com/ius/rsatool factordb(分解大素数) http://www.factordb.com python-PyCrypto库 O ...

  3. Linux下如何安装Nginx

    看这就够了 https://segmentfault.com/a/1190000012435644 注意如果是远程浏览器访问是否启动了nginx,出现无法访问 服务器能够启动.访问不了页面 很大可能是 ...

  4. TextView的封装和自定义

    实现的效果如下: #import <UIKit/UIKit.h> @interface CustomTextView : UITextView @property (nonatomic , ...

  5. linux操作备份

    ---------------------------------------------------------------------------------------------------- ...

  6. Vue学习笔记(三)组件间如何通信传递参数

    一:父组件向子组件传递参数 <template > <div id="app"> <h1 v-text="title">&l ...

  7. 深入理解Attention机制

    要了解深度学习中的注意力模型,就不得不先谈Encoder-Decoder框架,因为目前大多数注意力模型附着在Encoder-Decoder框架下,当然,其实注意力模型可以看作一种通用的思想,本身并不依 ...

  8. 工作采坑札记: 4. linux指定目录使用df和du的统计结果相差很大

    1. 背景 近日,线上的服务出现异常,调用服务返回的JSON格式数据不完整,导致客户端解析异常,因此记录了本次的填坑之旅(nnd)... 2. 排查过程 2.1 服务器分析 登录到服务所在linux服 ...

  9. Linux系统查看CPU使用率命令

    在linux的系统维护中,可能需要经常查看cpu使用率,分析系统整体的运行情况.而监控CPU的性能一般包括以下3点:运行队列.CPU使用率和上下文切换. 1.top 这个命令很常用,在第三行有显示CP ...

  10. spring效验

    相关依赖 如果开发普通 Java 程序的的话,你需要可能需要像下面这样依赖: <dependency> <groupId>org.hibernate.validator< ...