Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mycompuser

macrumors member
Original poster
May 8, 2012
37
0
Hi All,

I am investigating for a feature for my iOS app (iOS 6 and above) where I will be given a list of conflicting apps (these apps might not work as expected along side my app).

I have to check if an app (from the list) are already installed, if so need to prompt an warning msg to my user about the possible conflict.

Did some googling to try to find a solution to get list of installed apps on my iPhone/iPad but no success.

The nearest I could get was the solution which did not work for me is made available at this page. Tried running the code but the cacheDict is always empty.

I think they are using private api's which I would like to avoid as there is a change for apple to reject my app for app store.

Can you guys please guide me with a solution to the issue?

Thanks in advance.
 
Hi All,

Have discovered that one method to find whether an app is installed or not on a device is using custom URL Scheme.

Here is a link to the detailed explanation on the same.

But as configuring an URL Scheme is not mandatory for an app, relying on URL Scheme along for determining if an app is installed or not i feel might not be reliable.

Is there any other way by which we can figure out if an app is installed or not?
 
Custom URL Schemes is the only non-private way I know to detected installed apps.

Hi dejo,

Thanks for the reply.

If that is the case, I am thinking of using custom URL Schemes along with process name of an app to determine if the application is installed on the device or not.

So I would first search for Custom URL Scheme. If no conflicting apps are found, then I would look for the process name (of the conflicting app) from the list of running process on the device. (for this approach, I'll need process name and custom URL scheme (if any) of all the conflicting apps).

Of course, with this approach I will not be able to detect an conflicting app which has not configured Custom URL Scheme and which is not running (in the background) at the movement.

Are there any caveat that I have overlooked with this approach?

Can somebody suggest me a better approach if any?

Advance thanks.
 
Hi dejo,

Thanks for the reply.

If that is the case, I am thinking of using custom URL Schemes along with process name of an app to determine if the application is installed on the device or not.

So I would first search for Custom URL Scheme. If no conflicting apps are found, then I would look for the process name (of the conflicting app) from the list of running process on the device. (for this approach, I'll need process name and custom URL scheme (if any) of all the conflicting apps).

Of course, with this approach I will not be able to detect an conflicting app which has not configured Custom URL Scheme and which is not running (in the background) at the movement.

Are there any caveat that I have overlooked with this approach?

Can somebody suggest me a better approach if any?

Advance thanks.

Are you developing for the app store or cydia?
 
Hi dejo,

Thanks for the reply.

If that is the case, I am thinking of using custom URL Schemes along with process name of an app to determine if the application is installed on the device or not.

So I would first search for Custom URL Scheme. If no conflicting apps are found, then I would look for the process name (of the conflicting app) from the list of running process on the device. (for this approach, I'll need process name and custom URL scheme (if any) of all the conflicting apps).

Of course, with this approach I will not be able to detect an conflicting app which has not configured Custom URL Scheme and which is not running (in the background) at the movement.

Are there any caveat that I have overlooked with this approach?

Can somebody suggest me a better approach if any?

Advance thanks.
I don't think you can get the running processes via public APIs, can you? What you're trying to do would require a jailbroken phone I think.
 
Hi All,

The product is for App store.

I thought sysctl was not a private api. Is it not?

I actually extracted the below method code to return list of running process from an iOS project from github.

Am I doing something wrong (am I using private api)?

Code:
- (NSArray *) _sysctl_ps {
    
    int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0};
    size_t miblen = 4;
    size_t size;
    int st = sysctl(mib, miblen, NULL, &size, NULL, 0);
    struct kinfo_proc * process = NULL;
    struct kinfo_proc * newprocess = NULL;
    
    do {
        size += size / 10;
        newprocess = realloc(process, size);
        if (!newprocess){
            if (process){
                free(process);
            }
            return nil;
        }
        process = newprocess;
        st = sysctl(mib, miblen, process, &size, NULL, 0);
    } while (st == -1 && errno == ENOMEM);
    
    if (st == 0){
        if (size % sizeof(struct kinfo_proc) == 0){
            int nprocess = size / sizeof(struct kinfo_proc);
            if (nprocess){
                NSMutableArray * array = [[NSMutableArray alloc] init];
                for (int i = nprocess - 1; i >= 0; i--){
                    NSString * processID = [[NSString alloc] initWithFormat:@"%d", process[i].kp_proc.p_pid];
                    NSString * processName = [[NSString alloc] initWithFormat:@"%s", process[i].kp_proc.p_comm];
                    NSDictionary * dict = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects:processID, processName, nil] forKeys:[NSArray arrayWithObjects:@"ProcessID", @"ProcessName", nil]];
                    [array addObject:dict];
                }
                free(process);
                return array; 
            }
        }
    }
    
    return nil;
}
 
This will definitely get you rejected

XCode even will probably reject it before you can submit it to app store
 
This is an XY problem and I don't know why everyone is focused on Y.

Your X is that you think your app could conflict with other apps. Pray tell, how could your app, which is sandboxed, could possibly conflict with other apps, which are also sandboxed? The fact that your app can't even figure out if the other app is installed or not strongly suggests you wouldn't be able to even have a conflict between the two apps.
 
Hi ArtOfWarfare,

My app register with an apple framework (private framework exposed to us by Apple). But my competitor (conflicting app) can also register for events from that framework as he too has access to the private framework by apple.

So on some user action, the framework fires a notification/event, which is handled both by my app and my competitor's app. As we both use the same framework, there is a possibility of conflict.

This case we are trying to handle by showing some msg informing user of possible conflict.
 
Hi ArtOfWarfare,

My app register with an apple framework (private framework exposed to us by Apple).

Err... what? This sounds like you probably just violated an NDA if you're using a private framework Apple is giving you special permission to see.

But my competitor (conflicting app) can also register for events from that framework as he too has access to the private framework by apple.

So on some user action, the framework fires a notification/event, which is handled both by my app and my competitor's app. As we both use the same framework, there is a possibility of conflict.

This case we are trying to handle by showing some msg informing user of possible conflict.

I don't see the conflict. You're replying to a notification and so is the competing app - there's no conflict from both of you receiving a notification. The only way I can see them causing a conflict is if they're both trying to manipulate a shared resources in different ways, but you didn't describe a scenario like that, yet.
 
I don't see the conflict. You're replying to a notification and so is the competing app - there's no conflict from both of you receiving a notification. The only way I can see them causing a conflict is if they're both trying to manipulate a shared resources in different ways, but you didn't describe a scenario like that, yet.

I think that is the scenario that they are trying to handle (As that module was developed by another member of my team I am not aware of the details).

If call to sysctl to get background process is an private api, then how come there are so many apps in the app store which do just that (list running process and other info)? Search for "activity monitor" in iTunes. I assume that they too must be using sysctl to get process list?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.