简体   繁体   English

如何从我的应用程序打开我的设备上的其他应用程序

[英]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文件到该其他应用程序。

Custom URL is the way to go. 自定义URL是要走的路。 Refer this link for sample code with implementation. 请参阅此链接以获取实施示例代码。

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.

相关问题 从我的应用程序中打开其他已安装的应用程序 - Open other installed apps from within my app 在Swift中,当我的应用程序打开时,如何让其他应用程序继续播放音频? - In Swift, how do I let other apps continue to play audio when my app is open? 从iPad应用程序打开iTunes到特定应用程序(在我自己的应用程序中宣传我自己的应用程序) - Open iTunes from an iPad app to a specific app (advertise my own apps inside my own apps) 如何从其他iOS应用程序读取应用程序文档目录中的文档? - How can I read documents in my app's Document directory from other iOS apps? 我添加到我的 iOS 应用程序的自定义 fonts 是否可用于设备上的其他应用程序? - Are custom fonts that I add to my iOS app available to other apps on the device? 在我的应用程序中打开App Store中的应用程序列表 - Open a list of my apps in the App Store within my App 如何在他人的iPhone / iPod Touch设备上安装我的应用程序 - How to install my app on other's iphone/ipod touch device Iphone 应用程序可以打开其他应用程序吗? 如何 - Iphone App that can open other apps? How 如何通过电子邮件打开我的iPhone应用程序? - How to open my iPhone App from Email? 在其他设备上测试我的 iPad 应用程序 - Testing my iPad app on other device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM