0

I have created an LWC component with just one button and on click of that button I am trying to show notification using ShowToastEvent, This is working fine on desktop but not working in SF mobile app.

HTML File

</div>

Js File

import { LightningElement } from 'lwc'; import { ShowToastEvent } from 'lightning/platformShowToastEvent';

export default class ToastNotificationOnMobile extends LightningElement {

handleClick(){
    this.dispatchEvent(
        new ShowToastEvent({
                title: 'Success',
                message: 'Welcome',
                variant: 'success',
                mode : 'dismissable'
        }),
    );
}

}

0

2 Answers 2

4

It is because toast is not available for Mobile App


If you check the documentation, it says that toast is just available for Lightning Experience (one container) only

enter image description here


Comparatively, when you check the docs of pill, it is available for all containers - Lightning Experience, Lightning Communities, Salesforce Mobile App, Standalone Lightning App

enter image description here

2

Toast doesn't work in the Salesforce Mobile App container so the only way is to make a custom toast check out this link incase you need

https://newstechnologystuff.com/2019/03/16/custom-toast-component-in-lightning-web-components/

Events belonging to the force namespace are not supported in Salesforce Mobile App container and If you see the aura code for toast you will see toast originates from force namespace, so my guess is that in the backend they didn't redo the code

var toastEvent = $A.get("e.force:showToast");

https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.migrate_map_aura_lwc_components

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .