and thank you in advance for any help. It is much appreciated.
Developing and app that has the root plus subdomains and sub directories. Example: store.websitename.com/store1 and store.websitename.com/store2. We have set it up for Dynamic URL and Dynamic icon. It does work if you install it manually using the 3 dots and then "add to home screen". When the PWA is loading, the notification at the bottom works, but it is not using the dynamic url. Once the page loads, the notification just disappears when you click it. It does not use the dynamic url code at that point. Here is the code:
window.addEventListener("beforeinstallprompt", (event: Event) => {
console.log("beforeinstallprompt is fired -- ", event);
const deferredPrompt = event as any;
console.log("deferredPrompt ===== ", deferredPrompt);
const installButton = document.getElementById("installButton");
console.log("installButton ===== ", installButton);
// Show the prompt when the user clicks the install button
installButton.addEventListener("click", () => {
console.warn("install button clicked");
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
deferredPrompt.userChoice.then((choiceResult: any) => {
console.log("choiceResult.outcome ===== ", choiceResult.outcome);
if (choiceResult.outcome === "accepted") {
console.log("User accepted the install prompt");
} else {
console.log("User dismissed the install prompt");
}
});
// Remove the event listener after the prompt is shown
// installButton.removeEventListener('click', this.addToHomeScreen);
});
});
We have also added a button at the top of the app called Install but it does not trigger the install popup. I think it is due to the above code not working. If you need any further information from me, please let me know. I appreciate your help,.
Tried to make PWA using dynamic URL and dynamic Icon. We expected the notification to come up on the bottom and use the dynamic URL and dynamic icon. What actually resulted was the PWA loads and as it is loading the notification pops up at the bottom, and if you click it, it uses the standard PWA save to home screen. If you wait till the PWA is loaded, the notification at the bottom disappears when you click it. Also, it does use the dynamic URL and dynamic Icon if you use the 3 dots and choose "Add to home screen".