How to use Springboard Services Framework to use SBSLaunchApplicationWithIdentifier

牧云@^-^@ 提交于 2019-12-14 04:17:00

问题


I would like to use the Springboard services framework to make use of the following code.

SBSLaunchApplicationWithIdentifier(CFSTR("com.apple.preferences"), false);

However when I download the header files and use it in my project it won't build. Please let me know how to make this work.


回答1:


What exactly are you planning on using that method for? I was under the impression it was for launching an application from a daemon?

There are other ways to launch an application quite easily. The most reliable I have found is to use the display stacks to launch the application properly. Other methods of launching the app tend to cause issues when you close it and attempt to relaunch and it crashes.

Using theos, you could do something like this:

NSMutableArray *displayStacks = nil;

// Display stack names
#define SBWPreActivateDisplayStack        [displayStacks objectAtIndex:0]
#define SBWActiveDisplayStack             [displayStacks objectAtIndex:1]
#define SBWSuspendingDisplayStack         [displayStacks objectAtIndex:2]
#define SBWSuspendedEventOnlyDisplayStack [displayStacks objectAtIndex:3]

// Hook SBDisplayStack to get access to the stacks

%hook SBDisplayStack

-(id)init
{
    %log;
    if ((self = %orig)) 
    {
        NSLog(@"FBAuth: addDisplayStack");
        [displayStacks addObject:self];
    }
    return self;
}

-(void)dealloc
{
    [displayStacks removeObject:self];
    %orig;
}

%end

And then to launch the app, do this:

id PreferencesApp = [[objc_getClass("SBApplicationController") sharedInstance] applicationWithDisplayIdentifier:@"com.apple.preferences"];

[SBWActiveDisplayStack pushDisplay:PreferencesApp];

However, if you really want to use that method, you need to specify what errors are stopping it from building and check which header files you are using to build it with. You also need to link against the SBS framework.



来源:https://stackoverflow.com/questions/12247052/how-to-use-springboard-services-framework-to-use-sbslaunchapplicationwithidentif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!