[英]How to open other apps on my device from my app
I want to open another application (like GDrive, iBooks, etc.). 我想打开另一个应用程序(如GDrive,iBooks等)。 using the UTI from my application.
使用我的应用程序中的UTI。
For this I tried using the following code from this site , which was used for Exporting a PDF file from my application to another application. 为此,我尝试使用此站点中的以下代码, 该代码用于将PDF文件从我的应用程序导出到另一个应用程序。
NSString * filePath = [[NSBundle mainBundle] pathForResource:nil ofType:@"pdf"];
documentController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
documentController.delegate = self;
[documentController retain];
documentController.UTI = @"com.adobe.pdf";
[documentController presentOpenInMenuFromRect:CGRectZero inView:Parent animated:YES];
The above code does give me the list of applications (GDrive, iBooks, etc.) available on my device from my application , but when I click on any one of these applications ,it exports one PDF from my application to that selected application, though I have used the FilePath as "NIL". 上面的代码确实从我的应用程序中提供了我的设备上可用的应用程序列表(GDrive,iBooks等),但当我点击这些应用程序中的任何一个时,它会将一个PDF从我的应用程序导出到所选应用程序,我使用FilePath作为“NIL”。
What I want to do is to be able to open any of the available other applications (GDrive, iBooks, etc.) on my device from my application without sending any PDF file from my application to that other application. 我想要做的是能够从我的应用程序打开我的设备上的任何可用的其他应用程序(GDrive,iBooks等),而无需从我的应用程序发送任何PDF文件到该其他应用程序。
URL Schemes are the way to go but of course not every app has them. URL方案是要走的路,但当然不是每个应用都有它们。 A complete list can be found here (by the time of this answer, the website has some kind of error and won't open).
可在此处找到完整列表(截至本答复时,网站存在某种错误,无法打开)。
An example on how to use them to open the Facebook App: 有关如何使用它们打开Facebook App的示例:
NSURL *url = [NSURL URLWithString:@"fb://"];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
} // else -> i.e. open Safari to Facebook's page or show an error message
Every APP consists of Identifier Which is in the form of "com.companyName.appName"(ex:"com.adobe.appname"). 每个APP都包含标识符,其形式为“com.companyName.appName”(例如:“com.adobe.appname”)。 TO open it in Specific app,
要在特定的应用程序中打开它,
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"com.adobe.appname"]]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@“com.adobe.appname”]];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.