Event Listeners
Introduction
Sunlight SDK provides a set of event listeners that allow you to track and respond to various events that occur during the user's interaction with the SDK. These events can be used to enhance your application's functionality, provide a more responsive user experience, and gather valuable insights into user behavior.
App Closed Event
The app-closed
event is triggered when the user closes the Sunlight SDK interface. This could occur at any point during the card switch process, whether the user has completed the process or decided to exit prematurely.
To listen for the app-closed
event, you can add an event listener in your code as follows:
const sunlightConnect = SunlightConnect.initialize({...});
sunlightConnect.on('app-closed', function() {
// Your code here. For example:
console.log('The user has closed the Sunlight SDK interface.');
});
sunlightConnect.open();
In this example, the SunlightConnect.on
function is used to add an event listener for the app-closed
event. When the app-closed
event is triggered, the provided function is called. You can replace the console.log statement with your own code to perform whatever action is appropriate for your application.
Updated 4 months ago