新)
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
{
return YES;
}
旧)
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(nullable NSString *)sourceApplication annotation:(id)annotation
{
return YES;
}
NSURL *url = [NSURL URLWithString:@"jp.co.SampleApp001://"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url
options:@{}
completionHandler:nil];
}
<key>LSApplicationQueriesSchemes</key>
<array>
<string>"jp.co.SampleApp001</string>
</array>
通常メールアプリ連携
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:
[email protected]?Subject=fuga&body=test"]];
<
UIDocumentInteractionControllerDelegate
>
@property (strong, nonatomic) UIDocumentInteractionController *docInterCon;
NSBundle *bundle = [NSBundle mainBundle];
NSString *dataFilePath = [bundle pathForResource:@"fileName" ofType:@"xlsx"];
NSURL *url = [NSURL fileURLWithPath:dataFilePath];
self.docInterCon = [UIDocumentInteractionController interactionControllerWithURL:url];
self.docInterCon.delegate = self;
BOOL isValid;
isValid = [self.docInterCon presentOpenInMenuFromRect:self.view.frame inView:self.view animated:YES];
if (!isValid) {
NSLog(@"データを開けるアプリケーションが見つかりません。");
}
#pragma mark UIDocumentInteractionControllerDelegate
/**
* アプリ送信前に呼ばれる
* @param controller UIDocumentInteractionControllerインスタンス
* @param application 送信先アプリ名
* @return 無し
*/
- (void)documentInteractionController:(UIDocumentInteractionController *)controller
willBeginSendingToApplication:(NSString *)application
{
}
/**
* アプリ送信後に呼ばれる
* @param controller UIDocumentInteractionControllerインスタンス
* @param application 送信先アプリ名
* @return 無し
*/
- (void)documentInteractionController:(UIDocumentInteractionController *)controller
didEndSendingToApplication:(NSString *)application
{
self.docInterCon = nil;
}
最終更新:2019年06月02日 23:40