Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using launchd on IOS to restart app

I am using some iPads in a museum exhibition, running an app developed by others. Even though we've covered the Home button, I'm finding that occasionally the app crashes, leaving the user at the Home screen. From here they can access other unauthorised apps.

The museum is not averse to jailbreaking the iPad if that will give us the solution we require, so I have been doing some research into the idea of using launchd with the KeepAlive tag and putting the .plist file into the /Library/LaunchAgents directory to prevent the app closing or re-spawning it if it crashes

So far I have had success making it work with the default apps that come with the iPad and also Cydia installed apps but I can't get it to restart the app that we want. I have tried it from the /User/Applications directory and also /Applications, which someone suggested might make a difference but no joy. Can someone suggest a possible solution or am I wasting my time? I've inserted the XML from my plist file below.

   <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.MVFieldguide.launchd</string>
<key>ProgramArguments</key>
    <array>
    <string>/Applications/Field Guide 2010.app/Field Guide 2010</string>
    </array>

<key>RunAtLoad</key>
    <true/>

<key>KeepAlive</key>
    <dict>
        <key>SuccessfulExit</key>
        <true/>
    </dict>

like image 575
Joe Coleman Avatar asked May 04 '11 11:05

Joe Coleman


People also ask

How do I relaunch an app on my Mac?

Choose Apple menu > Force Quit, select the app in the dialogue that appears, then click Force Quit. Start the application again.


2 Answers

This won't work because App Store applications are not kept in the Applications folder. I can think of two options.

  1. Install AppLinks in Cydia. This will create symlinks of every App Store app and puts them in /var/mobile/AppLinks. Then in your plist file put the path to the application as

    /var/mobile/AppLinks/Field Guide 2010/Field Guide 2010

  2. Instead of installing the app onto the iPad conventionally, you can get the ipa from Xcode and extract the .app bundle. Then manually install it into /Applications/ and you'll be able to use your launchd plist the way you have it.

I recommend the first option because it will allow you update the app without manually putting the .app bundle into the Applications folder. Using the first option won't change your workflow for updating the app at all.

Also, just be aware that if you do this, you'll have to remove the plist before updating the app to quit it, as I don't think you can update an app while it's running.

like image 154
edc1591 Avatar answered Sep 24 '22 15:09

edc1591


iOS 6.0 may have some kind of fix for locking the device into a mode... I DON"T KNOW (NDA)

a hacked iOS 5.1 can still do the following:

user the app with the bundle identifier....

you can open calculator with com.apple.calculator.... no need for folders!

here is the script you put into launchd folder...

Install the Open app from cydia first so you can use the "open com.apple.calculator" terminal command

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Disabled</key>
    <false/>
    <key>Label</key>
    <string>com.perceptdev.tink</string>
    <key>ProgramArguments</key>
    <array>
        <string>open</string>
        <string>com.orbitusrobotics.thegatekeeper</string>
        <string></string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StartInterval</key>
    <integer>10</integer>
    <key>WatchPaths</key>
    <array/>
</dict>
</plist>
like image 45
Orbitus007 Avatar answered Sep 22 '22 15:09

Orbitus007