Finally, to make things work you have to include our JavaScript SDK on your website.
{.toc}
{#include-manifest-file}
Include manifest.json at the top of your <head> tag.
- An error occurs if
manifest.jsonis included in<body>. - Your
<link rel="manifest" href="/manifest.json">must appear before any other<link rel="manifest" ...>in<head>, otherwise it will not be found.
{#include-sdk-file}
Include <script src="https://cdn.notimatica.io/sdks/latest/notimatica-sdk.js" async></script> in your <head> tag.
Dont' worry our JavaScript SDK is fully asynchronous and event-based so it won't affect page loading.
{#initialize-sdk}
Place a small peace of JavaScript code right below SDK call.
{.line-numbers}
var Notimatica = Notimatica || [];
Notimatica.push(['init', {
project: 'PROJECT_ID',
subdomain: 'SUBDOMAIN',
safariWebId: 'web.com.mydomain'
}]);You can find your Project ID and Subdomain in Dashboard → Projects (take me there). In case I've added Apple Safari support you need to add safariWebId parameter with your Apple Web Push ID.
Now let's see a real life working example:
{.line-numbers}
<head>
<link rel="manifest" href="/manifest.json">
<script src="https://cdn.notimatica.io/sdks/latest/notimatica-sdk.js" async></script>
<script>
var Notimatica = Notimatica || [];
Notimatica.push(['init', {
project: '08823592-135f-5576-9a91-f3a0675aa1d1',
subdomain: 'testdomain',
debug: true,
plugins: {
button: {
enable: true,
autorun: true,
position: 'bottom-right'
}
}
}]);
</script>
</head>
In this example we:
- Include
manifest.json - Include JavaScript SDK file
- Initialize SDK
- Set Project ID
- Set Subdomain
- Enable debug-mode to see error messages in Developer Tools Console.
- Enable Floating button plugin in the bottom right corner. For additional ease of web push opt-in process we've enabled autorun option.
Checkout more Examples & Tutorials as well as comprehensive documentation on JavaScript SDK with complete list of options.
When testing your project in sandbox (https://localhost), it may be helpful to run browser with additional flags to bypass a warning of invalid certificate. Here are tips:
- Chrome: Run Chrome with
--ignore-certificate-errorsflag. - Firefox and Safari: Both have built-in mechanisms to create exceptions for specific certificates.