Content Search
Optional
Needed if your app searches for Regions or Location Tags by name.
Sending a Request
The IPSFramework makes possible searching for location-based content in a building, by name.
To initiate a search request, use the IPSContent.search() method. Since many objects can correspond to one request, the maximum number of objects returned for a single request is limited by the pageSize parameter (default value is 20).
The successful response contains:
-
The items corresponding to the search criteria as a list of IPSContentItem. Each item contains the common for all the content types information (like name and metadata) as well as information about where this item is located. Use IPSContentItem.type to figure out which type a content item is.
-
The IPSContentSearchPage object that can be used to request the next set of results with the IPSContent.fetch() method.
IPSContent.search(buildingId: "[Building Id]", searchTerm: "[Search term]", onSuccess: { (items, nextPage) in
for contentItem in items {
// Info about the placements in the building
let placements = contentItem.placements
switch contentItem.type {
case .region:
let region = contentItem as! IPSRegion
// use region
case .locationTag:
let locationTag = contentItem as! IPSLocationTag
// use location tag
}
}
}) { (error) in
// handle error
}
Note
The search occurs in the scope of the current selected Space and the building for which id is provided as a parameter.
Cancelling a Request
The Framework will request the content from the server. This requires an Internet connection. The request may take time. If necessary, the request can be cancelled by calling the IPSCancellable.cancel() method of the IPSCancellable object returned by the search/get/fetch method call.