JS-Widget use for Mobile Apps is deprecated – Mobile Apps should use Outbrain Native SDKs.

If your Mobile App is using a different Outbrain technology, please consult with your account manager regarding the best upgrade path.

Please Note

Please read the following guide to choose the best tech option for your app: In-App JS-Widget guide

Integration Flow

Note: The best way to understand the new logic is by looking at our sample project: JSWidgetSampleApp

1) On the HTML page you should make sure the Outbrain Widget includes the following apps specific parameters:

data-ob-installation-type, data-ob-user-id, data-ob-app-ver, data-ob-installation-key

Example:

<div class="OUTBRAIN" data-src="http://DROP_PERMALINK_HERE"
data-widget-id="DROP_WIDGET_ID_HERE" 
data-ob-template="DROP_TEMPLATE_NAME_HERE" 
data-ob-installation-type="app_js_widget"
data-ob-user-id="GOOGLE_APPLE_ADVERTISING_ID"
data-ob-app-ver="DROP_APPLICATION_VERSION_HERE"
data-ob-installation-key="DROP_PARTNER_KEY_HERE"></div>

For the full explanation click here.



2) Integrate Outbrain SDK 2.0 into your app, as described here



3) Initialize Outbrain SDK on app launch via:
[OBBridge initializeOutbrainWithPartnerKey:YOUR_PARTNER_KEY];



4) On a recommendation click, first grab the URL the user clicked on via UIWebViewDelegate method



5) Next, check if it’s a paid recommendation by calling:
if ([OBBridge isOutbrainPaidUrl:request.URL])



6) Check if the paid recommendation should be opened with a WebView or (OBWebview or OBWKWebView) or with SFSafariViewController via [OBBridge shouldOpenInSafariViewController:request.URL]


Handle a Click on a Recommendation

Note: The best way to understand the new logic is by looking at our sample project: JSWidgetSampleApp, specifically look at file viewController.m – you will find a good example for the implementation in method:

webView:shouldStartLoadWithRequest:navigationType:

1) On a recommendation click grab the URL the user clicked on via UIWebViewDelegate method:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType

2) Check if it’s a paid recommendation by calling: + (BOOL) isOutbrainPaidUrl:(NSURL *)url;

For example:

if ([OBBridge isOutbrainPaidUrl:request.URL]) {
....
}

Handling a Paid Recommendation

Please note:
The paid recommendation flow below is applicable only if you are not using SFSafariViewController for all web content in your app.

If you are using UIWebView or WKWebView, Please make sure to follow Apple ATS guidelines for displaying web content: https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW35

For paid recommendations, you should check if the paid recommendation should be opened with a WebView or (OBWebview or OBWKWebView) or with SFSafariViewController.

// We just detect a click on Outbrain paid recommendation, let's see where we should open the ad
if ([OBBridge shouldOpenInSafariViewController:request.URL]) {
    [self openUrlInSafariVC:request.URL];
}
else {
    [self performSegueWithIdentifier: @"openAdSague" sender: request.URL];
}



Complete Code Sample:


- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if ([OBBridge isOutbrainPaidUrl:request.URL]) {
        
        // We just detect a click on Outbrain paid recommendation, let's see where we should open the ad
        if ([OBBridge shouldOpenInSafariViewController:request.URL]) {
            [self openUrlInSafariVC:request.URL];
        }
        else {
            [self performSegueWithIdentifier: @"openAdSague" sender: request.URL];
        }
        
        return NO;
    }
    
    return YES;
}

Open Recommendation in SFSafariViewController

Following the above example, you should be able to open some of the recommendation in SFSafariViewController. Please use the code sample below if needed:

- (void) openUrlInSafariVC:(NSURL *)url {
    if (SYSTEM_VERSION_LESS_THAN(@"9.0")) {
        [[UIApplication sharedApplication] openURL:url];
        
    }
    else {
        SFSafariViewController *sf = [[SFSafariViewController alloc] initWithURL:url];
        [self.navigationController presentViewController:sf animated:YES completion:nil];
    }
}

Using OBWebView

Please follow the instructions here


Handling Organic Recommendation

Navigate to the organic recommendation with a method of your choice