Using External Identifier to show building/site¶
This guide aims to explain the usage of external id parameter to get specific site and buildings. The pre-requisite to this is to enter the preferred external id into your designated Pointr Cloud instance.
Let’s say your site and building structure is as below;
-
Favourite Site - iid: 1, eid: “fav_332_store”
- Green Building - iid: 1, eid: “green_221”
- Yellow Building - iid: 2, eid: “yellow_451”
-
Flagship Site - iid: 2, eid: “flagship_6554_store”
- Circus Building - iid: 3, eid: “circus_381”
The iid (internalIdentifier) above is used within Pointr systems. The eid(externalIdentifier) is designed for client usage. You can enter any string you prefer there. It is usually used to match the reference of the site/buildings in client CMS if exists.
To get a specific Site or Building, you will need to use the SiteManager, making use of either the iid or eid of the preferred Site/Building.
Note
The SiteManager data is updated regularly, similar to the DataManager logic. Be sure to assign a listener to SiteManager to override the onSiteManagerDataChanged callback, which will allow you to get notified when site/building data is updated.
Warn
If you are sure of an id that you use to access a Site/Building, but the SiteManager is returning null, the most common cause would be that the SiteManager is still downloading the Sites. Please wait for the onSiteManagerDataChanged callback and try again.
val favouriteSiteInternalId = 1
val favouriteSiteExternalId = "fav_332_store"
val greenBuildingExternalId = "green_221"
val yellowBuildingExternalId = "yellow_451"
val greenBuildingInternalId = 1
Pointr.getPointr()?.siteManager?.let { nonNullSiteManager->
val greenBuilding = nonNullSiteManager.getBuilding(greenBuildingExternalId)
val greenBuildingWithInternalId = nonNullSiteManager.getBuilding(greenBuildingInternalId)
/** [greenBuilding] and [greenBuildingWithInternalId] are the same object */
val favouriteSite = nonNullSiteManager.getSite(favouriteSiteExternalId)
val favouriteSiteWithInternalId = nonNullSiteManager.getSite(favouriteSiteInternalId)
/** [favouriteSite] and [favouriteSiteWithInternalId] are the same object */
// You can also find the matching building from the buildings associated with a site
val yellowBuilding = favouriteSite?.buildings?.firstOrNull { it.externalIdentifier == yellowBuildingExternalId }
}
let favouriteSiteInternalId = 1
let favouriteSiteExternalId = "fav_332_store"
let greenBuildingExternalId = "green_221"
let yellowBuildingExternalId = "yellow_451"
let greenBuildingInternalId = 1
if let nonNullSiteManager = Pointr.shared.siteManager {
let greenBuilding = nonNullSiteManager.building(withExternalIdentifier: greenBuildingExternalId)
let greenBuildingWithInternalId = nonNullSiteManager.building(withInternalIdentifier: Int32(greenBuildingInternalId))
/** [greenBuilding] and [greenBuildingWithInternalId] are the same object */
let favouriteSite = nonNullSiteManager.site(withExternalIdentifier: favouriteSiteExternalId)
let favouriteSiteWithInternalId = nonNullSiteManager.site(withInternalIdentifier: Int32(favouriteSiteInternalId))
/** [favouriteSite] and [favouriteSiteWithInternalId] are the same object */
// You can also find the matching building from the buildings associated with a site
let yellowBuilding = favouriteSite?.buildings.filter{ $0.externalIdentifier == yellowBuildingExternalId }.first
}