How to connect your game

Getting started with Connect for Web

Pointvoucher Connect provides a simple API for connecting your game to the Pointvoucher platform. You can prepare for this integration in three easy steps.

  • Contact Pointvoucher to obtain a unique Connect API key for your game.
  • Download the latest version of the script (which is not on npm just yet). The download link is in development 👀
  • Place the script somewhere in your game projects scripts folder.

The script declares a global object PvConnect that you can initialize with your game details and a callback function.

// import the script
  Object.assign(document.createElement('script', {
    src: '/scripts/pointvoucher-connect.js',
    onload: myinit,
    async: true,

function myinit() {

  // log any errors
  PvConnect.onError(e => console.error(e.message));

  // initialize Connect
    api_key: "eyJhbGciOiJIUzI1Ni...",
    app_name: "My Addictive Game",
    app_icon_url: "'data:image/png;base64,iVBORw0KGgoAAAAN...",
  }, () => {

    // trigger first action

Once initialized, you can at any time invoke the action method to trigger a user facing notification message. The method takes a context string and an optional callback as arguments. CONTEXT_TITLE_SCREEN may for example trigger a notification that invites the user to join Pointvoucher.

PvConnect.action(PvConnect.CONTEXT_TITLE_SCREEN, () => {
  console.log(`Let's play!`);

If provided, the callback gets invoked as soon as the user is done interacting with Connect, for example when the user swipes the invitation away or when the signup process has been completed. The SDK may also decide, not to show a notification at this point in time, in which case the callback gets invoked immediately. Connect adapts its behavior to the following contexts.

Used before the user presses Play. A notification may advertise the integration with Pointvoucher and invite the user to sign up.
Used in between game levels or some equivalent break in active gameplay. A notification may display points earned.
When the game ends, a notification may display points earned.

Remember that Connect may always decide, not to show a notification when the action method is called, for example when the user has accumulated zero voucher points since the last status update.

Pointvoucher supports all the latest browsers, but notably not Safari 10 or any version of Microsoft Edge released before 2020. The SDK itself will not throw exceptions in unsupported browsers. Instead, it will simply never display notifications and always execute your callback functions immediately. The Pointvoucher integration is in other words invisible to users of legacy browsers.

Edge 79+
Safari 11+


  • string context
  • Function callback

Instruct Connect to display an appropriate notification based on the given context. The optional callback is invoked when the notification gets dismissed or closes automatically.

  • Object config
  • Function callback

Initialize Connect whenever the user opens the game. The optional callback is invoked when initialization either succeeded or failed. Make sure to configure method onError to identify the cause of potential failure.

  • Function callback

Get an angle on potential errors since Connect is otherwise designed to fail silently. The callback receives an object with a message property.

  • Function callback

Open the user's account page via Pointvouchers website. The optional callback is invoked when the popup is closed.

  • Function callback

Open the voucher shop via Pointvouchers website. The optional callback is invoked when the popup is closed.