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

大兔子大兔子 提交于 2019-11-27 06:18:28

问题


[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.


回答1:


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.

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?



来源:https://stackoverflow.com/questions/11047176/ios-how-can-i-use-uiapplication-launchapplicationwithidentifier-which-is-in-priv

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