Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS How can I use UIApplication launchApplicationWithIdentifier which is in private APIs?

[EDIT]I've jb my device. And I found the latest private APIs iOS-Runtime-Headers on Github.

I want to use private APIs in my app.

I found kennytm/iphone-private-frameworks on github but it only support iOS 3.x. While I'm working on iOS 5.0.1.

I also found some codes on Google iPhone development tools. But it really make me confused. I'm new to iPhone development.

What should I do to use

[[UIApplication sharedApplication] launchApplicationWithIdentifier:@"com.a.b" suspended:NO];

Someone can give me a direction or some examples. Thanks a lot.

like image 637
wyp Avatar asked Feb 21 '23 03:02

wyp


1 Answers

REQUIREMENTS

  1. Jailbroken iDevice
  2. Valid certificates/keys in your keychain and its associated provisioning profile. (If you aren't enrolled in the apple developer program, use this workaround: self sign my code and test on iphone in xCode)

MY SOLUTION

1) Enable Entitlements in your XCode project.

To add Entitlements to your project, select your project in project navigator, then on active Target -> Summary -> Entitlements -> check Enable entitlements check box. New file with name "YourProject.entitlements" would appear in project navigator right after.

2) Add folowing property to Entitlements.

Add entitlement property: com.apple.springboard.launchapplications of type Boolean with value YES

3) Since launchApplicationWithIdentifier:suspended: is private API, you need to explicitly declare it in order to build your app. Just add folowing code in appropriate place(s):

// Simply make declaration  inside a Category.
#import "BlahBlah.h"
@interface UIApplication (Undocumented)
    - (void) launchApplicationWithIdentifier: (NSString*)identifier suspended: (BOOL)suspended;
@end
....
@implementation BlahBlah
...

4) Build your project.

5) Copy YourProject.app into device's /Application folder (via SFTP, for example)

6) Respring or reboot iDevice.

7) ...

8) Profit!

SEE ALSO

Special API to launch an app from my application - another solution

What is the bundle identifier of apple's default applications in iOS?

like image 51
Oleg Trakhman Avatar answered May 07 '23 15:05

Oleg Trakhman