SITCommunicationManager

Objective-C

@interface SITCommunicationManager : NSObject

Swift

class SITCommunicationManager : NSObject

The Communication manager allows you to make asynchronous requests to the server, mostly to fetch data.

Initializers

  • Call this method to receive a reference to an initialized object of this class

    Note

    You should not try to initialize multiple objects of this class using alloc:init because it would result in unexpected behaviour.

    Declaration

    Objective-C

    + (instancetype _Nonnull)sharedManager;

    Swift

    class func shared() -> Self

    Return Value

    The shared manager object. Initially, this method stablish a value of 24 hours as the CAHCE_MAX_AGE for the cache system.

Methods

  • Retrieve the time when data on cache was retrieved

    Declaration

    Objective-C

    - (NSDate *_Nullable)cacheDate;

    Swift

    func cacheDate() -> Date?

    Return Value

    the date when the information was successfully fetched or nil if there is not cache.

  • Establish the time when the stored data on cache expires

    Declaration

    Objective-C

    - (void)setCacheMaxAge:(NSInteger)cacheMaxAge;

    Swift

    func setCacheMaxAge(_ cacheMaxAge: Int)

    Parameters

    cacheMaxAge

    Integer value in seconds. If a negative value is inserted, a value of 0 will be established.

  • Retrieve the value when the stored data on cache expires.

    Declaration

    Objective-C

    - (NSInteger)cacheMaxAge;

    Swift

    func cacheMaxAge() -> Int

    Return Value

    Integer value in seconds.

  • Clear the contents of the cache for a particular user

    Declaration

    Objective-C

    - (void)clearCache;

    Swift

    func clearCache()
  • Download all the necessary information to start positioning. This includes SITBuilding, SITBuildingInfo and the building’s model.

    Note

    Valid options for this method are:

    • SITForceRequestKey. Boolean value indicating if request will be directed to the network system directly (YES) without checking the cache system or the request should check cache first (NO) before going to network
    • SITPreloadImagesKey Boolean value indicating if the POI category and floorplans images should be preload to caché

    Declaration

    Objective-C

    - (BOOL)prefetchPositioningInfoForBuildings:
                (NSArray<NSString *> *_Nullable)buildingIdentifiers
                                    withOptions:(NSDictionary *_Nullable)options
                                 withCompletion:
                                     (SITPrefetchHandler _Nonnull)completion;

    Swift

    func prefetchPositioningInfo(forBuildings buildingIdentifiers: [String]?, withOptions options: [AnyHashable : Any]? = nil, withCompletion completion: @escaping SITPrefetchHandler) -> Bool

    Parameters

    buildingIdentifiers

    List of identifiers of the buildings which information should be prefetched. Can be nil. If nil, all the buildings of this account would be prefetched.

    options

    additional parameters to customize the internal operation of the method declared in SITCommunicationConstants.

    completion

    the kind of block that will be performed after the operation has been completed

    Return Value

    BOOL value indicating if the operation will be performed or not

  • Retrieve the information of the available categories

    Note

    Valid options for this method are:
    • SITForceRequestKey. Boolean value indicating if request will be directed to the network system directly (YES) without checking the cache system or the request should check cache first (NO) before going to network
    • SITPreloadImagesKey Boolean value indicating if the POI category images should be preload to caché

    Declaration

    Objective-C

    - (BOOL)fetchCategoriesWithOptions:(NSDictionary *_Nullable)options
                        withCompletion:
                            (SITPOICategoriesFetchHandler _Nonnull)completion;

    Swift

    func fetchCategories(options: [AnyHashable : Any]? = nil, withCompletion completion: @escaping SITPOICategoriesFetchHandler) -> Bool

    Parameters

    options

    additional parameters to customize the internal operation of the method declared in SITCommunicationConstants.h

    completion

    the kind of block that will be performed after the operation has been completed

    Return Value

    BOOL value indicating if the operation will be performed or not

  • Retrieve the list of floors associated with a building

    Note

    Keys of the options dictionary: - SITForceRequestKey boolean value that determines if the operation should hit the server (YES) or the cachesystem (NO) - SITPreloadImagesKey Boolean value indicating if the building floorplans images should be preload to caché

    Declaration

    Objective-C

    - (NSError *_Nullable)
        fetchFloorsForBuilding:(NSString *_Nonnull)buildingIdentifier
                   withOptions:(NSDictionary *_Nullable)options
                       success:(SITSuccessHandler _Nonnull)success
                       failure:(SITFailureCompletion _Nonnull)failure;

    Swift

    func fetchFloors(forBuilding buildingIdentifier: String, withOptions options: [AnyHashable : Any]? = nil, success: @escaping SITSuccessHandler, failure: @escaping SITFailureCompletion) -> Error?

    Parameters

    buildingIdentifier

    unique identifier of the building

    options

    parameters that modify the internal behaviour

    success

    the kind of block that will be executed when the operation has successfully been performed

    failure

    the kind of block that will be executed when the operation fails

    Return Value

    error that describes why the operation could not be executed (a nil value means the request is valid and will be executed)

  • Download a given building tiles. Not all the buildings have tiles available to be downloaded. If the tiles are available, a zip file is downloaded and unzipped in the user Library path for application We use tiles supported by google maps https://developers.google.com/maps/documentation/ios-sdk/tiles

    Declaration

    Objective-C

    - (NSError *_Nullable)
        fetchTilesForBuilding:(NSString *_Nonnull)buildingIdentifier
                      success:(SITSuccessHandler _Nonnull)success
                      failure:(SITFailureCompletion _Nonnull)failure;

    Swift

    func fetchTiles(forBuilding buildingIdentifier: String, success: @escaping SITSuccessHandler, failure: @escaping SITFailureCompletion) -> Error?

    Parameters

    buildingIdentifier

    unique identifier of the building

    success

    the kind of block that will be executed when the operation has successfully been performed

    failure

    the kind of block that will be executed when the operation fails

    Return Value

    Error when success or failure callback are not supplied, nil otherwise

  • Returns a specific SITTile for a building with buildingIdentifier at the floor specified in floorIdentifier with coordinates x,y at the zoom level z. This SITTile could be either a tile stored in user Library path or a url to fetch the tile

    Declaration

    Objective-C

    - (SITTile *_Nonnull)getTileForBuilding:(NSString *_Nonnull)buildingIdentifier
                            floorIdentifier:(NSString *_Nonnull)floorIdentifier
                                          x:(NSInteger)x
                                          y:(NSInteger)y
                                          z:(NSInteger)z;

    Swift

    func getTileForBuilding(_ buildingIdentifier: String, floorIdentifier: String, x: Int, y: Int, z: Int) -> SITTile

    Parameters

    buildingIdentifier

    unique identifier of the building

    floorIdentifier

    unique identifier

    x

    x coordinate of the tile

    y

    y coordinate of the tile

    z

    level of zoom of the tile

    Return Value

    SITTile with the information of the tile for zoom z and coordinates x,y

  • Invalidate all tiles resources

    Declaration

    Objective-C

    - (void)clearTiles;

    Swift

    func clearTiles()
  • Retrieve the list of users positioning in the building

    Note

    Keys of the options dictionary: forceRequest boolean value that determines if the operation should hit the server (YES) or the cachesystem (NO)

    Declaration

    Objective-C

    - (NSError *_Nullable)
        fetchRealTimeUsersForBuilding:(NSString *_Nonnull)buildingIdentifier
                          withOptions:(NSDictionary *_Nullable)options
                              success:(SITSuccessHandler _Nonnull)success
                              failure:(SITFailureCompletion _Nonnull)failure;

    Swift

    func fetchRealTimeUsers(forBuilding buildingIdentifier: String, withOptions options: [AnyHashable : Any]? = nil, success: @escaping SITSuccessHandler, failure: @escaping SITFailureCompletion) -> Error?

    Parameters

    buildingIdentifier

    unique identifier of the building

    options

    parameters that modify the internal behaviour

    success

    the kind of block that will be executed when the operation has successfully been performed

    failure

    the kind of block that will be executed when the operation fails

    Return Value

    error that describes why the operation could not be executed (a nil value means the request is valid and will be executed)

  • Retrieve the list of buildings

    Note

    Keys of the options dictionary: forceRequest boolean value that determines if the operation should hit the server (YES) or the cachesystem (NO)

    Declaration

    Objective-C

    - (NSError *_Nullable)
        fetchBuildingsWithOptions:(NSDictionary *_Nullable)options
                          success:(SITSuccessHandler _Nonnull)success
                          failure:(SITFailureCompletion _Nonnull)failure;

    Swift

    func fetchBuildings(options: [AnyHashable : Any]? = nil, success: @escaping SITSuccessHandler, failure: @escaping SITFailureCompletion) -> Error?

    Parameters

    options

    parameters that modify the internal behaviour

    success

    the kind of block that will be executed when the operation has successfully been performed. Information can be accessed through the results key on the mapping result dictionary

    failure

    the kind of block that will be executed when the operation fails with an error describing what has failed

    Return Value

    error that describes why the operation could not be executed (a nil value means the request is valid and will be executed)

  • Retrieve the list of indoor points of interest associated with a building

    Note

    Keys of the options dictionary: forceRequest boolean value that determines if the operation should hit the server (YES) or the cachesystem (NO)

    Declaration

    Objective-C

    - (NSError *_Nullable)fetchPoisOfBuilding:(NSString *_Nonnull)buildingIdentifier
                                  withOptions:(NSDictionary *_Nullable)options
                                      success:(SITSuccessHandler _Nonnull)success
                                      failure:
                                          (SITFailureCompletion _Nonnull)failure;

    Swift

    func fetchPois(ofBuilding buildingIdentifier: String, withOptions options: [AnyHashable : Any]? = nil, success: @escaping SITSuccessHandler, failure: @escaping SITFailureCompletion) -> Error?

    Parameters

    buildingIdentifier

    unique identifier of the building

    options

    parameters that modify the internal behaviour (see discussion section)

    success

    the kind of block that will be executed when the operation has successfully been performed. Information can be accessed through the results key on the mapping result dictionary

    failure

    the kind of block that will be executed when the operation fails with an error describing what has failed

    Return Value

    error that describes why the operation could not be executed (a nil value means the request is valid and will be executed)

  • Retrieve a single indoor point of interest associated with a building an identified by an id.

    Note

    Keys of the options dictionary: forceRequest boolean value that determines if the operation should hit the server (YES) or the cachesystem (NO)

    Declaration

    Objective-C

    - (NSError *_Nullable)fetchIndoorPoi:(NSString *_Nonnull)poiIdentifier
                              ofBuilding:(NSString *_Nonnull)buildingIdentifier
                             withOptions:(NSDictionary *_Nullable)options
                                 success:(SITSuccessHandler _Nonnull)success
                                 failure:(SITFailureCompletion _Nonnull)failure;

    Swift

    func fetchIndoorPoi(_ poiIdentifier: String, ofBuilding buildingIdentifier: String, withOptions options: [AnyHashable : Any]? = nil, success: @escaping SITSuccessHandler, failure: @escaping SITFailureCompletion) -> Error?

    Parameters

    poiIdentifier

    unique identifier of the point of interest

    buildingIdentifier

    unique identifier of the building

    options

    parameters that modify the internal behaviour (see discussion section)

    success

    the kind of block that will be executed when the operation has successfully been performed. Information can be accessed through the results key on the mapping result dictionary

    failure

    the kind of block that will be executed when the operation fails with an error describing what has failed

    Return Value

    error that describes why the operation could not be executed (a nil value means the request is valid and will be executed)

  • Retrieve the list of outdoor points of interest associated with a building

    Note

    Keys of the options dictionary: forceRequest boolean value that determines if the operation should hit the server (YES) or the cachesystem (NO)

    Declaration

    Objective-C

    - (NSError *_Nullable)
        fetchOutdoorPoisOfBuilding:(NSString *_Nonnull)buildingIdentifier
                       withOptions:(NSDictionary *_Nullable)options
                           success:(SITSuccessHandler _Nonnull)success
                           failure:(SITFailureCompletion _Nonnull)failure;

    Swift

    func fetchOutdoorPois(ofBuilding buildingIdentifier: String, withOptions options: [AnyHashable : Any]? = nil, success: @escaping SITSuccessHandler, failure: @escaping SITFailureCompletion) -> Error?

    Parameters

    buildingIdentifier

    unique identifier of the building

    options

    parameters that modify the internal behaviour (see discussion section)

    success

    the kind of block that will be executed when the operation has successfully been performed. Information can be accessed through the results key on the mapping result dictionary

    failure

    the kind of block that will be executed when the operation fails with an error describing what has failed

    Return Value

    error that describes why the operation could not be executed (a nil value means the request is valid and will be executed)

  • Retrieve the information of a building.

    Note

    Keys of the options dictionary: - SITForceRequestKey boolean value that determines if the operation should hit the server (YES) or the cachesystem (NO) - SITPreloadImagesKey Boolean value indicating if the building floorplans images should be preload to caché

    Declaration

    Objective-C

    - (NSError *_Nullable)fetchBuildingInfo:(NSString *_Nonnull)buildingIdentifier
                                withOptions:(NSDictionary *_Nullable)options
                                    success:(SITSuccessHandler _Nonnull)success
                                    failure:(SITFailureCompletion _Nonnull)failure;

    Swift

    func fetchBuildingInfo(_ buildingIdentifier: String, withOptions options: [AnyHashable : Any]? = nil, success: @escaping SITSuccessHandler, failure: @escaping SITFailureCompletion) -> Error?

    Parameters

    buildingIdentifier

    unique identifier of the building.

    options

    parameters that modify the internal behaviour (see discussion section)

    success

    the kind of block that will be executed when the operation has successfully been performed. Information can be accessed through the results key on the mapping result dictionary

    failure

    failure the kind of block that will be executed when the operation fails with an error describing what has failed

    Return Value

    error that describes why the operation could not be executed (a nil value means the request is valid and will be executed)

  • Retrieve the floorplan of a floor

    Declaration

    Objective-C

    - (BOOL)fetchMapFromFloor:(SITFloor *_Nonnull)floor
               withCompletion:(SITImageFetchHandler _Nonnull)imageFetchHandler;

    Swift

    func fetchMap(from floor: SITFloor, withCompletion imageFetchHandler: @escaping SITImageFetchHandler) -> Bool

    Parameters

    floor

    SITFloor object

    imageFetchHandler

    the kind of block that will be executed when the operation has successfully been performed (a nil data would mean the operation has failed)

    Return Value

    return false when imageFetchHandler is nil

  • Retrieve the contents of an icon of a category

    Declaration

    Objective-C

    - (BOOL)fetchSelected:(BOOL)selected
          iconForCategory:(SITPOICategory *_Nonnull)category
           withCompletion:(SITPOICategoryIconFetchCompletion _Nonnull)completion;

    Swift

    func fetchSelected(_ selected: Bool, iconFor category: SITPOICategory, withCompletion completion: @escaping SITPOICategoryIconFetchCompletion) -> Bool

    Parameters

    selected

    BOOL parameter indicating the kind of icon to retrieve (YES means the selected one, NO means the regular or normal one)

    category

    SITPOICategory object. Normally you do not instantiate objects of this class, instead you should use the one obtained by -fetchCategoriesWithCompletion:

    completion

    the kind of callback that will be called after the operation has been completed

    Return Value

    BOOL value indicating if the operation is well formed and if it will be executed (YES) or not (NO)

  • Retrieve the events of a SITBuilding

    Note

    Valid options for this method are: SITForceRequestKey. The value of this key is a NSNumber with a bool value on it. The value of YES means that the request will be directed to the network system directly without checking the cache system. The value of NO means the request will be directed to the cache system and if not found it will be redirected to the network system.

    Declaration

    Objective-C

    - (BOOL)fetchEventsFromBuilding:(SITBuilding *_Nonnull)building
                        withOptions:(NSDictionary *_Nullable)options
                     withCompletion:(SITHandler _Nonnull (^_Nonnull)(
                                        NSArray<SITEvent *> *_Nullable,
                                        NSError *_Nullable))completion;

    Swift

    func fetchEvents(from building: SITBuilding, withOptions options: [AnyHashable : Any]? = nil, withCompletion completion: @escaping ([SITEvent]?, Error?) -> SITHandler) -> Bool

    Parameters

    building

    SITBuilding object

    options

    additional parameters to customize the internal operation of the method

    completion

    SITHandler

    Return Value

    This method gives the user a flag that indicates if the operation has been performed or not.

  • Retrieve the events of a SITBuilding

    Note

    Valid options for this method are: SITForceRequestKey. The value of this key is a NSNumber with a bool value on it. The value of YES means that the request will be directed to the network system directly without checking the cache system. The value of NO means the request will be directed to the cache system and if not found it will be redirected to the network system.

    Declaration

    Objective-C

    - (BOOL)fetchEventsFromBuilding:(SITBuilding *_Nonnull)building
                     withCompletion:(SITHandler _Nonnull (^_Nonnull)(
                                        NSArray<SITEvent *> *_Nullable,
                                        NSError *_Nullable))completion;

    Swift

    func fetchEvents(from building: SITBuilding, withCompletion completion: @escaping ([SITEvent]?, Error?) -> SITHandler) -> Bool

    Parameters

    building

    SITBuilding object

    completion

    SITHandler

    Return Value

    This method gives the user a flag that indicates if the operation has been performed or not.

  • Retrieve the geofences of a SITBuilding

    Declaration

    Objective-C

    - (NSError *_Nullable)
        fetchGeofencesFromBuilding:(SITBuilding *_Nonnull)building
                       withOptions:(NSDictionary *_Nullable)options
                    withCompletion:(SITHandler _Nonnull)completion;

    Swift

    func fetchGeofences(from building: SITBuilding, withOptions options: [AnyHashable : Any]? = nil, withCompletion completion: @escaping SITHandler) -> Error?

    Parameters

    building

    Building from which we want to retrieve the geofences

    options

    Additional parameters to customize the internal operation of the method

    completion

    SITHandler

    Note

    Valid options for this method are: SITForceRequestKey. The value of this key is a NSNumber with a bool value on it. The value of YES means that the request will be directed to the network system directly without checking the cache system. The value of NO means the request will be directed to the cache system and if not found it will be redirected to the network system.

    Return Value

    This method gives the user a flag that indicates if the operation has been performed or not.

  • Retrieve the SITRemoteConfig of the current uset with the parameters stored on the dashbooard.

    Note

    Valid options for this method are: SITForceRequestKey. The value of this key is a NSNumber with a bool value on it. The value of YES means that the request will be directed to the network system directly without
    • checking the cache system. The value of NO means the request will be directed to the cache system and if not found it will be redirected to the network system.

    Declaration

    Objective-C

    - (NSError *_Nullable)
        fetchRemoteConfigWithOptions:(NSDictionary *_Nullable)options
                             success:(SITSuccessHandler _Nonnull)success
                             failure:(SITFailureCompletion _Nonnull)failure;

    Swift

    func fetchRemoteConfig(options: [AnyHashable : Any]? = nil, success: @escaping SITSuccessHandler, failure: @escaping SITFailureCompletion) -> Error?

    Parameters

    options

    Additional parameters to customize the internal operation of the method

    success

    the kind of block that will be executed when the operation has successfully been performed. Information can be accessed through the “results” key on the mapping result dictionary

    failure

    failure the kind of block that will be executed when the operation fails with an error describing what has failed

    Return Value

    This method gives the user a flag that indicates if the operation has been performed or not.

  • Retrieve the SITRemoteConfig of the current uset with the parameters stored on the dashbooard. In addition this method overrides the assigned values of the locationRequest.

    Note

    Valid options for this method are: SITForceRequestKey. The value of this key is a NSNumber with a bool value on it. The value of YES means that the request will be directed to the network system directly without
    • checking the cache system. The value of NO means the request will be directed to the cache system and if not found it will be redirected to the network system.

    Declaration

    Objective-C

    - (NSError *_Nullable)
        fetchRemoteConfigWithRequest:(SITLocationRequest *_Nullable)locationRequest
                             options:(NSDictionary *_Nullable)options
                             success:(SITSuccessHandler _Nonnull)success
                             failure:(SITFailureCompletion _Nonnull)failure;

    Swift

    func fetchRemoteConfig(with locationRequest: SITLocationRequest?, options: [AnyHashable : Any]? = nil, success: @escaping SITSuccessHandler, failure: @escaping SITFailureCompletion) -> Error?

    Parameters

    options

    Additional parameters to customize the internal operation of the method

    success

    the kind of block that will be executed when the operation has successfully been performed. Information can be accessed through the “results” key on the mapping result dictionary

    failure

    failure the kind of block that will be executed when the operation fails with an error describing what has failed

    Return Value

    This method gives the user a flag that indicates if the operation has been performed or not.

  • Notifies an event occurrence

    Declaration

    Objective-C

    - (BOOL)createOccurrenceForEvent:(SITEvent *_Nonnull)event
                         withSuccess:
                             (SITOccurrenceCompletion _Nonnull)successCompletion
                             failure:(SITErrorCompletion _Nonnull)errorCompletion;

    Swift

    func createOccurrence(for event: SITEvent, withSuccess successCompletion: @escaping SITOccurrenceCompletion, failure errorCompletion: @escaping SITErrorCompletion) -> Bool

    Parameters

    event

    The event that occurred

    successCompletion

    completion block that will be executed if the operation is performed

    errorCompletion

    completion block that will be executed if the operation fails

    Return Value

    BOOL Returns a flag that indicates if the operation has been performed or not.

  • Notifies an event occurrence

    Declaration

    Objective-C

    - (BOOL)updateOccurrence:(SITOccurrence *_Nonnull)occurrence
                    forEvent:(kSITOccurrenceAction)action
                 withSuccess:(SITOccurrenceCompletion _Nonnull)successCompletion
                     failure:(SITErrorCompletion _Nonnull)errorCompletion;

    Swift

    func update(_ occurrence: SITOccurrence, forEvent action: kSITOccurrenceAction, withSuccess successCompletion: @escaping SITOccurrenceCompletion, failure errorCompletion: @escaping SITErrorCompletion) -> Bool

    Parameters

    occurrence

    event occurrence

    action

    action performed on the event

    successCompletion

    completion block that will be executed if the operation is performed

    errorCompletion

    completion block that will be executed if the operation fails

    Return Value

    BOOL Returns a flag that indicates if the operation has been performed or not.

  • Authenticate with user and password

    Note

    This method needs to be called before performing any other network operation in order to validate the credentials. Otherwise the operations could failed with a 401 error code. Before attempting to connect with different credentials remeber to disconnect to the actual session performing a -logoutWithCompletion: operation.

    Declaration

    Objective-C

    - (BOOL)loginWithUser:(NSString *_Nonnull)user
                 password:(NSString *_Nonnull)password
           withCompletion:(SITLoginHandler _Nonnull)loginHandler;

    Swift

    func login(withUser user: String, password: String, withCompletion loginHandler: @escaping SITLoginHandler) -> Bool

    Parameters

    user

    email of the user

    password

    password of the user

    loginHandler

    completion block that will be executed if the operation is performed

    Return Value

    This method gives the user a flag that indicates if the operation has been performed (YES) or not (NO).

  • Disconnect and clear previous session credentials

    Declaration

    Objective-C

    - (BOOL)logoutWithCompletion:(SITLogoutHandler _Nonnull)logoutHandler;

    Swift

    func logout(completion logoutHandler: @escaping SITLogoutHandler) -> Bool

    Parameters

    logoutHandler

    completion block that will be executed if the operation if performed.

    Return Value

    This method gives the user a flag that indicates if the operation has been performed (YES) or not (NO).

  • Retrieve information about the organization to adapt the look and feel of your app based on your brand.

    Declaration

    Objective-C

    - (BOOL)fetchOrganizationThemeWithOptions:(NSDictionary *_Nullable)options
                                      success:(SITSuccessHandler _Nonnull)success
                                      failure:
                                          (SITFailureCompletion _Nonnull)failure;

    Swift

    func fetchOrganizationTheme(options: [AnyHashable : Any]? = nil, success: @escaping SITSuccessHandler, failure: @escaping SITFailureCompletion) -> Bool

    Return Value

    Upon success you can use a SITOrganizationTheme object