Step 1 — Add Zaap SDK to your project

To add Zaap SDK to your project you can use one of the solutions below.

Add as a dependency in your package.json

npm install -S zaap-sdk
# or
yarn add zaap-sdk

Import with a script tag in your HTML

<script src="<https://unpkg.com/zaap-sdk@latest/dist/index.js>" type="text/javascript"></script>

Step 2 — Ask permissions for notifications

Before sending a notification to your user you need to ask his permission.

Zaap.ZaapPlatform.registerForNotifications()
	.then(console.log)
	.catch(console.error)

registerForNotifications will return if the user allows push notifications. You can allow using the method below to know it.

Zaap.ZaapPlatform.isRegisteredForNotifications()
	.then(console.log)
	.catch(console.error)

Extra — Set the user external id

setExternalId will return the installation.

Zaap.ZaapPlatform.setExternalId('[email protected]')
	.then(console.log)
	.catch(console.error)

Extra — Get the installation

Zaap.ZaapPlatform.getInstallation()
	.then(console.log)
	.catch(console.error)