OpenAD Protocol for LINE NEXT
  • Introduction
    • About
  • Getting Started
    • For Advertiser
      • Advertising Formats
      • Creating Your Ads Campaign
        • Banner Ads
        • Interactive Ads
      • Advertising Strategy Guide
      • Ad Campaign Management and Analytics
      • Payment Method
      • Advertiser Callback
    • For Volume Owner
      • Advertising Formats
      • Create Your Ad Placement
      • How to Integrate OpenAD
        • Create Banner Ads
        • Create Interactive Ads
      • Ad Slot Management and Analytics
      • How to Integrate APPs on More Platforms
        • Native JS APP
        • Direct Ajax Call for Native App
      • Troubleshooting
        • Prevention from 'Blocking'
        • Banners Not Delivering over SSL
  • Index
    • Approval
    • Glossary
    • About Us
  • Brand Kit
    • Logos
Powered by GitBook
On this page
  • Step #1. Load SDK
  • Step #2. Get Ad Info
Export as PDF
  1. Getting Started
  2. For Volume Owner
  3. How to Integrate APPs on More Platforms

Native JS APP

Instructions on how to integrate your codes into OpenAD Protocol for native JS APP.

This document provides instructions on how to access the SDK in native HTML (Games, etc.).


Step #1. Load SDK

#1. Load the SDK in the body of html, the code is as follows:

<body>
  <!--Your codes above-->
  <script
      name="openADJsSDK"
      version="3.0"  
      type="text/javascript" 
      src="https://protocol.openad.network/sdkloader.js">
  </script>
</body>

We recommend to add your application version number or release timestamp after JS to obtain the latest JS SDK for your application. E.g.,

https://protocol.openad.network/sdkloader.js?t=your-app-release-timestamp

https://protocol.openad.network/sdkloader.js?v=your-app-version

The script will pick OpenAD node for your end users, and load proper version of OpenAD SDK for you.

#2. Add DOM placeholder for Ad banner

<body>
  <!-- code before banner -->
  <div class="openADJsSDKBanner #your_style_class" 
       publisherld="49"
       zoneld="158">
  </div>
  <!-- code after banner -->
</body>

zoneld="158", 158 is a demo zoneld, please use your own "zoneId". publisherld="49", 49 is a demo publisherld, please use your own "publisherld" feel free to define your own banner style

OpenAD SDK will get ad banner for your end users and has it rendered in the DOM placeholder.

In traditional web applications, you can see OpenAD banner been rendered.

Step #2. Get Ad Info

Please embed the following code into the body.

<script type="text/javascript">
    window.addEventListener('DOMContentLoaded',  function() {
        window.openAdNative = {
            adInfo: {
               zoneId: 158, // please check your parameter zoneId
               publisherId: 49, // please check your parameter publisherId
               eventId: 0, // Reserved Parameter
            },
            adParams: {
                version: 'your-app-version', // optional
                TG: true, // optional, should be set if the application is TMA
            },
            // userInfo object
            // please add reasonable user IDs for your end users.
            // otherwise, OpenAD statistics may be inaccurate,
            // which may affect your incentives
            userInfo: {
                userId    : '', // user ID , If there is no data, please leave it blank
                firstName : '', // firstName or userId , If there is no data, please leave it blank
                lastName  : '', // lastName or userId , If there is no data, please leave it blank
                username  : '', // userName or userId , If there is no data, please leave it blank
            },
            // If the user is already logged in, initialize user data
            initUserInfo: function(data){
                this.userInfo.userId = data.userId;
                this.userInfo.firstName = data.firstName;
                this.userInfo.lastName = data.lastName;
                this.userInfo.username = data.username;
            },
            // Call SDK method to get advertising data
            getAD: function(){
                window.openADJsSDK.bridge.init({ userInfo: this.userInfo, adParams: this.adParams, adInfo: this.adInfo });
            },
            // Close AD
            destroy: function(adInfo){
              document.querySelector(`.openADJsSDKBanner[zoneId="${adInfo.zoneId}"][publisherId="${adInfo.publisherId}"]`).innerHTML = '';
            }
        };
    });
</script>

Event Callback

If the user is already logged in,

  1. Initialize user data (optional, not need to set in TMA)

window.openAdNative.initUserInfo(data);

  1. Get Ad Info

window.openAdNative.getAD();

  1. Close AD

window.openAdNative.destroy(window.openAdNative.adInfo);

PreviousHow to Integrate APPs on More PlatformsNextDirect Ajax Call for Native App

Last updated 28 days ago