Forum Academy Marketplace Showcase Pricing Features

Using javascript in bubble

Hi bubbles,
I am struggling with running a javascript.
I made my app completely PWA and Google chrome now triggers the( addbto home screen) message automatically .
I wanted to be able to trigger this message manually through a button and a workflow , as I am not an expert in java, I have been searching everywhere in the Internet but I don’t know why it doesn’t do anything.
So something like this for example
I do when button is pressed workflow> run javascript :
( installprompt.addEventListener(‘click’, (e) => {
triggerEvent.prompt();
//user response
triggerEvent.userChoice.then((response) => {
if (response.outcome === ‘accepted’) {
console.log(‘yes, please install’);
} else {
console.log(‘No thanks, I am good!’);
}
});
}); )

This is just example I tried a lot of different javascripts , I think that I need to write (function ) in the header script so my app can understand these codes ( I honestly don’t know).
I hope you understood what I mea .
Thanks in advance :relaxed:

Hi @husam.hamdy !

Give a look here. You will se the code and and a working example:

1 Like

I literally came cross this topic, my question is. Where should I put these codes.
This one for example:

Listen to install and store event as prompt

 const beforeInstallListener = e => {
        // Prevent Chrome 76 and later from showing the install prompt
        e.preventDefault();
        // Stash the event so it can be triggered later.
        dispatch(setAndroidDeferredPrompt(e));
        dispatch(showAndroidPromptDownload(true));
    };
    window.addEventListener("beforeinstallprompt", beforeInstallListener

This topic was automatically closed after 70 days. New replies are no longer allowed.