Discovery

    Discovery


    Article summary


    title: Discovery

    version: 1.0.0
    layout: default
    sdk: manage

    # Discovery Module

    Version Discovery 1.0.0

    Table of Contents

    Usage

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

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

    Overview

    Your App likely wants to integrate with the Platform's discovery capabilities. For example to add a "Watch Next" tile that links to your app from the platform's home screen.

    Getting access to this information requires to connect to lower level APIs made available by the platform. Since implementations differ between operators and platforms, the Firebolt SDK offers a Discovery module, that exposes a generic, agnostic interface to the developer.

    Under the hood, an underlaying transport layer will then take care of calling the right APIs for the actual platform implementation that your App is running on.

    The Discovery plugin is used to send information to the Platform.

    Localization

    Apps should provide all user-facing strings in the device's language, as specified by the Firebolt Localization.language property.

    Apps should provide prices in the same currency presented in the app. If multiple currencies are supported in the app, the app should provide prices in the user's current default currency.

    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. Discovery.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. Discovery.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. Discovery.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. Discovery.clear(id)

    See Listening for events for more information and examples.

    Events

    signIn

    function listen('signIn', (object) => void): Promise<number>
    

    See also: listen(), once(), clear().

    Event value:

    PropertyTypeDescription
    appIdstring

    Capabilities:

    RoleCapability
    managesxrn:firebolt:capability:discovery:sign-in-status

    Examples

    Default Example

    JavaScript:

    import { Discovery } from '@firebolt-js/manage-sdk'
    
    Discovery.listen('signIn', event => {
      console.log(event)
    })
    

    Value of event:

    {
    	"appId": "firecert"
    }
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Discovery.onSignIn",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": {
    		"appId": "firecert"
    	}
    }
    

    signOut

    function listen('signOut', (object) => void): Promise<number>
    

    See also: listen(), once(), clear().

    Event value:

    PropertyTypeDescription
    appIdstring

    Capabilities:

    RoleCapability
    managesxrn:firebolt:capability:discovery:sign-in-status

    Examples

    Default Example

    JavaScript:

    import { Discovery } from '@firebolt-js/manage-sdk'
    
    Discovery.listen('signOut', event => {
      console.log(event)
    })
    

    Value of event:

    {
    	"appId": "firecert"
    }
    
    JSON-RPC:Request:
    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"method": "Discovery.onSignOut",
    	"params": {
    		"listen": true
    	}
    }
    

    Response:

    {
    	"jsonrpc": "2.0",
    	"id": 1,
    	"result": {
    		"appId": "firecert"
    	}
    }
    


    Was this article helpful?

    What's Next