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.
Once you've done that you can then call:
[[UIApplication sharedApplication] openUrl:[NSURL urlWithString:@"xingipad://"]];
Comments
-
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 withcom.test.app1
andcom.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 over 12 yearsAre 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 over 12 yearsI don't think an Apple approved way exists.
-
Kapil Choubisa almost 12 yearsI 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 almost 7 yearsThank you very much! Works on iOS 11, and don't need to know URL scheme.
-
ekscrypto over 6 yearsExcept you should never use private APIs.
-
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 over 6 yearsbeing 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 almost 6 yearsI get the error
Implicitly declaring library function 'objc_getClass' with type 'id (const char *)'
on the first line -
ekscrypto almost 6 yearsThe question already included deep linking, asker was trying to find a way around that
-
Alok almost 6 yearsAll steps of deep linking are given in the above answer.
-
MEnnabah over 4 years@LuísCunha
#import <objc/runtime.h>
on the top of the file -
Zeeshan Ahmed almost 3 yearsthis worked for me, will my app gonna pass Apple review with this?
-
Zeeshan Ahmed almost 3 yearsI am using this just to open different apps using their bundle id's
-
zumzum about 2 yearsthis works. Just tested today. running latest version of Xcode and on device I have running iOS 15.3.1 (19D52)