TMBClient

@interface TMBClient : NSObject <TMBPushInternalDelegate>

Client for interacting with a Tamber project and/or engine via the Tamber API.

  • Create a Tamber Client instance.

    Declaration

    Objective-C

    + (nullable instancetype)apiClientWithPublishableProjectKey:
                                 (nullable NSString *)publishableProjectKey
                                           publishableEngineKey:
                                               (nullable NSString *)
                                                   publishableEngineKey;

    Swift

    class func apiClient(withPublishableProjectKey publishableProjectKey: String?, publishableEngineKey: String?) -> Self?

    Parameters

    publishableProjectKey

    Your publishable project key. Obtained from https://dashboard.tamber.com

    publishableEngineKey

    Your publishable engine key. Obtained from https://dashboard.tamber.com

  • Create a Tamber Client instance.

    Declaration

    Objective-C

    + (nullable instancetype)
        apiClientWithPublishableProjectKey:
            (nullable NSString *)publishableProjectKey
                      publishableEngineKey:(nullable NSString *)publishableEngineKey
                                      user:(nullable NSString *)user;

    Swift

    class func apiClient(withPublishableProjectKey publishableProjectKey: String?, publishableEngineKey: String?, user: String?) -> Self?

    Parameters

    publishableProjectKey

    Your publishable project key. Obtained from https://dashboard.tamber.com

    publishableEngineKey

    Your publishable engine key. Obtained from https://dashboard.tamber.com

    user

    The unique id for the app user

  • Tamber initialization

    Declaration

    Objective-C

    - (nullable instancetype)
        initWithPublishableProjectKey:(nullable NSString *)publishableProjectKey
                 publishableEngineKey:(nullable NSString *)publishableEngineKey
                                 user:(nullable NSString *)user;

    Swift

    init?(publishableProjectKey: String?, publishableEngineKey: String?, user: String?)

    Parameters

    publishableProjectKey

    Your publishable project key, obtained from https://dashboard.tamber.com

    publishableEngineKey

    Your publishable engine key, obtained from https://dashboard.tamber.com

    user

    The unique id for the app user

  • Set id for the user

    Declaration

    Objective-C

    - (void)setUser:(nullable NSString *)user;

    Swift

    func setUser(_ user: String?)

    Parameters

    user

    The unique id for the app user

  • Get the current user. Returns nil if no user has been set.

    Declaration

    Objective-C

    - (nullable NSString *)getUser;

    Swift

    func getUser() -> String?
  • Set the push token for the user (must set the user first)

    Declaration

    Objective-C

    - (void)setUserPushToken:(nullable NSString *)token;

    Swift

    func setUserPushToken(_ token: String?)

    Parameters

    token

    The unique push token for the user

  • Set the location for the user (must set the user first)

    Declaration

    Objective-C

    - (void)setUserLocation:(nullable CLLocation *)location;

    Swift

    func setUserLocation(_ location: CLLocation?)

    Parameters

    location

    The current location for the user

  • Set the delegate for TMBPush.

    Declaration

    Objective-C

    - (void)setPushDelegate:(nullable id<TMBPushDelegate>)delegate;

    Swift

    func setPushDelegate(_ delegate: TMBPushDelegate?)

    Parameters

    delegate

    The TMBPushDelegate.

  • Enable TMBPush operation. Initializes TMBPush instance to begin handling push notification events.

    Declaration

    Objective-C

    - (void)enablePush;

    Swift

    func enablePush()
  • Track start of user session. Used to evaluate engagement driven by push notifications.

    Declaration

    Objective-C

    - (void)sessionStarted;

    Swift

    func sessionStarted()
  • Disable push notification services for the user.

    Declaration

    Objective-C

    - (void)disableUserPush;

    Swift

    func disableUserPush()
  • Enable push notification services for the user after having called disableUserPush. Push services will be enabled by default if enablePush has been called and the user has given push permissions to the app.

    Declaration

    Objective-C

    - (void)reEnableUserPush;

    Swift

    func reEnableUserPush()
  • Track event to your project.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)
                trackEvent:(nullable TMBEventParams *)eventParams
        responseCompletion:(nullable TMBAPIResponseBlock)responseCompletion;

    Swift

    func trackEvent(_ eventParams: TMBEventParams?, responseCompletion: TMBAPIResponseBlock? = nil) -> URLSessionDataTask?

    Parameters

    eventParams

    The parameters for the event you are tracking. If the client’s user has been set, then the user field can be nil and it will default to the client’s user.

    responseCompletion

    The callback to run with the returned TMBEventResponse (and any errors that may have occurred)

  • Create user in your project. IMPORTANT: You do not need to manually create users, tracking events will automatically create novel users. Manually creating a user is valuable for initializing metadata, or if you have an onboarding flow where users interact with items, you can create the user with a list of events from onboarding to seed their recommendations.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)
                createUser:(nullable TMBUserParams *)userParams
        responseCompletion:(nullable TMBAPIResponseBlock)responseCompletion;

    Swift

    func createUser(_ userParams: TMBUserParams?, responseCompletion: TMBAPIResponseBlock? = nil) -> URLSessionDataTask?

    Parameters

    userParams

    The parameters for the user you are creating. If the client’s user has been set, then the ID field can be nil and it will default to the client’s user.

    responseCompletion

    The callback to run with the returned TMBUser (and any errors that may have occurred)

  • Save user in your project. The metadata field will be set to the value provided, if not nil, overwriting any past metadata.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)saveUser:(nullable TMBUserParams *)userParams
                             responseCompletion:
                                 (nullable TMBAPIResponseBlock)responseCompletion;

    Swift

    func saveUser(_ userParams: TMBUserParams?, responseCompletion: TMBAPIResponseBlock? = nil) -> URLSessionDataTask?

    Parameters

    userParams

    The parameters for the user you are updating. If the client’s user has been set, then the ID field can be nil and it will default to the client’s user.

    responseCompletion

    The callback to run with the returned TMBUser (and any errors that may have occurred)

  • Save user in your project with configurable save mode, either “merge” or “replace”. The metadata field will be set to the value provided, if not nil, overwriting any past metadata.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)saveUser:(nullable TMBUserParams *)userParams
                                       withMode:(nullable NSString *)mode
                             responseCompletion:
                                 (nullable TMBAPIResponseBlock)responseCompletion;

    Swift

    func saveUser(_ userParams: TMBUserParams?, withMode mode: String?, responseCompletion: TMBAPIResponseBlock? = nil) -> URLSessionDataTask?

    Parameters

    userParams

    The parameters for the user you are updating. If the client’s user has been set, then the ID field can be nil and it will default to the client’s user.

    mode

    The mode for how the user object will be saved on conflict, either “merge” with the pre-existing user or “replace” the whole object (default is “replace”).

    responseCompletion

    The callback to run with the returned TMBUser (and any errors that may have occurred)

  • Deprecated

    Use saveUser instead.

    Update user in your project. The metadata field will be set to the value provided, if not nil, overwriting any past metadata.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)
                updateUser:(nullable TMBUserParams *)userParams
        responseCompletion:(nullable TMBAPIResponseBlock)responseCompletion;

    Swift

    func updateUser(_ userParams: TMBUserParams?, responseCompletion: TMBAPIResponseBlock? = nil) -> URLSessionDataTask?

    Parameters

    userParams

    The parameters for the user you are updating. If the client’s user has been set, then the ID field can be nil and it will default to the client’s user.

    responseCompletion

    The callback to run with the returned TMBUser (and any errors that may have occurred)

  • Retrieve user in your project.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)
              retrieveUser:(nullable TMBUserParams *)userParams
        responseCompletion:(nullable TMBAPIResponseBlock)responseCompletion;

    Swift

    func retrieveUser(_ userParams: TMBUserParams?, responseCompletion: TMBAPIResponseBlock? = nil) -> URLSessionDataTask?

    Parameters

    userParams

    The parameters for the user you are retrieving – only the ID is used. If the client’s user has been set, then the ID field can be nil and it will default to the client’s user.

    responseCompletion

    The callback to run with the returned TMBUser (and any errors that may have occurred)

  • Retrieve user in your project.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)
              retrieveUser:(nullable TMBUserParams *)userParams
                 getEvents:(BOOL)getEvents
        responseCompletion:(nullable TMBAPIResponseBlock)responseCompletion;

    Swift

    func retrieveUser(_ userParams: TMBUserParams?, getEvents: Bool, responseCompletion: TMBAPIResponseBlock? = nil) -> URLSessionDataTask?

    Parameters

    userParams

    The parameters for the user you are retrieving – only the ID is used. If the client’s user has been set, then the ID field can be nil and it will default to the client’s user.

    getEvents

    Include the past events performed by the user in the user response.

    responseCompletion

    The callback to run with the returned TMBUser (and any errors that may have occurred)

  • Merge from the current default user to another, transferring the tracked events / recommendations and removing the default user from the project, as well as all associated engines, and setting the TMBClient default user to the id of the new toUser. Useful for transferring a temporary user profile to a logged-in user.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)mergeToUser:(nonnull NSString *)toUser
                                responseCompletion:(nullable TMBAPIResponseBlock)
                                                       responseCompletion;

    Swift

    func merge(toUser: String, responseCompletion: TMBAPIResponseBlock? = nil) -> URLSessionDataTask?

    Parameters

    toUser

    The ID of the user that will be merged to.

    responseCompletion

    The callback to run with the returned TMBUser (and any errors that may have occurred)

  • Merge one user into another, removing the from user. Useful for transferring the tracked events / recommendations of a temporary user to a logged-in user.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)mergeUser:(nonnull NSString *)fromUser
                                          toUser:(nonnull NSString *)toUser
                              responseCompletion:
                                  (nullable TMBAPIResponseBlock)responseCompletion;

    Swift

    func mergeUser(_ fromUser: String, toUser: String, responseCompletion: TMBAPIResponseBlock? = nil) -> URLSessionDataTask?

    Parameters

    fromUser

    The ID of the user that will be merged from.

    toUser

    The ID of the user that will be merged to.

    responseCompletion

    The callback to run with the returned TMBUser (and any errors that may have occurred)

  • Merge one user into another, removing the from user. Useful for transferring the tracked events / recommendations of a temporary user to a logged-in user.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)mergeUser:(nonnull NSString *)fromUser
                                          toUser:(nonnull NSString *)toUser
                                        noCreate:(BOOL)noCreate
                                       getEvents:(BOOL)getEvents
                              responseCompletion:
                                  (nullable TMBAPIResponseBlock)responseCompletion;

    Swift

    func mergeUser(_ fromUser: String, toUser: String, noCreate: Bool, getEvents: Bool, responseCompletion: TMBAPIResponseBlock? = nil) -> URLSessionDataTask?

    Parameters

    fromUser

    The ID of the user that will be merged from.

    toUser

    The ID of the user that will be merged to.

    noCreate

    By default, if the toUser does not yet exist it will be created. Set noCreate to true to disable this behavior (meaning attempting to merge to a user that does not exist will return an error).

    getEvents

    Include the past events performed by the user in the user response.

    responseCompletion

    The callback to run with the returned TMBUser (and any errors that may have occurred)

  • Search for users by metadata field-values.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)searchUsers:(nonnull NSDictionary *)metadata
                                responseCompletion:(nullable TMBAPIResponseBlock)
                                                       responseCompletion;

    Swift

    func searchUsers(_ metadata: [AnyHashable : Any], responseCompletion: TMBAPIResponseBlock? = nil) -> URLSessionDataTask?

    Parameters

    metadata

    Dictionary of key-value pairs to search on. The key-values are AND’d together, meaning the search will return users whose metadata contains the entirety of the given dictionary.

    responseCompletion

    The callback to run with the returned TMBUserSearchResponse (and any errors that may have occurred)

  • Retrieve the set of recommended items to display next for the given item and user (if the user is set). Discover Next is your go-to tool for displaying personalized items on item-pages (set the item to the currently displayed item).

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)
              discoverNext:(nonnull TMBDiscoverParams *)discoverParams
        responseCompletion:(nonnull TMBAPIResponseBlock)responseCompletion;

    Swift

    func discoverNext(_ discoverParams: TMBDiscoverParams, responseCompletion: @escaping TMBAPIResponseBlock) -> URLSessionDataTask?

    Parameters

    discoverParams

    The parameters for the discover request.

    responseCompletion

    The callback to run with the returned TMBEventResponse (and any errors that may have occurred)

  • Retrieve recommended items for the given user.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)
        discoverRecommendations:(nonnull TMBDiscoverParams *)discoverParams
             responseCompletion:(nonnull TMBAPIResponseBlock)responseCompletion;

    Swift

    func discoverRecommendations(_ discoverParams: TMBDiscoverParams, responseCompletion: @escaping TMBAPIResponseBlock) -> URLSessionDataTask?

    Parameters

    discoverParams

    The parameters for the discover request. If the client’s user has been set, then the user field can be nil and it will default to the client’s user.

    responseCompletion

    The callback to run with the returned TMBEventResponse (and any errors that may have occurred)

  • Retrieve similar items for the given item.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)
           discoverSimilar:(nonnull TMBDiscoverBasicParams *)discoverParams
        responseCompletion:(nonnull TMBAPIResponseBlock)responseCompletion;

    Swift

    func discoverSimilar(_ discoverParams: TMBDiscoverBasicParams, responseCompletion: @escaping TMBAPIResponseBlock) -> URLSessionDataTask?

    Parameters

    discoverParams

    The parameters for the discover request. Set the item parameter to the id of the item for which you wish to receive similar item suggestions.

    responseCompletion

    The callback to run with the returned TMBEventResponse (and any errors that may have occurred)

  • Retrieve similar items for the given item, that are tailored to the taste profile of the given user.

    Declaration

    Objective-C

    - (nullable NSURLSessionDataTask *)
        discoverRecommendedSimilar:(nonnull TMBDiscoverBasicParams *)discoverParams
                responseCompletion:(nonnull TMBAPIResponseBlock)responseCompletion;

    Swift

    func discoverRecommendedSimilar(_ discoverParams: TMBDiscoverBasicParams, responseCompletion: @escaping TMBAPIResponseBlock) -> URLSessionDataTask?

    Parameters

    discoverParams

    The parameters for the discover request. Set the item parameter to the id of the item for which you wish to receive similar item suggestions. If the client’s user has been set, then the user field can be nil and it will default to the client’s user.

    responseCompletion

    The callback to run with the returned TMBEventResponse (and any errors that may have occurred)