I am trying to get MKMapItem.pointOfInterestCategory on iOS 13 beta using this unit test:
func testPointOfInterests() {
let request = MKLocalSearch.Request()
let mkSearchExpectation = expectation(description: "MKLocalSearch")
// Sagrada Família, Barcelone
let coordinate = CLLocationCoordinate2D(latitude: 41.40359499, longitude: 2.17436157)
request.region = MKCoordinateRegion.init(center: coordinate, latitudinalMeters: 1000, longitudinalMeters: 1000)
request.naturalLanguageQuery = "Sagrada Família"
if #available(iOS 13.0, *) {
request.pointOfInterestFilter = MKPointOfInterestFilter(excluding: [.atm])
}
let search = MKLocalSearch(request: request)
search.start { (response, error) in
mkSearchExpectation.fulfill()
XCTAssertNil(error)
XCTAssertNotNil(response)
guard let response = response else {
return
}
for mapItem in response.mapItems {
dump(mapItem)
if #available(iOS 13.0, *) {
if let category = mapItem.pointOfInterestCategory {
print(category)
}
}
}
}
waitForExpectations(timeout: 10.0) {
error in
if let error = error {
XCTFail(error.localizedDescription)
}
}
}
I get a relevant mapItem, but MKMapItem.pointOfInterestCategory is nil.
A similar test using Apples Maps app shows that Apples servers know that the Sagrada Família in Barcelona is a church.
What am I doing wrong? I'd like to get the pointOfInterestCategory running on iOS 13 beta.