Xtremepush
Prerequisites
In order to
How to Install
- Go to Portal’s Control Panel -> Site Settings -> Embedded Code, and insert the snippet from Xtremepush to "HTML to add before the </head>" field <id> to ID from Xtremepush backoffice:
<!-- xtremepush -->
<script type="text/javascript">
(function(p,u,s,h,e,r,l,i,b) {p['XtremePushObject']=s;p[s]=function(){
(p[s].q=p[s].q||[]).push(arguments)};i=u.createElement('script');i.async=1;
i.src=h;b=u.getElementsByTagName('script')[0];b.parentNode.insertBefore(i,b);
})(window,document,'xtremepush','https://us.webpu.sh/<id>/sdk.js');
</script>
<script>
xtremepush('ready', () => {
xtremepush('push', 'auto_prompt', false);
xtremepush('event','on_site');
});
</script>
<!-- End xtremepush -->
- Go to Control Panel -> Tags Manager -> Tags, Click “Create Tag” and select “Custom JS”;
- Give it a name (e.g. “Xtremepush”), give a description;
- Assign a “On App Init” condition to this tag
- Insert the following contents of the Tag:
(() => {
function initializeXtremePushConnection() {
const data = Playtech.fetchUserDetails();
// set user_id
xtremepush('set', 'user_id', data.userId);
xtremepush('event', 'on_sign_in');
// set tags on the user
const properties = {
'advertiser': 'advertiser',
'age': 'age',
'ageVerificationStatus': 'age_verification_status',
'birthDate': 'birth_date',
'casinoName': 'casino_name',
'clientType': 'client_type',
'contactPreferences': 'contact_preferences',
'email': 'email',
'firstName': 'first_name',
'frozen': 'frozen',
'lastName': 'last_name',
'loginName': 'login_name',
'noBonus': 'no_bonus',
'previousLoginTime': 'previous_login_time',
'username': 'username',
'vipLevel': 'vip_level',
'wantMail': 'want_mail',
};
for (const [property, name] of Object.entries(properties)) {
xtremepush('tag', name, data[property]);
}
}
if (Playtech.API.auth.isLoggedIn) {
initializeXtremePushConnection();
}
Playtech.on('LOGGED_IN', initializeXtremePushConnection);
Playtech.on('LOGGED_IN_FAIL', () => xtremepush('event', 'failed_login'));
Playtech.on('LOGGED_OUT', () => xtremepush('event', 'on_sign_out'));
Playtech.on('DEPOSIT_COMPLETED', () => xtremepush('event', 'deposit_completed'));
Playtech.on('DEPOSIT_FAIL', () => xtremepush('event', 'deposit_fail'));
Playtech.on('GAME_LAUNCH', ([
{
launchType,
gameCode,
gameName,
gameFeed,
container
}
]) => xtremepush('event', 'game_launch', {
game: gameCode,
name: gameName
}));
const permission = xtremepush('push', 'permission');
const DISMISS_KEY = 'webpush_prompt_dismissed';
const wasAskedAlready = localStorage.getItem(DISMISS_KEY) === '1';
if (permission === 'default' && !wasAskedAlready) {
Playtech.on('LOGGED_IN', async () => {
await new Promise((resolve) => setTimeout(resolve, 3000));
Playtech.API.popup.showPopup('confirmation', {
content: 'Would you like to enable notifications?',
acceptBtnText: 'Enable',
onAccept: () => {
xtremepush('push', 'prompt', {
allowCallback: function () {
// register in IMS
const id = xtremepush('get', 'device_info')?.id;
if (id) {
Playtech.API.server.registerPushApplication({
pushId: 'xtremepush',
deviceId: id,
application: '<Application Name From IMS>'
});
}
},
blockCallback: function () {
// user clicked block button
},
dismissCallback: function () {
// user dismissed permissions dialog
}
});
},
onDecline: () => {
localStorage.setItem(DISMISS_KEY, '1');
}
});
});
}
})();
- Go to Control Panel -> Content Configuration -> Documents and Media, and create the following file in the Documents & Media:
/library/xtremepush/service-worker.js
with the following contents:
importScripts(decodeURIComponent(
location.search.substring(location.search.indexOf('ref=')+4)
));
- Log out from Control Panel and test out by logging in.