4

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

4

1 回答 1

2

目前,在 iOS 9 中,Siri 不会与您的应用添加到 Spotlight 索引的项目进行交互。此 API 仅用于让项目出现在 Spotlight 搜索结果中,而不是在 Siri 响应中。

于 2015-12-24T22:00:04.617 回答