File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,30 @@ <h2>godwin@sdb3.org</h2>
6767 console . log ( "Received the onEmbeddedMessagingBusinessHoursEnded event…" ) ;
6868 console . log ( "Event detail: " , event . detail ) ;
6969 } ) ;
70+
71+ // Listen for visibility changes
72+ document . addEventListener ( 'visibilitychange' , ( ) => {
73+ if ( document . visibilityState === 'hidden' ) {
74+ // Call the API when the page is hidden
75+ embeddedservice_bootstrap . userVerificationAPI
76+ . clearSession ( true )
77+ . then ( ( ) => {
78+ // ✅ Success handling
79+ console . log ( 'Session cleared successfully.' ) ;
80+ embeddedservice_bootstrap . utilAPI . removeAllComponents ( ) ;
81+ console . log ( 'Removed components successfully.' ) ;
82+ debugger ;
83+ } )
84+ . catch ( error => {
85+ // ❌ Error handling
86+ console . error ( 'Error clearing session:' , error ) ;
87+ } )
88+ . finally ( ( ) => {
89+ // 🛡️ Code that should run regardless of outcome
90+ console . log ( 'clearSession finished (success or error).' ) ;
91+ } ) ;
92+ }
93+ } ) ;
7094 </ script >
7195 < script type ='text/javascript '>
7296 function initEmbeddedMessaging ( ) {
You can’t perform that action at this time.
0 commit comments