Content Search
Optional
Needed if your app searches for Regions or Location Tags by name.
Sending a Request
The IPS SDK 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).
A successful response contains:
-
The items corresponding to the search criteria as a list of IPSContentItem objects. Each item contains the common information for all the content types (like name and metadata) as well as information about where this item is located (its placements). 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("[Building Id]", "[Search term]", PAGE_SIZE, new IPSContentSearchListener() {
@Override
public void onSearchResult(@NonNull List<IPSContentItem> list, @Nullable IPSContentSearchPage nextPage) {
for (IPSContentItem contentItem : list) {
switch (contentItem.getType()) {
case IPSContentItem.TYPE_LOCATION_TAG:
IPSLocationTag locationTag = (IPSLocationTag)contentItem;
// use location tag
break;
case IPSContentItem.TYPE_REGION:
IPSRegion region = (IPSRegion)contentItem;
// use region
break;
}
}
}
@Override
public void onError(@NonNull IPSError error) {
// 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 SDK 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 IPSCancelable object returned by the search/get/fetch method call.