[英]How to open other apps on my device from my app
我想打開另一個應用程序(如GDrive,iBooks等)。 使用我的應用程序中的UTI。
為此,我嘗試使用此站點中的以下代碼, 該代碼用於將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];
上面的代碼確實從我的應用程序中提供了我的設備上可用的應用程序列表(GDrive,iBooks等),但當我點擊這些應用程序中的任何一個時,它會將一個PDF從我的應用程序導出到所選應用程序,我使用FilePath作為“NIL”。
我想要做的是能夠從我的應用程序打開我的設備上的任何可用的其他應用程序(GDrive,iBooks等),而無需從我的應用程序發送任何PDF文件到該其他應用程序。
自定義URL是要走的路。 請參閱此鏈接以獲取實施示例代碼。
URL方案是要走的路,但當然不是每個應用都有它們。 可在此處找到完整列表(截至本答復時,網站存在某種錯誤,無法打開)。
有關如何使用它們打開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
每個APP都包含標識符,其形式為“com.companyName.appName”(例如:“com.adobe.appname”)。 要在特定的應用程序中打開它,
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@“com.adobe.appname”]];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.