Event Handling

iOS Classic - Event Handling

TBLClassicPageDelegate

When fetching and displaying Taboola content, you may need to handle certain events. Taboola SDK Classic Integration provides a TBLClassicPageDelegate for event handling.

Available Events

didClickPlacementName

An item in the placement was clicked.

πŸ‘

Use Case

Use this method to intercept the click event, and open organic content directly within your app.

- (BOOL)classicUnit:(UIView*)classicUnit didClickPlacementName:(NSString *)placementName itemId:(NSString *)itemId clickUrl:(NSString *)clickUrl isOrganic:(BOOL)organic {
    // Insert your code here...
    // Return 'NO' to handle the click event yourself - or 'YES' for Taboola to handle it.
    // Note: you can override the default behavior for *organic* content only.
    return YES;
}
func classicUnit(_ classicUnit: UIView!, didClickPlacementName placementName: String!, itemId: String!, clickUrl: String!, isOrganic organic: Bool) -> Bool {
    // Insert your code here...
    // Return 'false' if you are handling the click event yourself, or 'true' if you want Taboola SDK to handle the click event.
    // Note: you can override the default behavior for *organic* content only.
    return true;
}

πŸ“˜

Callback params

  • classicUnit - A reference to the placement, returned as type UIView.
  • placementName - The name of the clicked placement - e.g. "<<placementName>>".
  • itemId - The ID of the clicked item.
  • clickUrl - The Click URL of the clicked item.
  • organic - A boolean value, indicating if the clicked item is organic. (If not, then you cannot override the click behavior.)

πŸ“˜

Return value

  • Return true (or YES for Obj C) to indicate that Taboola SDK should open the Click URL.
  • Return false (or NO for Obj C) to prevent Taboola SDK from opening the Click URL (allowing you to handle it).

🚧

You can override the default behavior for organic content only.

didLoadOrResizePlacementName

Returns the loaded placement with its updated height.

🚧

Best practice

Let Taboola SDK manage the cell, so that no event handling is required here

Otherwise - insert your resizing code (for both the WidgetWidget - A Taboola placement with a finite number of items (typically 1 - 3). and FeedFeed - A Taboola placement with an ongoing list of items (infinite scroll).) here.

- (void)classicUnit:(UIView *)classicUnit didLoadOrResizePlacementName:(NSString *)placementName height:(CGFloat)height placementType:(PlacementType)placementType {
    NSLog(@"%@", placementName);
    // If Taboola manages the UI (*recommended*), then NO special handling is required here.
    // Else - insert your code here.
}
func classicUnit(_ classicUnit: UIView!, didLoadOrResizePlacementName placementName: String!, height: CGFloat, placementType: PlacementType) {
    print("Placement name: \(String(describing: placementName)) has been loaded with height: \(height)")
    // If Taboola manages the UI (*recommended*), then NO special handling is required here.
    // Else - insert your code here.
}

πŸ“˜

Params

  • placementName - The name of the placement loaded/resized.
  • height - The height, in pixels, of the placement loaded/resized.
  • placementType - WidgetWidget - A Taboola placement with a finite number of items (typically 1 - 3). or FeedFeed - A Taboola placement with an ongoing list of items (infinite scroll)..

🚧

For a more detailed example, see: Advanced Options > Publisher manages the cell.

didFailToLoadPlacementName

The Taboola Unit failed to receive an ad.

- (void)classicUnit:(UIView *)classicUnit didFailToLoadPlacementName:(NSString *)placementName errorMessage:(NSString *)error {
    NSLog(@"%@", error);
    // Insert your code here...
}
func classicUnit(_ classicUnit: UIView!, didFailToLoadPlacementName placementName: String!, errorMessage error: String!) {
    print(error as Any)
    // Insert your code here...
}

πŸ“˜

Params

  • placementName - The name of the placement that failed.
  • error - The error message. (See below for possible values.)

Possible values for error:

Value

Description

NO_ITEMS

No Taboola content was returned.

WRONG_PARAMS

The wrong tb_mode was submitted.

RESPONSE_ERROR

TIMEOUT

A connectivity issue occurred.

UNKNOWN_ERROR

An unknown error occurred.

INTERNAL_1

An internal server error occurred.

scrollViewDidScrollToTopClassicUnit

When the user scrolls down in your app and encounters a Taboola FeedFeed - A Taboola placement with an ongoing list of items (infinite scroll)., the SDK automatically switches the scroll from your app to the Feed (i.e. to the Feed's web view). By default, this scroll switch is handled automatically by Taboola SDK, without any action on your part.

You can override this default behavior and implement the scroll switch yourself. For more detail, see: Advanced Options > Manual Scroll Switch.


πŸ’

🏻 Need a hand?

Go ahead! Ask a question in our Support Forum.

Tip: Provide as much detail as possible, including your platform and SDK version.


Did this page help you?