Open application with bundle identifier

11,286

Solution 1

I don't think that's possible.

Solution 2

You can use private API to do that

Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
NSObject * workspace = [LSApplicationWorkspace_class performSelector:@selector(defaultWorkspace)];
BOOL isopen = [workspace performSelector:@selector(openApplicationWithBundleID:) withObject:@"com.apple.mobilesafari"];

Solution 3

The Swift version of @EvanJIANG answer.

guard let obj = objc_getClass("LSApplicationWorkspace") as? NSObject else { return false }
let workspace = obj.perform(Selector(("defaultWorkspace")))?.takeUnretainedValue() as? NSObject
let open = workspace?.perform(Selector(("openApplicationWithBundleID:")), with: "com.apple.mobilesafari") != nil
return open

Solution 4

You can use the openUrl call, but in order to succeed you must add some values to your project's xy-Info.plist file.

enter image description here

Once you've done that you can then call:

[[UIApplication sharedApplication] openUrl:[NSURL urlWithString:@"xingipad://"]];

Share:
11,286
Kapil Choubisa
Author by

Kapil Choubisa

Love coding :) #SOreadytohelp

Updated on June 06, 2022

Comments

  • Kapil Choubisa
    Kapil Choubisa almost 2 years

    Is it possible to open a application from our application with bundle identifier. Suppose I have two apps installed on device one with com.test.app1 and com.test.app2. Can I open app1 from my app2.

    I know about openUrl method. for that I have to register url scheme in info.plist. and then i can use following method:

    [[UIApplication sharedApplication] openUrl:[NSURL urlWithString:@"myApp1://"]];
    

    But what if I didn't register url scheme or don't know the registered url.

    Any idea..?

  • Kapil Choubisa
    Kapil Choubisa over 12 years
    Are you sure that this is not possible..? Because we can check if application is installed in device or not with bundle identifier. so I was wondering that there may be some method for open it.
  • Akshay
    Akshay over 12 years
    I don't think an Apple approved way exists.
  • Kapil Choubisa
    Kapil Choubisa almost 12 years
    I know that this is possible with URL Scheme but I want to know that is this possible using bundle identifier?? If I don't have url scheme register than is this possible to open an app.
  • DmitryKanunnikoff
    DmitryKanunnikoff almost 7 years
    Thank you very much! Works on iOS 11, and don't need to know URL scheme.
  • ekscrypto
    ekscrypto over 6 years
    Except you should never use private APIs.
  • Evan JIANG
    Evan JIANG over 6 years
    @ekscrypto But I think it's the only way to match the requirements. And by the way, we successfully uploaded app with this code to AppStore.
  • ekscrypto
    ekscrypto over 6 years
    being able to snoop a private api usage by the app review team should not be seen as an authorization to use a private api.
  • Luís Cunha
    Luís Cunha almost 6 years
    I get the error Implicitly declaring library function 'objc_getClass' with type 'id (const char *)' on the first line
  • ekscrypto
    ekscrypto almost 6 years
    The question already included deep linking, asker was trying to find a way around that
  • Alok
    Alok almost 6 years
    All steps of deep linking are given in the above answer.
  • MEnnabah
    MEnnabah over 4 years
    @LuísCunha #import <objc/runtime.h> on the top of the file
  • Zeeshan Ahmed
    Zeeshan Ahmed almost 3 years
    this worked for me, will my app gonna pass Apple review with this?
  • Zeeshan Ahmed
    Zeeshan Ahmed almost 3 years
    I am using this just to open different apps using their bundle id's
  • zumzum
    zumzum about 2 years
    this works. Just tested today. running latest version of Xcode and on device I have running iOS 15.3.1 (19D52)