Demo

Download the demo

A full demo is available for download at https://github.com/mioko-tech/presence-demo. The demo includes all code you need to see Presence working locally, including as a docker-compose.yml file to run a local HTTPS container. Once downloaded, there are two pieces of config you need to update, the first of which is the UUID and public key inside index.html:

const myUser = new PresenceUser('exampleuser001', 'pk_test_123456');

You can set the UUID to whatever value you would like, however note that this will be stored in your Presence account and also visible to your users. The format this is stored in and displayed is [UUID]-[Domain name], for example exampleuser001-example.com. You need to set the public key to the key from your Presence account under the 'Domains & API keys' screen.

Once that config is updated, you will need to serve the index.html file over HTTPS, because Web Authentication is only supported over HTTPS. The included docker-compose.yml allows you to do this quickly and easily. If you are a Mac user, you will also need to update the docker-compose.yml file to use the name of your Mac (which can be found in System Preferences > Sharing):

...
environment:
    STAGE: 'local'
    DOMAINS: '0.0.0.0, [your Mac name].local, localhost'
volumes:
    - ./:/var/www/vhosts/0.0.0.0
    - ./:/var/www/vhosts/[your Mac name].local
    - ./:/var/www/vhosts/localhost

Once that config is updated, in your terminal simply cd to the downloaded demo directory and run:

docker-compose up

You will need Docker installed in order to run this command.

Congratulations! You are now running a demo page available locally at https://0.0.0.0:8181/ which is also accessible from iPhone and Android devices.

Last updated