Sonic JS SDK



Basic Responsibilities


1. API proxy - gets single or multiple campaigns 
2. Module load / initialize
3. Ad Unit load / initialize
4. Show/Hide/Re-size Ad Unit iFrame 
5. Communication with Ad Unit
6. Client callbacks / events 

PSEUDO Flow

1. SDK init will read and parse json config
2. SDK will load relevant modules
3. SDK will load the relevant ad unit iframe

Basic tag


       window.sonicAsyncInit = function() {
        sonicCore.init({
          appkey     : '{your-app-key}',
          userId     : '{your-user-id}'        });
      };

      (function(d, s, id){
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement(s); js.id = id;
         js.src = "//s.soniccdn.com/sdk.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'sonic-jssdk'));

As seen on Facebook JS SDK

Offer Wall Tag

       window.sonicAsyncInit = function() {
        sonicCore.init({
          appkey     : '{your-app-key}',
          userId     : '{your-user-id}'          offerWall: {                 // detailed settings json [TBD]          }        });
      };

      (function(d, s, id){
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement(s); js.id = id;
         js.src = "//s.soniccdn.com/sdk.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'sonic-jssdk'));

RTB Tag

       window.sonicAsyncInit = function() {
        sonicCore.init({
          appkey     : '{your-app-key}',
          userId     : '{your-user-id}'          interstitial: {              campaign:{                 // detailed campaign json [TBD]              },               width: 480, height: 320          }        });
      };

      (function(d, s, id){
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement(s); js.id = id;
         js.src = "//s.soniccdn.com/sdk.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'sonic-jssdk'));

INTERSTITIAL + MRAID

       window.sonicAsyncInit = function() {
        sonicCore.init({
          appkey      : '{your-app-key}',
          userId      : '{your-user-id}',          mraid       : true, // ad unit will enable injecting of mraid          interstitial: {
} }); }; (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//s.soniccdn.com/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'sonic-jssdk'));

Acting AS Mobile SDK Controller

       window.sonicAsyncInit = function() {
        sonicCore.init({
          appkey      : '{your-app-key}',
          userId      : '{your-user-id}',          mobileSdk   : true         });
      };

      (function(d, s, id){
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement(s); js.id = id;
         js.src = "//s.soniccdn.com/sdk.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'sonic-jssdk'));
mobileSdk - Indicates that we need to load the the following modules:
MRAID,  PreCache, MSG-ios, MSG-Android, etc..

More than One ad Unit in Config

       window.sonicAsyncInit = function() {
        sonicCore.init({
          appkey      : '{your-app-key}',
          userId      : '{your-user-id}',          interstitial: {                    },          offerwall:{
} }); }; (function(d, s, id){ // load sonic core asyncly }(document, 'script', 'sonic-jssdk'));

Discussions:


Precache
Separate deployment of server & client
aarki
Made with Slides.com