Reputation: 5232
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..?
Upvotes: 14
Views: 16156
Reputation: 1006
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
Upvotes: 13
Reputation: 25978
Answer: You can't open app directly only with Bundle identifier.
Solution: You can implement deep linking (and take your bundle id as your deep linking id)concept to do this: Deep-linking
Upvotes: 2
Reputation: 710
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"];
Upvotes: 16
Reputation: 11161
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://"]];
Upvotes: 2