장치에 설치된 (다른, 어쩌면 제 3 자) 응용 프로그램 목록을 가져와야하는 응용 프로그램이 있습니다. 어떻게 할 수 있습니까? 아니면 전혀 끝낼 수 있습니까?iphone objective-c에 설치된 응용 프로그램 목록을 받으십시오.
답변
내가 뭔가를 사용할 수 있는지 의심 스럽지만 (일부 아이폰이 jailbreaked이고 사용자가 파일 시스템에 액세스 할 수있는 경우 가능합니다. 그러나이 사실을 알지 못합니다.) link 다음과 같이 사용하면 도움이됩니다. 모든 앱이 무엇인지 확인할 수 있으며 사용자의 필요에 맞게 맞춤 설정할 수 있습니다.
iOS 장비에서 같은 목록 (아이팟 터치/아이폰/아이 패드)를 가져 오기 위해 사과에서 공용 API가 없다
-(NSArray *) installedApps
{
BOOL isDir enter code here= NO;
NSDictionary *cacheDienter code herect;
NSDictionary *user;
static NSString *const cacheFileName = @"com.apple.mobile.installation.plist";
NSString *relativeCachePath = [[@"Library" stringByAppendingPathComponent: @"Caches"] stringByAppendingPathComponent: cacheFileName];
NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent: @"../.."] stringByAppendingPathComponent: relativeCachePath];
if ([[NSFileManager defaultManager] fileExistsAtPath: path isDirectory: &isDir] && !isDir) // Ensure that file exists
{
cacheDict = [NSDictionary dictionaryWithContentsOfFile: path];
user = [cacheDict objectForKey: @"System"]; // Then all the user (App Store /var/mobile/Applications) apps
}
//NSLog(@"Installed Applications = %@",[user allKeys]);
//return [user allKeys];
return nil;
}
이 개인 API를 사용하면 설치된 응용 프로그램의 이름의 배열을 줄 것이다
장치에서 IOS 6에서 작동하지 않습니다. 파일이 존재하지 않습니다. –
사과 전용 프레임 워크 "MobileInstallationInstall"을 통해 모든 앱을 검색 할 수 있습니다.
방법은 아래와 같다 :
NSDictionary *options = [NSDictionary dictionaryWithKeyAndValues:@"ApplicationType",@"Any",nil]
NSDictionary *apps = MobileInstallationLookup(options);
에만 JB 장치에 사용될 수있다.
사실. 그것은 또한 투옥 된 장치에 사용될 수 있습니다. 그러나이 코드는 개인용 API이므로 AppStore에 앱을 가져올 수 없습니다. –
MobileInstallationInstall의 헤더를 가져 오는 방법은 무엇입니까? – EwyynTomato
@EwyynTomato : 예 : 헤더는 https://github.com/Cykey/ios-reversed-headers/blob/master/MobileInstallation/MobileInstallation.h에서 찾을 수 있습니다. –
이 WONT는 설치된 응용 프로그램 목록을 제공하지만이 코드로 백그라운드에서 실행중인 응용 프로그램 목록과 관련 프로세스를 얻을 수 있습니다. 있는 viewDidLoad에서
전화 -
[self printProcessInfo];
.
-(NSMutableString*) printProcessInfo {
int mib[5];
struct kinfo_proc *procs = NULL, *newprocs;
int i, st, nprocs;
size_t miblen, size;
/* Set up sysctl MIB */
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_ALL;
mib[3] = 0;
miblen = 4;
/* Get initial sizing */
st = sysctl(mib, miblen, NULL, &size, NULL, 0);
/* Repeat until we get them all ... */
do {
/* Room to grow */
size += size/10;
newprocs = realloc(procs, size);
if (!newprocs) {
if (procs) {
free(procs);
}
perror("Error: realloc failed.");
return (0);
}
procs = newprocs;
st = sysctl(mib, miblen, procs, &size, NULL, 0);
} while (st == -1 && errno == ENOMEM);
if (st != 0) {
perror("Error: sysctl(KERN_PROC) failed.");
return (0);
}
/* Do we match the kernel? */
assert(size % sizeof(struct kinfo_proc) == 0);
nprocs = size/sizeof(struct kinfo_proc);
if (!nprocs) {
perror("Error: printProcessInfo.");
return(0);
}
printf(" PID\tName\n");
printf("-----\t--------------\n");
self.lists = [[NSMutableString alloc] init];
NSMutableString *localStr = [[NSMutableString alloc] init];
for (i = nprocs-1; i >=0; i--) {
// printf("%5d\t%s\n",(int)procs[i].kp_proc.p_pid, procs[i].kp_proc.p_comm);
localStr = [NSString stringWithFormat:@"%@,\nPID:-%5d,\tPROCESS_NAME:-%s\n",localStr,(int)procs[i].kp_proc.p_pid, procs[i].kp_proc.p_comm ];
NSString *pathStr = [self print_argv_of_pid:(int)procs[i].kp_proc.p_pid];
//NSString *pathStr = print_argv_of_pid:(((int)procs[i].kp_proc.p_pid));
localStr = [NSString stringWithFormat:@"%@,\n%@\n",localStr,pathStr ];
// [self getAttributesOfProcess];
//printf("%s",path);
}
NSLog(@"%@",lists);
free(procs);
return localStr;
//return (0);
}
-(NSString*) print_argv_of_pid:(int) pid {
char path[1000];
printf("%d\n", pid);
int mib[3], argmax, nargs, c = 0;
size_t size;
char *procargs, *sp, *np, *cp;
extern int eflg;
int show_args = 1;
mib[0] = CTL_KERN;
mib[1] = KERN_ARGMAX;
size = sizeof(argmax);
if (sysctl(mib, 2, &argmax, &size, NULL, 0) == -1) {
return @"";
//goto ERROR_A;
}
/* Allocate space for the arguments. */
procargs = (char *)malloc(argmax);
if (procargs == NULL) {
return @"";
//goto ERROR_A;
}
/*
* Make a sysctl() call to get the raw argument space of the process.
* The layout is documented in start.s, which is part of the Csu
* project. In summary, it looks like:
*
* /---------------\ 0x00000000
* : :
* : :
* |---------------|
* | argc |
* |---------------|
* | arg[0] |
* |---------------|
* : :
* : :
* |---------------|
* | arg[argc - 1] |
* |---------------|
* | 0 |
* |---------------|
* | env[0] |
* |---------------|
* : :
* : :
* |---------------|
* | env[n] |
* |---------------|
* | 0 |
* |---------------| <-- Beginning of data returned by sysctl() is here.
* | argc |
* |---------------|
* | exec_path |
* |:::::::::::::::|
* | |
* | String area. |
* | |
* |---------------| <-- Top of stack.
* : :
* : :
* \---------------/ 0xffffffff
*/
mib[0] = CTL_KERN;
mib[1] = KERN_PROCARGS2;
mib[2] = pid;
size = (size_t)argmax;
if (sysctl(mib, 3, procargs, &size, NULL, 0) == -1) {
//goto ERROR_B;
return @"";
}
memcpy(&nargs, procargs, sizeof(nargs));
cp = procargs + sizeof(nargs);
/* Skip the saved exec_path. */
for (; cp < &procargs[size]; cp++) {
if (*cp == '\0') {
/* End of exec_path reached. */
break;
}
}
if (cp == &procargs[size]) {
//goto ERROR_B;
return @"";
}
/* Skip trailing '\0' characters. */
for (; cp < &procargs[size]; cp++) {
if (*cp != '\0') {
/* Beginning of first argument reached. */
break;
}
}
if (cp == &procargs[size]) {
//goto ERROR_B;
return @"";
}
/* Save where the argv[0] string starts. */
sp = cp;
/*
* Iterate through the '\0'-terminated strings and convert '\0' to ' '
* until a string is found that has a '=' character in it (or there are
* no more strings in procargs). There is no way to deterministically
* know where the command arguments end and the environment strings
* start, which is why the '=' character is searched for as a heuristic.
*/
for (np = NULL; c < nargs && cp < &procargs[size]; cp++) {
if (*cp == '\0') {
c++;
if (np != NULL) {
/* Convert previous '\0'. */
*np = ' ';
} else {
/* *argv0len = cp - sp; */
}
/* Note location of current '\0'. */
np = cp;
if (!show_args) {
/*
* Don't convert '\0' characters to ' '.
* However, we needed to know that the
* command name was terminated, which we
* now know.
*/
break;
}
}
}
/*
* sp points to the beginning of the arguments/environment string, and
* np should point to the '\0' terminator for the string.
*/
if (np == NULL || np == sp) {
/* Empty or unterminated string. */
// goto ERROR_B;
return @"";
}
/* Make a copy of the string. */
// printf("%s\n", sp);
//path = sp;
memset(path,0,1000);
strcpy(path, sp);
NSString *pathStr = [NSString stringWithFormat:@"%s",path];
NSLog(@"%@",pathStr);
// printf("%s\n", path);
/* Clean up. */
free(procargs);
return pathStr;
ERROR_B:
free(procargs);
ERROR_A:
printf("(%d)", pid);
}
그래서 magicd의 답변과 헤더 파일에 대한 Victor의 의견은이 문제를 해결하는 데 도움이되었습니다.
Xcode의 "링크 된 프레임 워크 및 라이브러리"에 MobileInstallation.framework를 추가해야한다는 것을 추가하고 싶습니다.
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/System/Library/PrivateFrameworks
내가 확인 할 수 있습니다 : 여기 그 프레임 워크를 발견 이것은 비 jailbroken 장치에서 작동합니다. 앱 스토어는 저에게 관심사가 아닙니다. 여기
내가 사용되는 코드입니다 :NSDictionary *options = [NSDictionary dictionaryWithObject:@"Any" forKey:@"ApplicationType"];
NSDictionary *apps = (__bridge NSDictionary *) MobileInstallationLookup((__bridge CFDictionaryRef) options);
- 1. iPhone SDK : 설치된 응용 프로그램 목록?
- 2. Mac에 설치된 응용 프로그램 목록을 얻는 방법
- 3. iPhone에 설치된 응용 프로그램 쿼리
- 4. iPhone에 설치된 응용 프로그램 목록 (iPhone 자체 또는 iTunes를 통해)
- 5. android : 설치된 응용 프로그램 목록
- 6. iPhone 플랫폼에서 응용 프로그램 목록을 얻으려면 어떻게해야합니까?
- 7. 안드로이드에서 gps를 사용하는 설치된 응용 프로그램 목록을 얻는 방법은 무엇입니까?
- 8. Objective c를 사용하여 iPad에 설치된 응용 프로그램 목록을 얻는 방법
- 9. iPhone 장치에 설치된 앱 목록을 얻으려면 어떻게해야합니까?
- 10. 시작할 수있는 설치된 응용 프로그램의 목록을 가져옵니다.
- 11. "숨기기"설치된 안드로이드 응용 프로그램
- 12. WP7에 설치된 응용 프로그램 나열
- 13. @Autowired없이 응용 프로그램 구성 요소를 받으십시오.
- 14. iphone 응용 프로그램 디자인
- 15. 설치된 응용 프로그램 캐시 폴더 경로를 얻으려면
- 16. 설치된 응용 프로그램 목록 가져 오기
- 17. iPhone : iPhone 응용 프로그램 테스트
- 18. Webkit 브라우저에서 설치된 응용 프로그램 URI 처리기 감지
- 19. 응용 프로그램 내에서 iPhone 응용 프로그램 닫기
- 20. 버튼 응용 프로그램 - iPhone 응용 프로그램
- 21. 응용 프로그램 iPhone 응용 프로그램 재설정
- 22. iPhone Simulator는 설치된 응용 프로그램을 어디에서 저장합니까?
- 23. iPhone 장치에 설치된 응용 프로그램을 확인하는 방법
- 24. iphone 응용 프로그램 (HTML 포함)
- 25. 응용 프로그램 아이콘이있는 설치된 프로그램 목록 가져 오기
- 26. 흔들어 응용 프로그램, iPhone
- 27. iPhone 시작시 응용 프로그램
- 28. iPhone 응용 프로그램 Autologin
- 29. HTML5의 iPhone 응용 프로그램
- 30. 다중보기가있는 iphone 응용 프로그램
이, 스레드 - 다음 중복 하나를 참조하십시오됩니다 http://stackoverflow.com/questions/4614114/get-list-of-installed-apps- on-iphone – rishi
이 트릭을 수행 할 타사 라이브러리가 있습니까? – Oleg
@rishi에게 감사드립니다. 나는 그것을 놓쳤다. 귀하의 의견에 제 질문에 답하십시오. – Oleg