ad-sdk-persona

1.5.2 • Public • Published

persona-adsdk

Installing the SDK

npm i ad-sdk-persona

Create a react component to display an Ad

import React, { Component } from 'react';
import AdDisplay from "ad-sdk-persona";

class MyComponent extends Component {
    constructor(props) {
        super(props);
        this.adDisplayed = false;
    }

    componentDidMount() {
        if (!this.adDisplayed) {
            const myAd = new AdDisplay("AIzaSyDj5IlXqxL_S_yW7HMsxWjk4Gh9OnVmgiA");
            myAd.display('my-ad-container', { backgroundColor: 'black', display: 'contents' });
            this.adDisplayed = true;
        }
    }

    render() {
        return (
            <div>
                <h1>Welcome to my website</h1>
                <div id="my-ad-container"></div>
            </div>
        );
    }
}

export default MyComponent;

Once the component is created import and use the component to display ad anywhere.

Initializing SDK

After importing the SDK from

import AdDisplay from "ad-sdk-persona";

create instance of AdDisplay

const myAd = new AdDisplay();

now call the display function

myAd.display(my-ad-container, style);

this contains two parameters

  • The first parameter refers to the container's ID to display the ad inside a particular div, argument typer 'string'
  • The second parameter refers to the styling of the ad div example
myAd.display('my-ad-container', { backgroundColor: 'black', display: 'contents' });

Readme

Keywords

none

Package Sidebar

Install

npm i ad-sdk-persona

Weekly Downloads

0

Version

1.5.2

License

ISC

Unpacked Size

7.88 kB

Total Files

3

Last publish

Collaborators

  • persona3