在我的 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 交谈时,它只会进行网络搜索。