Types of events emitted by the widget
Here are a list of Meld events emitted by the widget, along with what each means and what to do with them.{ domain: "meld-connect", eventName: "init" }- Emitted when the widget initializes.
- Use this to know that the widget has been initialized so that you can track a session.
{ domain: "meld-connect", eventName: "debug" }- Emitted at various times with debug information. Examples include when your customer cancels an integrated service provider’s embedded widget or whenever your customer navigates to another screen within an integrated service provider’s embedded widget.
- This event is used by Meld for debugging. It is not necessary for you to listen to this event.
{ domain: "meld-connect", eventName: "error" }- Emitted when the widget encounters an error. This event will be accompanied by query-string metadata, containing
detailsandreasonkeys, as available. - This event tells you if a user runs into a service provider error while trying to connect to their bank. It is not necessary for you to listen to this event.
- Emitted when the widget encounters an error. This event will be accompanied by query-string metadata, containing
{ domain: "meld-connect", eventName: "connect_complete" }- Emitted once the internal API call to /connect/complete has finished. It will be accompanied by query-string metadata, containing:
- institutionId: Meld’s institution ID for the institution your customer chose to connect with
- institutionName: The name of the same institution
- accountCount: The number of accounts your customer has connected
- accounts: Where available, an array of connected accounts including details such as name, type, and mask; null otherwise
- This event tells you the connection has completed successfully, and you can close the widget. Note that the connection may still be aggregating (aka gathering data), but will still succeed with the widget closed as the user’s involvement is done.
- Emitted once the internal API call to /connect/complete has finished. It will be accompanied by query-string metadata, containing:
{ domain: "meld-connect", eventName: "cancel" }- Emitted when your customer cancels the widget.
- This event lets you know that the customer has decided to leave the widget without successfully completing a connection. Use this event to trigger closing the widget.
{ domain: "meld-connect", eventName: "handover" }- Emitted when the connect has been completed. This is a legacy event that has been made redundant by “connect_complete”.
- It is not necessary for you to listen to this event, in fact it is advised that you don’t, as “connect_complete” serves the same purpose.
Listening for Emitted Events
After your customer has successfully authenticated themselves, the Meld Connect Widget will emit an event indicating that the widget can now be closed and the connection will still succeed. On most platforms, this event will have adata object, which will contain a domain (always "meld-connect"), an eventName, and a metadata object (where appropriate). However, for iOS and Android, these events will be serialized into a string, in the format [<domain>]<eventName>?<&-delimited-metaData>.
If you wish to close the iframe at this point, you can capture the [meld-connect]connect_complete event. This can be done in a few different ways, depending on how you have embedded the widget.
Desktop / Mobile browser
If you have embedded the widget into a page running in a full web browser, you can make use of that browser’s addEventListener function:
onMessage function:
React
@JavascriptInterface interface, and add that to the webview. The name of the class is unimportant, but the Connect Widget knows to look for a namespace named Android that contains a function named postMessage, so those names are required.
WKWebView set up to handle callback messages. Configure a WKWebView with userContentController:
We recommend also capturing the following events to close the iframe when an error occurs, or your customer does not complete the authentication step.
[meld-connect]error— Emitted when the widget encounters an error[meld-connect]cancel— Emitted when your customer cancels the widget
connect_complete event, the widget flow is complete. After setting up a webhook configuration with Meld, you will receive the BANK_LINKING_CONNECTION_COMPLETED webhook notifying you of official connection completion, followed by the other aggregation-related webhooks that signal when account and transaction data is ready to be fetched from the Meld API.
See Retrieving Connection Data for next steps and more detail on loading account and transaction data.