6

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..?

Wladimir Palant
  • 55,537
  • 12
  • 95
  • 123
Kapil Choubisa
  • 5,052
  • 9
  • 61
  • 99

6 Answers6

12

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"];
Evan JIANG
  • 660
  • 6
  • 5
5

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
Dmytro Shvetsov
  • 816
  • 9
  • 13
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://"]];

leviathan
  • 10,870
  • 5
  • 40
  • 39
3

I don't think that's possible.

Tim Cooper
  • 151,519
  • 37
  • 317
  • 271
Akshay
  • 5,699
  • 3
  • 22
  • 35
  • 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. – Kapil Choubisa Aug 29 '11 at 13:17
  • I don't think an Apple approved way exists. – Akshay Aug 29 '11 at 14:33
0

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

Alok
  • 23,024
  • 5
  • 38
  • 65
-1

It is possible using URL Schemes .

krishnendra
  • 563
  • 6
  • 7
  • 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. – Kapil Choubisa Aug 07 '12 at 06:58