Skip to content

Build

SDK reference

Every option, method and script-tag attribute.

What the script adds to your page

GlobalDescription
window.IungoAn object with init(options) and version. Always present once the script has loaded.
window.iungoClient()Returns the client the script tag created. Only exists when the script tag carries data-partner-key.

Iungo.init(options)

Creates a client. Use it when you want more control than the script-tag attributes give you, for example to place the window inline. It must run in a browser. If the options are wrong it throws an error that says what to fix.

javascript
const iungo = Iungo.init({
  partnerKey: 'pk_live_YOUR_KEY',
})
OptionTypeDefaultDescription
partnerKeystringrequiredYour partner key, pk_live_…. It identifies your site and is not a secret.
mode'modal' | 'inline''modal'A modal opens over the page. inline fills container.
containerElement | stringnoneFor inline: an element or a CSS selector. Required in that mode.
theme'light' | 'dark'iungo defaultForces the window's colour theme.
localestringnoneAccepted for the future. The window is English only for now.
zIndexnumber2147483000Stacking order of the modal.
draggablebooleantrueOn larger screens the visitor can drag the call window aside by its grab strip, and during a call the dimmed backdrop goes away so your page stays usable behind it. Phones always get a full-screen window. Set false to keep the window fixed and the page dimmed.
readyTimeoutMsnumber15000Advanced. How long to wait for the window to load before reporting EMBED_TIMEOUT. At least 1000.

The client

init and window.iungoClient() return the same kind of client.

MethodDescription
openCall()Opens the call window for your host: sign-up or log-in if needed, a top-up if the balance is low, then the call.
openSignup()Opens sign-up or log-in on its own.
openTopUp()Opens the wallet top-up on its own.
close()Closes the window. If a call is in progress the visitor is asked before it ends.
signOut()Signs the visitor out of iungo, whether or not the window is open. If it is closed, the SDK signs them out in a hidden frame and removes it. Visitors can also log out themselves with the “Log out” link inside the window.
on(type, handler)Listens for an event. Returns a function that stops listening.
off(type, handler)Stops listening.
isOpen()Whether the window is showing.
destroy()Removes everything the SDK added to your page.
versionThe SDK version, a string.

The methods that open the window return a promise. It resolves when the window has accepted the request and rejects with an IungoError, which has code, message and retryable. Always branch on code, never on message.

A custom button
const iungo = window.iungoClient()

document.querySelector('#talk').addEventListener('click', async () => {
  try {
    await iungo.openCall()
  } catch (error) {
    if (error.code === 'POPUP_BLOCKED') {
      alert('Please allow pop-ups for this site to pay.')
    } else {
      console.error(error.code, error.message)
    }
  }
})

Signing visitors out with your own site

A visitor's iungo session is kept inside the window, so logging out of your own site does not sign them out of iungo. Call signOut() when your site logs a user out, so the next person on a shared computer is not signed in as them:

javascript
// when your site logs its user out:
window.iungoClient()?.signOut().catch(() => {})

It rejects with EMBED_TIMEOUT if the window cannot load (for example on a website that is not registered), so catch the error if you do not need to react to it.

Script tag attributes

AttributeDescription
data-partner-keyRequired for the no-code setup. Your partner key.
data-themelight or dark.
data-draggableSet to false to turn off dragging (same as draggable).
data-ready-timeout-msAdvanced. Same as readyTimeoutMs.

Buttons use data-iungo-call, data-iungo-signup and data-iungo-topup. See Installation.

Versions

The SDK follows semantic versioning. Breaking changes only come with a new major version, and the window keeps working with older SDK versions, so you upgrade when you choose. Iungo.version tells you which one is running.

Something missing or unclear? Tell us.