You should not modify the Info.plist application Info.plist (or anything in your application) at run time. This is bad practice and you will also break your application if it is signed with code. This is more important now, since all applications in the application store must be signed with code.
It is best to use the TransformProcessType() Application Services function to move the application from the background to the foreground application.
First set the LSUIElement key in the Info.plist application to YES , and then check the default startup for the user to determine whether your application should work as an agent or not:
#import <ApplicationServices/ApplicationServices.h> @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)notification { if (![[NSUserDefaults standardUserDefaults] boolForKey:@"LaunchAsAgentApp"]) { ProcessSerialNumber psn = { 0, kCurrentProcess }; TransformProcessType(&psn, kProcessTransformToForegroundApplication); SetFrontProcess(&psn); } } @end
Make sure you remember to add the application infrastructure to your project.
source share