Session Timeout Notification
🧭 Overview
The onSessionTimeOutNotification
callback is invoked by the REL-ID SDK when a session timeout is imminent. This gives the app an opportunity to either alert the user or extend the session depending on timeout type and app policy.
🧩 Context of Use
Applications receive session timeout notifications through the onSessionTimeOutNotification
event. This payload includes:
timeLeftInSecond
– Time remaining before timeoutsessionCanBeExtended
– Boolean indicating if session can be extended
✅ Developer Options
Upon receiving the timeout notification, the developer can:
- ✅ Silently extend the session (if policy allows)
- ✅ Prompt the user with a UI (e.g., “Do you want to stay signed in?”)
- ❌ Ignore the notification, allowing the session to expire
🚀 How to Extend
To extend the session, call the extendSessionIdleTimeout
API only if sessionCanBeExtended = true
.
📩 Event Payload
Sample payload structure:
{
"userID": "ak1",
"message": "Your session will automatically end in 30. Please save your progress to avoid losing any changes.",
"timeLeftInSeconds": 30,
"sessionCanBeExtended": 1,
"info": {
"sessionType": 1,
"currentWorkFlow": "USER_LOGGED_IN"
}
}
📦 Relevant Fields
Field | Description |
---|---|
userId | The user ID associated with the session. |
message | A pre-formatted notification message based on the configured template. |
timeLeftInSecond | The exact time remaining in seconds before the session times out. |
sessionCanBeExtended | Indicates whether the session is extendable. true for idle timeouts, false for hard timeouts. |
info | Additional information including session type (app session/user session) for decision making. |
💻 Sample Code (Platform-Specific)
React Native
rdnaEventRegistery.addListener('onSessionTimeOutNotification', (data) => {
const status = data?.status;
const message = status?.statusMessage;
const timeLeft = status?.timeLeftInSecond;
const canExtend = status?.sessionCanBeExtended;
console.log("Session expired:", message);
console.log("Time left (s):", timeLeft);
console.log("Can session be extended?", canExtend);
// Navigate user to login screen or show session extension prompt
});
Flutter
rdnaClient.on(RdnaClient.onSessionTimeOutNotification, (event) {
var status = event['status'];
print("Session Timeout: ${status['statusMessage']}");
print("Time left: ${status['timeLeftInSecond']}s");
print("Session can be extended: ${status['sessionCanBeExtended']}");
// Redirect or prompt based on session type
});
Cordova
document.addEventListener('onSessionTimeOutNotification', function(event) {
const status = event.status;
console.warn("Session expired:", status.statusMessage);
console.warn("Time left:", status.timeLeftInSecond);
console.warn("Can extend:", status.sessionCanBeExtended);
// Prompt user to log in again or extend session
}, false);
Native Android
void onSessionTimeOutNotification(RDNARequestStatus status, RDNAError error) {
Log.w("REL-ID", "Session timeout: " + status.getStatusMessage());
Log.w("REL-ID", "Time left (s): " + status.getTimeLeftInSecond());
Log.w("REL-ID", "Can Extend: " + status.getSessionCanBeExtended());
// Handle session timeout logic (redirect or extend)
}
Native iOS
- (void)onSessionTimeOutNotification:(RDNARequestStatus *)status error:(RDNAError *)error {
NSLog(@"Session Timeout: %@", status.statusMessage);
NSLog(@"Time left: %ld", (long)status.timeLeftInSecond);
NSLog(@"Can Extend: %@", status.sessionCanBeExtended ? @"YES" : @"NO");
// Handle session cleanup and redirection
}
Updated 2 months ago