Skip to main content

Platform API

caution

This page assumes the app developer is familiar with Regular SDK Guidelines – if that’s not the case, please make sure to review the official Regular SDK guide before you continue to this page.

Setup SDK

Make sure to initiate Outbrain SDK by calling initializeOutbrain() method with a partner key that is configured specifically for platforms (contact your AM or GTO for more details if needed). See example:

Outbrain.initializeOutbrain(withPartnerKey: "iOSSampleApp2023")

Create a Request

In order to generate a request for recommendations via the SDK, the app developer should create a new instance of OBPlatformRequest with the following mandatory params:

  1. widget id
  2. bundleUrl or portalUrl
  3. lang (for example: “en”)

See the bundleUrl constructor signature:

/**
* @brief A constructor for defining an OBRequest object.
*
* @param bundleUrl - The Bundle URL for the app that displays this widget - for platforms.
* @param lang - For language breakdown of the sources
* @param widgetId - a string ID (assigned by your account manager) for the widget in which content recommendations will be displayed.
*
* @note: If you have more than one widgetID on the same page, use widgetIndex to set the corresponding index on the page.
**/
+ (instancetype _Nonnull)requestWithBundleURL:(NSString * _Nonnull)bundleUrl lang:(NSString * _Nonnull)lang widgetID:(NSString * _Nonnull)widgetId;

See the portalUrl constructor signature

/**
* @brief A constructor for defining an OBRequest object.
*
* @param portalUrl - for platforms - instead of URL of the of the page this will include the source representation logic or a page representing the activity
* @param lang - For language breakdown of the sources
* @param widgetId - a string ID (assigned by your account manager) for the widget in which content recommendations will be displayed.
*
* @note: If you have more than one widgetID on the same page, use widgetIndex to set the corresponding index on the page.
**/
+ (instancetype _Nonnull)requestWithPortalURL:(NSString * _Nonnull)portalUrl lang:(NSString * _Nonnull)lang widgetID:(NSString * _Nonnull)widgetId;

See example

let platformRequest = OBPlatformRequest(bundleURL: bundleUrl, lang: "en", widgetID: "SDK_1")

or

let platformRequest = OBPlatformRequest(portalURL: portalUrl, lang: "en", widgetID: "SDK_1")

Optional param – psub

psub is a property on OBPlatformRequest which publishers can set for an additional source breakdown available for platforms.

Fetch Recommendations

After OBPlatformRequest is created – the app developer can fetch recommendations by calling:

Outbrain.fetchRecommendations(platformRequest, this);