当通过SiriKit启动应用程序时,打开一个不同的UIViewController
我正在尝试在我的iOS应用程序中实现SiriKit。 我想通过 Siri启动应用程序时打开一个不同的视图控制器。
我怎样才能在我的应用程序中处理这种types的操作?
您可以这样做,但是,首先您必须在您的应用程序中设置SiriKit,这是一个长长的指令列表: https : //developer.apple.com/library/prerelease/content/documentation/Intents /Conceptual/SiriIntegrationGuide/index.html#//apple_ref/doc/uid/TP40016875-CH11-SW1 。
还有一个叫做UnicornChat的样本SiriKit应用程序: https : //developer.apple.com/library/content/samplecode/UnicornChat/Introduction/Intro.html
一旦添加了SiriKit应用程序扩展并正确处理了您的Intent,您就可以使用与您的Intent关联的ResponseCode将其发送到您的应用程序。 这将打开你的应用程序,你可以通过将下面的代码添加到你的应用程序委托来捕获它并发送到WhateverViewController:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool { // implement to handle user activity created by Siri or by our SiriExtension let storyboard = UIStoryboard(name: "Main", bundle: nil) // Access the storyboard and fetch an instance of the view controller let viewController: WhateverViewController = storyboard.instantiateViewController(withIdentifier: "WhateverViewController") as! WhateverViewController window?.rootViewController = viewController window?.makeKeyAndVisible() }
- Swift中的parser.parse()会导致EXC_BAD_ACCESS
- 如何在Safari中打开外部链接而不是应用程序的UIWebView?
- “发生了ssl错误,并且无法build立与服务器的安全连接”,仅在手机上连接到Internal Development Server
- 在Facebook用户的Xcode中查看ProfilePicture
- MonoTouch – xib.designer.cs丢失UIKit对象完全限定path的文件
- UIImageView:变换UIImage
- 将高度UILabel设置为0
- 当AVPlayer播放m3u8stream时,如何捕捉图像?
- NC宣布出售-iOS上的Notification Center的Twitter小部件