Add to homescreen Event On Amp Analytics - analytics

I use PWA with AMP. I want to track users that clicked to Add To Homescreen button, but AMP doesnt allow custom javascripts. I use amp-analytics component. How can i trigger on PWA's "beforeinstallprompt" event on AMP ?

I'm not sure if this is possible at all. As you are well aware, AMP doesn’t allow custom JavaScript.
I've read about The Washington Post using PWA and AMP-HTML together at a certain extent using amp-install-serviceworker but not entirely sure if this is your use case.

Related

What is the correct way to control when/if to show tooltip in mobile app using react native?

I am writing a mobile app and when the user sees some screens of the app for the first time, I would like to show a tooltip, explaining some of the functionality.
For instance, the user navigates to the profile page, and I show a tooltip on the add icon, saying something like "you can add a photo here".
Obviously I dont want to show this tooltip every time the user navigates to the profile page, so what is the correct way of doing so? Is it via redux? Keeping some state like "tooltipWasShown"?
Or should I write a custom hook? Something which checks if the tooltip was shown? (this should happen again via redux I guess)
I dont think it is a unique problem, but I couldn't find any blog posts/examples of what is the way to implement it. Any suggestions are welcome!
You will need to use Async Storage for the save data about tutorial, if user reload app redux will be empty. Or will add isFirstEnter field to user in DB and then check this field

How to create a confirm dialog with office-js and react?

I'd like to write a simple confirm modal for my office excel addin written in React.
This doesn't work because window.confirm has been forbidden by officejs (cf this explanation).
onClick={() => { if (window.confirm('Are you sure you wish to delete this item?')) { this.handleClick(); } }}>
According to officeJS doc, I could use the dialog api but those dialogs are not modals, therefore don't match my usecase : I want the user to confirm the action before going further.
Is there another way ?
Thanks
There's a modal Fabric React dialog component. From what you say about your use case, it might be what you are looking for. The reference for it is here: Dialog component in Fabric React.
You could also use the Dialog API which what I have used. Make sure you add the url to your AppDomain in xml manifest.

Can a salesforce custom button have some javascript in it?

What is the current way to do a custom button with some js in it?
We are building a custom button that needs to be able to read from the current contact (email address, phone, mailing address), and run a few lines of js. (We also need to create a call record.)
But how/where is this done in salesforce these days?
This page doesn't point me anywhere:
https://help.salesforce.com/apex/HTViewHelpDoc?id=customize_enterprise.htm
And this explanation of the new method in Lightning isn't clear where the js lives:
https://developer.salesforce.com/forums/?id=906F0000000BWr4IAG
Where is the needed example/doc?
If you are using buttons on custom visualforce page there are no any problems with defining custom JS function for it. For example, if you use <apex:commandButton/> you can use such attributes as onclick, onkeydown, onkeyup and other. See more information in documentation.
If you are using buttons on object layouts, you can create custom button and chose executing of JS as a behavior, see attached screenshot.
If you mean some other cases, please, describe it.

salesforce: Is it possible to override Salesforce global search?

There's a search box on the top of Salesforce. Is it possible to override(re-implement) it? Like catching the click event, popping up dialog, or customizing the search result page...
I went over the Visualforce development guide, it seems I can't do this with Visualforce. Any suggestions?
You'd need to use custom sidebar components.
In one of them place javascript that will intercept the events from the global search -> and make that event invoke whatever you want.

how to create a custom splash page in salesforce?

Need to show a popup message in home page only for the first time a user logs into salesforce....
its more like a splash page.
it can be a jquery popup as well..
can i do it using a visualforce page ??? if yes, please give ur suggestions
can we do it using the sidebar component in salesforce ???
I thought of showing it using a sidebar component by keeping a custom field in user object...everytime he logs in i will check the custom field and the show the popup...since this popup will be shown only for the first time is there anyother better solution instead of querying the user object evertime..
thanks.
You can use window.open method of Javascript and for the sidebar provide your scroll option.
If you want to get fancy to have customized look you can just use jquery modal with some style on document ready.
We can use cookie to store if this is the first time or salesforce user object can tell you this is the first time

Resources