Blow some breath to your app with Chabok realtime messaging and receive push notifications cross any platform with zero code. Know your users's better, push them content based on their location or track their presence/location without headache. Chabok helps mobile application marketers to optimize their acquisition campaigns and increase user engagement & retention.
npm i @chabok/web-sdk
Chabok SDK make use of javascript's promises. if you're targeting legacy browsers (IE etc.) and did not provide your own polyfill, you might want to include following script to polyfill window.Promise
in your clients' browser.
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script>
Or directly import using a bundler like Webpack:
import 'promise-polyfill/src/polyfill';
Initialize Chabok SDK:
import { Chabok } from '@chabok/sdk';
const chabok = new Chabok({
appId: '[application ID]',
secret: '[api secret key]',
logLevel: 'silent', // 'verbose' | 'warning' | 'error' | 'silent',
// optional
push: {
publicKey: '[vapid public key]',
},
});
await chabok.init()
const user = chabok.getUser()
Note:
CallingChabok.init()
each time the user visits the website is required.
Note:
The application credentials (appId
andsecret
) are can be found in you dashboard.
await chabok.enablePush();
Note:
CallingChabok.init()
each time the user visits the website is required.
const profile = {
firstName: 'John',
lastName: 'Doe',
phoneNumber: '989121234567',
gender: 'male', // male, female, other
email: 'john@company.com',
birthDate: 1685015036582, // must be a timestamp
}
await chabok.profile(profile);
Set an attribute:
await chabok.attribute('eyeColor', 'brown');
Unset an attribute:
await chabok.attribute('eyeColor', null);
Log in a user:
await chabok.login('username');
Logout a user:
await chabok.logout();
const tags = ['tag1', 'tag2', 'tag3'];
await chabok.setTags(tags);
const tags = ['tag1', 'tag2', 'tag3'];
await chabok.unsetTags(tags);