Advertising

    Advertising


    Article summary


    title: Advertising

    version: 1.2.0
    layout: default
    sdk: manage

    # Advertising Module


    Version Advertising 1.2.0

    Table of Contents

    Usage

    To use the Advertising module, you can import it into your project from the Firebolt SDK:

    import { Advertising } from '@firebolt-js/manage-sdk'
    

    Overview

    A module for platform provided advertising settings and functionality.

    Methods

    listen

    To listen to a specific event pass the event name as the first parameter:

    listen(event: string, callback: (data: any) => void): Promise<number>
    

    Parameters:

    ParamTypeRequiredSummary
    eventstringYesThe event to listen for, see Events.
    callbackfunctionYesA function that will be invoked when the event occurs.

    Promise resolution:

    TypeDescription
    numberListener ID to clear the callback method and stop receiving the event, e.g. Advertising.clear(id)

    Callback parameters:

    ParamTypeRequiredSummary
    dataanyYesThe event data, which depends on which event is firing, see Events.

    To listen to all events from this module pass only a callback, without specifying an event name:

    listen(callback: (event: string, data: any) => void): Promise<number>
    

    Parameters:

    ParamTypeRequiredSummary
    callbackfunctionYesA function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

    Callback parameters:

    ParamTypeRequiredSummary
    eventstringYesThe event that has occured listen for, see Events.
    dataanyYesThe event data, which depends on which event is firing, see Events.

    Promise resolution:

    TypeDescription
    numberListener ID to clear the callback method and stop receiving the event, e.g. Advertising.clear(id)

    See Listening for events for more information and examples.

    once

    To listen to a single instance of a specific event pass the event name as the first parameter:

    once(event: string, callback: (data: any) => void): Promise<number>
    

    The once method will only pass the next instance of this event, and then dicard the listener you provided.

    Parameters:

    ParamTypeRequiredSummary
    eventstringYesThe event to listen for, see Events.
    callbackfunctionYesA function that will be invoked when the event occurs.

    Promise resolution:

    TypeDescription
    numberListener ID to clear the callback method and stop receiving the event, e.g. Advertising.clear(id)

    Callback parameters:

    ParamTypeRequiredSummary
    dataanyYesThe event data, which depends on which event is firing, see Events.

    To listen to the next instance only of any events from this module pass only a callback, without specifying an event name:

    once(callback: (event: string, data: any) => void): Promise<number>
    

    Parameters:

    ParamTypeRequiredSummary
    callbackfunctionYesA function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

    Callback parameters:

    ParamTypeRequiredSummary
    eventstringYesThe event that has occured listen for, see Events.
    dataanyYesThe event data, which depends on which event is firing, see Events.

    Promise resolution:

    TypeDescription
    numberListener ID to clear the callback method and stop receiving the event, e.g. Advertising.clear(id)

    See Listening for events for more information and examples.

    resetIdentifier

    Resets a user's identifier in the ad platform so that the advertising id that apps get will be a new value

    function resetIdentifier(): Promise<void>
    

    Promise resolution:

    Capabilities:

    RoleCapability
    managesxrn:firebolt:capability:advertising:identifier

    Examples

    Default Example

    JavaScript:

    import { Advertising } from '@firebolt-js/manage-sdk'
    
    let result = await Advertising.resetIdentifier()
    console.log(result)
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "Advertising.resetIdentifier",
      "params": {}
    }
    

    Response:

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": null
    }
    

    skipRestriction

    Set the value for AdPolicy.skipRestriction

    To get the value of skipRestriction call the method like this:

    function skipRestriction(): Promise<SkipRestriction>
    

    Promise resolution:

    SkipRestriction

    Capabilities:

    RoleCapability
    managesxrn:firebolt:capability:advertising:configuration

    Examples

    Default Example

    JavaScript:

    import { Advertising } from '@firebolt-js/manage-sdk'
    
    let result = await Advertising.skipRestriction()
    console.log(result)
    

    Value of result:

    'none'
    
    JSON-RPC:Request:
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "Advertising.skipRestriction",
      "params": {}
    }
    

    Response:

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": "none"
    }
    

    Additional Example

    JavaScript:

    import { Advertising } from '@firebolt-js/manage-sdk'
    
    let result = await Advertising.skipRestriction()
    console.log(result)
    

    Value of result:

    'none'
    
    JSON-RPC:Request:
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "Advertising.skipRestriction",
      "params": {}
    }
    

    Response:

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": "all"
    }
    

    To set the value of skipRestriction call the method like this:

    function skipRestriction(value: SkipRestriction): Promise<void>
    

    Parameters:

    ParamTypeRequiredDescription
    valueSkipRestrictiontrue
    values: 'none' \| 'adsUnwatched' \| 'adsAll' \| 'all'

    Promise resolution:

    Examples

    Default Example

    JavaScript:

    import { Advertising } from '@firebolt-js/manage-sdk'
    
    let result = await Advertising.skipRestriction('none')
    console.log(result)
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "Advertising.setSkipRestriction",
      "params": {
        "value": "none"
      }
    }
    

    Response:

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": null
    }
    

    Additional Example

    JavaScript:

    import { Advertising } from '@firebolt-js/manage-sdk'
    
    let result = await Advertising.skipRestriction('all')
    console.log(result)
    

    Value of result:

    null
    
    JSON-RPC:Request:
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "Advertising.setSkipRestriction",
      "params": {
        "value": "all"
      }
    }
    

    Response:

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": null
    }
    

    To subscribe to notifications when the value changes, call the method like this:

    function skipRestriction(callback: (value) => SkipRestriction): Promise<number>
    

    Promise resolution:

    number
    

    Examples

    Default Example

    JavaScript:

    import { Advertising } from '@firebolt-js/manage-sdk'
    
    let listenerId = await skipRestriction((value) => {
      console.log(value)
    })
    console.log(listenerId)
    

    Value of result:

    'none'
    
    JSON-RPC:Request:
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "Advertising.onSkipRestrictionChanged",
      "params": {
        "listen": true
      }
    }
    

    Response:

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": "none"
    }
    

    Additional Example

    JavaScript:

    import { Advertising } from '@firebolt-js/manage-sdk'
    
    let listenerId = await skipRestriction((value) => {
      console.log(value)
    })
    console.log(listenerId)
    

    Value of result:

    'none'
    
    JSON-RPC:Request:
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "Advertising.onSkipRestrictionChanged",
      "params": {
        "listen": true
      }
    }
    

    Response:

    {
      "jsonrpc": "2.0",
      "id": 1,
      "result": "all"
    }
    

    Events

    skipRestrictionChanged

    See: skipRestriction

    Types


    Was this article helpful?