Options
Menu

Class Device

Twilio Device. Allows registration for incoming calls, and placing outgoing calls.

Hierarchy

  • EventEmitter
    • Device

Index

Type aliases

Static ToggleableSound

ToggleableSound: Incoming | Outgoing | Disconnect

Names of all togglable sounds.

Constructors

constructor

Events

Static errorEvent

Static incomingEvent

  • incomingEvent(call: Call): void

Static registeredEvent

  • registeredEvent(device: Device): void

Static registeringEvent

  • registeringEvent(device: Device): void

Static tokenWillExpireEvent

  • tokenWillExpireEvent(device: Device): void
  • Emitted when the Device's token is about to expire. Use DeviceOptions.refreshTokenMs to set a custom warning time. Default is 10000 (10 seconds) prior to the token expiring.

    example

    device.on('tokenWillExpire', () => { const token = getNewTokenViaAjax(); device.updateToken(token); })

    Parameters

    Returns void

Static unregisteredEvent

  • unregisteredEvent(device: Device): void

Properties

Static defaultMaxListeners

defaultMaxListeners: number

Accessors

audio

calls

  • get calls(): Call[]

edge

  • get edge(): string | null

home

  • get home(): string | null

identity

  • get identity(): string | null
  • Returns the identity associated with the Device for incoming calls. Only populated when registered.

    Returns string | null

isBusy

  • get isBusy(): boolean

state

token

  • get token(): string | null

Static Private audioContext

  • get audioContext(): AudioContext | undefined

Static Private extension

  • get extension(): "mp3" | "ogg"

Static isSupported

  • get isSupported(): boolean

Static packageName

  • get packageName(): string

Static version

  • get version(): string

Methods

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

connect

destroy

  • destroy(): void

disconnectAll

  • disconnectAll(): void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

register

  • register(): Promise<void>
  • Register the Device to the Twilio backend, allowing it to receive calls.

    Returns Promise<void>

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this

Private toString

  • toString(): string

unregister

  • unregister(): Promise<void>
  • Unregister the Device to the Twilio backend, disallowing it to receive calls.

    Returns Promise<void>

updateOptions

  • updateOptions(options?: Options): void

updateToken

  • updateToken(token: string): void

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static runPreflight

Static Private toString

  • toString(): string

Generated using TypeDoc