Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special API to launch an app from my application

I had asked a question here but the answer guide me to open a new topic. Shortly, i want to launch a free app on Appstore from my application but the app i want to launch has no URL Scheme. The comments on my other question say using some special APIs like SBSLaunchApplicationWithIdentifier or classes like UIDocumentInteractionController make it possible. Can anyone please help me how to launch an application from my appication. Thanks in advance

like image 354
ilhnctn Avatar asked Apr 18 '12 07:04

ilhnctn


People also ask

How do I run one application from another application?

To take the user from one activity to another, your app must use an Intent to define your app's "intent" to do something. When you pass an Intent to the system with a method such as startActivity() , the system uses the Intent to identify and start the appropriate app component.

Do you need an API to build an app?

If you want an app for your business, the likelihood is you'll need to develop an API at some point. The key is knowing what you want from it, understanding its role in the process and making sure your developer has the information they need to develop a creative, effective and efficient app around it.


Video Answer


1 Answers

Let me first say that this method is jailbreak only! It uses private API's that Apple can stop supporting at any time in a future version!

Let's get to it, this method uses the [UIApplication launchApplicationWithIdentifier:suspended:] private method:

[[UIApplication sharedApplication] launchApplicationWithIdentifier:@"com.apple.Preferences" suspended:NO];

From what I've tested calling this method from an application not running as root is useless, apparently SpringBoard (or LaunchServices) only allow root applications to launch other applications using this method.

So, first you need to jailbreak your iPhone, then you need to get your application running as root.

To get your app running as root you need to place it in /Applications/YourApp.app instead of the usual /User/Applications/UUID/YourApp.app.

You can install OpenSSH using Cydia and use SSH to access your phone's shell.

Then, after having your app in the right place you need to set permissions, for example:

enter image description here

I would use the same ones as Cydia:

chown -R root:wheel /Applications/YourApp.app

Next, a little trick. The binary will need the setuid bit:

chmod 4755 /Applications/YourApp.app/YourApp

And for the last step, SpringBoard doesn't open apps with the setuid bit, but it opens a script (which can open another app)! Just change the name of the binary to something like YourApp_:

mv /Applications/YourApp.app/YourApp /Applications/YourApp.app/YourApp_

And create a new file named YourApp in your app folder with the following script:

#!/bin/bash
CrrDir=$(dirname "$0")
exec "${CrrDir}"/YourApp_

Now, just respring (there's an app for that in Cydia) and you're ready to go.

Sorry if this seems hard, it isn't, I don't remember where I learned it, but it was a long time ago. This method works fine in all iOS versions and I've just tested it with iOS 5.1.

Again, YOUR APP WILL NOT BE APPROVED BY APPLE IF YOU DO THIS.

like image 104
fbernardo Avatar answered Oct 28 '22 01:10

fbernardo