One line of code was enough for iOS. But I am having problem on android. I have attached the manifest.json file. There is only one button at the top. I want the application to write its name on the play store and show its logo. Code:
<button id="btnAdd"></button>
<script>
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
deferredPrompt = e;
btnAdd.style.display = 'block';
});
btnAdd.addEventListener('click', (e) => {
btnAdd.style.display = 'none';
deferredPrompt.prompt();
deferredPrompt.userChoice
.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log('User accepted the A2HS prompt');
} else {
console.log('User dismissed the A2HS prompt');
}
deferredPrompt = null;
});
});
</script>