2013-12-17 156 views
0

我使用下面的代码:iPhone 5应用程序启动另一个应用程序

int (*openApp)(CFStringRef, Boolean); 
void* sbServices = dlopen("/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices", RTLD_LAZY); 
openApp= (int(*)(CFStringRef, Boolean))dlsym(sbServices,"SBSLaunchApplicationWithIdentifier"); 
openApp(CFSTR("com.apple.mobilephone"), FALSE); 
dlclose(sbServices); 

这是在模拟器上工作正常,但在设备上它给以下错误:

com.apple.springboard.launchapplications required to use kern_return_t _SBXXLaunchApplication(mach_port_t, char *, sbs_url_string_t, sbs_property_list_data_t, mach_msg_type_number_t, sbs_property_list_data_t, mach_msg_type_number_t, SBSApplicationLaunchFlags, SBSApplicationLaunchError *, audit_token_t)

有什么解决上述问题?

回答

1

更好的使用[[UIApplication sharedApplication] openUrl:[NSURL URLWithString:@"YOUR URL"]];你需要在你的第二个应用中设置一个自定义URL方案。请检查这tutorial或只需使用“iphone自定义URL方案”进行搜索。有很多很好的教程。

相关问题