Search code examples
iphoneiosjailbreakiphone-privateapi

Preferred method to automatically start an app on startup/boot?


I'm looking to build a jailbroken device in "kiosk mode" where only my app can run on the device. I'd like to have my app automatically launch when the device boots. There have been a number of questions asked about this:

However none of the answers have provided much detail. Maybe I can implement -(BOOL) _shouldAutoLaunchOnBoot:(BOOL)boot;, return YES and bob's your uncle (I'll experiment with that). Maybe I can simply replace SpringBoard.app with my own app. Has anyone accomplished this and willing to provide details?

For the record this will be used in an environment where it doesn't matter if the device is jailbroken, and I won't be submitting anything to the App Store.


Solution

  • I don't know how you could use _shouldAutoLaunchOnBoot: but I've done something similar before using MobileSubstrate

    I hooked -[SBUIController finishLaunching] and then launched the app I wanted

    -(void) appLaunch {
        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 4.0) {
            if ([[objc_getClass("SBIconModel") sharedInstance] iconForDisplayIdentifier:bundleID] != nil){
            [[[objc_getClass("SBIconModel") sharedInstance] iconForDisplayIdentifier:bundleID] launch]; 
            }
        }
        else {
            if ([[objc_getClass("SBIconModel") sharedInstance] applicationIconForDisplayIdentifier:bundleID] != nil) {
            [[[objc_getClass("SBIconModel") sharedInstance] applicationIconForDisplayIdentifier:bundleID] launch]; 
            }
        }   
    }
    

    To make sure that no one can exit the app using the home button you could hook and block SpringBoard's menuButtonDown: and menuButtonUp:. You'll probably have to block a few other things but this should get you started.