我正在尝试使位置图标显示在iOS的Spotlight中。
使用下面的代码,我可以使电话图标显示在Spot Light中,但不能使地图图标显示。
我想念什么?
谢谢!
func addToSpotlightIndex(store: StoreLocatons) {
var searchableItems = [CSSearchableItem]()
let searchItemAttributeSet = CSSearchableItemAttributeSet(itemContentType: "location")
searchItemAttributeSet.title = "Closest Store"
searchItemAttributeSet.namedLocation = store.locationName
searchItemAttributeSet.contentDescription = "\(store.locationName)\n\(store.locationAddress1)"
searchItemAttributeSet.supportsPhoneCall = true
searchItemAttributeSet.supportsNavigation = true
searchItemAttributeSet.phoneNumbers = [store.phoneNumber1]
searchItemAttributeSet.longitude = NSNumber(value: store.longitude)
searchItemAttributeSet.latitude = NSNumber(value: store.latitude)
let searchableItem = CSSearchableItem(uniqueIdentifier: store.locationName, domainIdentifier: nil, attributeSet: searchItemAttributeSet)
searchableItems.append(searchableItem)
CSSearchableIndex.default().indexSearchableItems(searchableItems) { (error) -> Void in
if error != nil {
print(error?.localizedDescription ?? "Error")
}
}
}