在我的IOS9应用程序中,我可以使用CoreSpotlight库将数据添加到spotlight的索引中(即,当我使用spotlight搜索框进行搜索时,会显示我添加到索引中的内容)。
然而,Siri似乎并没有从中提取信息。下面是我的代码:
let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeText as String)
attributeSet.title = "AWS Traffic"
attributeSet.contentDescription = "AWS Server Traffic in MyCompany"
attributeSet.keywords = ["MyApp", "AWS", "Server", "Traffic"]
let item = CSSearchableItem(uniqueIdentifier: "com.mycompany.MyApp", domainIdentifier: "com.company.MyApp.AWS", attributeSet: attributeSet)
CSSearchableIndex.defaultSearchableIndex().indexSearchableItems([item]) { (error: NSError?) -> Void in
if let error = error {
print("Indexing error: \(error.localizedDescription)")
} else {
print("Search item successfully indexed!")
}
}有没有办法让Siri显示我的应用程序中的索引数据?目前,当我用我的关键字与Siri交谈时,它只会进行网络搜索。
发布于 2015-12-25 06:00:05
目前,在iOS 9中,Siri不会与你的应用程序添加到Spotlight索引中的项目进行交互。此API仅用于让项目显示在Spotlight搜索结果中,而不是Siri响应中。
https://stackoverflow.com/questions/33228194
复制相似问题