(function () {
'use strict';
//Check if share API is supported or not
if (navigator.share !== undefined) {
document.addEventListener('DOMContentLoaded', function() {
var shareBtn = document.querySelector('.share');
//Share button event listener
shareBtn.addEventListener('click', function(event) {
//Web share API
navigator.share({
title: document.title,
text: 'A simple pwa which works in offline, add to home screen and has a splash screen, push notifications, bg sync etc',
url: window.location.href
})
.then(function() {
console.info('Shared successfully.');
})
.catch(function (error) {
console.error('Error in sharing: ', error);
})
});
});
}
})();
© 2019 GitH
Created
November 3, 2019 17:34
-
-
Save adyontech/3b3ec8030f79bb0abed24f6f793314d8 to your computer and use it in GitHub Desktop.