admin管理员组文章数量:1022679
I have a PWA app that correctly prompts users to add the app to their home screen. The problem is that IMHO this automatic behavior is bad user experience because 90% of the time, the prompt is perceived like an annoying popup and users just close it.
What I think is way better UX, would be for users to look for a way to "install the app", like in the footer of any page where you usually see "Download on Android" or "Get the app in the App Store" or, after some specific interactions some popup I CONTROL would appear WHEN I FEEL the user is sufficiently engaged with my app and might be interested into saving it to its home screen.
I have done some searches and I have not been able to find any way to trigger the "add to home screen" popup when I need to. Did I miss something? How do you prompt for "add to homescreen" a second or third time?
Looking for any solution on Android and iPhone.
I have a PWA app that correctly prompts users to add the app to their home screen. The problem is that IMHO this automatic behavior is bad user experience because 90% of the time, the prompt is perceived like an annoying popup and users just close it.
What I think is way better UX, would be for users to look for a way to "install the app", like in the footer of any page where you usually see "Download on Android" or "Get the app in the App Store" or, after some specific interactions some popup I CONTROL would appear WHEN I FEEL the user is sufficiently engaged with my app and might be interested into saving it to its home screen.
I have done some searches and I have not been able to find any way to trigger the "add to home screen" popup when I need to. Did I miss something? How do you prompt for "add to homescreen" a second or third time?
Looking for any solution on Android and iPhone.
Share Improve this question asked Apr 16, 2020 at 15:47 Jona RodriguesJona Rodrigues 9801 gold badge12 silver badges26 bronze badges 01 Answer
Reset to default 5From Provide a custom install experience:
To indicate your Progressive Web App is installable, and to provide a custom in-app install flow:
- Listen for the
beforeinstallprompt
event.- Save the
beforeinstallprompt
event, so it can be used to trigger the install flow later.- Alert the user that your PWA is installable, and provide a button or other element to start the in-app installation flow.
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent the mini-infobar from appearing on mobile
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
// Update UI notify the user they can install the PWA
showInstallPromotion();
});
Then markup the install option and handle user events to return the deferred prompt
buttonInstall.addEventListener('click', (e) => {
// Hide the app provided install promotion
hideMyInstallPromotion();
// Show the install prompt
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.oute === 'accepted') {
console.log('User accepted the install prompt');
} else {
console.log('User dismissed the install prompt');
}
})
});
I have a PWA app that correctly prompts users to add the app to their home screen. The problem is that IMHO this automatic behavior is bad user experience because 90% of the time, the prompt is perceived like an annoying popup and users just close it.
What I think is way better UX, would be for users to look for a way to "install the app", like in the footer of any page where you usually see "Download on Android" or "Get the app in the App Store" or, after some specific interactions some popup I CONTROL would appear WHEN I FEEL the user is sufficiently engaged with my app and might be interested into saving it to its home screen.
I have done some searches and I have not been able to find any way to trigger the "add to home screen" popup when I need to. Did I miss something? How do you prompt for "add to homescreen" a second or third time?
Looking for any solution on Android and iPhone.
I have a PWA app that correctly prompts users to add the app to their home screen. The problem is that IMHO this automatic behavior is bad user experience because 90% of the time, the prompt is perceived like an annoying popup and users just close it.
What I think is way better UX, would be for users to look for a way to "install the app", like in the footer of any page where you usually see "Download on Android" or "Get the app in the App Store" or, after some specific interactions some popup I CONTROL would appear WHEN I FEEL the user is sufficiently engaged with my app and might be interested into saving it to its home screen.
I have done some searches and I have not been able to find any way to trigger the "add to home screen" popup when I need to. Did I miss something? How do you prompt for "add to homescreen" a second or third time?
Looking for any solution on Android and iPhone.
Share Improve this question asked Apr 16, 2020 at 15:47 Jona RodriguesJona Rodrigues 9801 gold badge12 silver badges26 bronze badges 01 Answer
Reset to default 5From Provide a custom install experience:
To indicate your Progressive Web App is installable, and to provide a custom in-app install flow:
- Listen for the
beforeinstallprompt
event.- Save the
beforeinstallprompt
event, so it can be used to trigger the install flow later.- Alert the user that your PWA is installable, and provide a button or other element to start the in-app installation flow.
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent the mini-infobar from appearing on mobile
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
// Update UI notify the user they can install the PWA
showInstallPromotion();
});
Then markup the install option and handle user events to return the deferred prompt
buttonInstall.addEventListener('click', (e) => {
// Hide the app provided install promotion
hideMyInstallPromotion();
// Show the install prompt
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.oute === 'accepted') {
console.log('User accepted the install prompt');
} else {
console.log('User dismissed the install prompt');
}
})
});
本文标签: javascriptPWAPrompt for quotadd to home screenquot when I wantStack Overflow
版权声明:本文标题:javascript - PWA - Prompt for "add to home screen" when I want? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745575613a2156999.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论