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 OBPlatformsRequest constructor signature​

Please note, one of contentUrl, portalUrl or bundelUrl has to be an actual URL value.

public init(
widgetID: String,
widgetIndex: Int = 0,
contentUrl: String? = nil,
portalUrl: String? = nil,
bundelUrl: String? = nil,
lang: String? = nil,
psub: String? = nil
) {
super.init(url: nil, widgetID: widgetID, widgetIndex: widgetIndex)
self.contentUrl = contentUrl
self.portalUrl = portalUrl
self.bundleUrl = bundelUrl
self.lang = lang
self.psub = psub
}

See example​

let platformRequest = OBPlatformsRequest(widgetID:"SDK_1", widgetIndex: 0, contentUrl: nil, portalUrl: portalUrl, bundelUrl: nil, lang: "en", psub: "");

or

let platformRequest = OBPlatformsRequest(widgetID:"SDK_1", widgetIndex: 0, contentUrl: nil, portalUrl: nil, bundelUrl: bundelUrl, lang: "en", psub: "");

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(for: platformRequest) { response in

}