[self.extensionContext openURL:completion]
を試しましたが、アプリがクラッシュしました。私はいくつかの拡張機能は、このメソッドを使用することができない、iMessageの拡張機能を聞いた?オープンなホストアプリケーションをイメージ化できますか?
ところで、アプリをホストすることができますiMessageの拡張機能を有効にする?
[self.extensionContext openURL:completion]
を試しましたが、アプリがクラッシュしました。私はいくつかの拡張機能は、このメソッドを使用することができない、iMessageの拡張機能を聞いた?オープンなホストアプリケーションをイメージ化できますか?
ところで、アプリをホストすることができますiMessageの拡張機能を有効にする?
This is apparently not working in Seed 2 but should be fixed in Seed 3.
それは動作していないわけではありません。彼らはこのように機能するつもりはない。これは受け入れられた答えであってはなりません。 – MattWright
'私はちょうどテストをしました。今あなたはベータ4のiMessage拡張からホストアプリケーションを開くことができます ' – Maize
共有拡張機能とアクション拡張機能は、アプリランチャーとして機能するようには設計されていません。
App Extension Programming Guide
アプリ拡張とその含有アプリとの間に直接的な通信はありません。通常、含まれている拡張機能が実行されている間は、そのアプリケーションを含むアプリケーションが実行されていません。アプリリンクを含むアプリの拡張機能とホストアプリはまったく通信しません。
拡張機能はユーザーインターフェイスを表示し、何らかの作業を行い、拡張機能の目的に応じて、データをホストに返します。
アプリエクステンションとそれを含むアプリとのやりとりが制限されています。 は、NSExtensionContext
クラスのopenURL:completionHandler:
メソッドを呼び出すことで、そのアプリを含むアプリケーションを開くようにシステムに依頼することができます(その他のアプリ拡張タイプはありません)。 「
周りのキーボード拡張のために(iOSの9.2上でテスト)このSO question。
作業溶液由来。
このカテゴリ作品に隠されにアクセスするための特別なメソッドを追加しますsharedApplication
オブジェクトを呼び出して、openURL:
を呼び出します(もちろん、openURL:
メソッドをアプリスキームで使用する必要があります)。
// Valentin Shergin
extension UIInputViewController {
func openURL(url: NSURL) -> Bool {
do {
let application = try self.sharedApplication()
return application.performSelector("openURL:", withObject: url) != nil
}
catch {
return false
}
}
func sharedApplication() throws -> UIApplication {
var responder: UIResponder? = self
while responder != nil {
if let application = responder as? UIApplication {
return application
}
responder = responder?.nextResponder()
}
throw NSError(domain: "UIInputViewController+sharedApplication.swift", code: 1, userInfo: nil)
}
}
[self.extensionContext openURL:YOUR_NSURL completionHandler:nil];
アプリ
self.extensionContext?.open(url, completionHandler: nil)
に特定の画面を開くには、ディープリンクを渡すことができれば、それはいいだろう、私のIMessageが拡張子では動作しません。
tymacの答えが正しいか、しかしOpenURLのはスウィフト3に
を開くために移動された私は、このスレッドでは簡単な解決策が見つかりました:これは私のために正常に動作しますopenURL not work in Action Extension
extension UIViewController {
func openURL(url: URL) {
var responder = self as UIResponder?
while (responder != nil){
if responder?.responds(to: Selector("openURL:")) == true{
responder?.perform(Selector("openURL:"), with: url)
}
responder = responder!.next
}
}
}
これは動作しません... –
を:
NSString *customURL = @"myHostAppName://";
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:customURL]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];
} else {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"URL error" message:[NSString stringWithFormat:@"No custom URL defined for %@", customURL] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:ok];
[self presentViewController:alertController animated:YES completion:nil];
}
再度ホストアプリケーションを再インストールしてください。検討How to open our app from iMessage
チェックこの答えで
がテイク[SWIFT 3.0の私のキーボード延長から私のアプリケーションを開く](https://stackoverflow.com/a/44718613/2150318) –