Fetch Notifications
š© GetNotifications ā SDK API Documentation
š§ Overview
The getNotifications API is used to retrieve active REL-ID verification push notifications such as login or transaction requests. This is typically invoked when a user taps a notification bell or lands on the "Notifications" screen of the app. The SDK then fetches and returns any pending notifications from the server for rendering in the app.
šÆ Target Screen
The app should present a Notifications List Screen, showing login or transaction-related requests that require user attention. Each notification item can be tapped to view details or perform an action.
Notifications List Screen showing:
- Each notification item with message and date/time
- Action buttons if applicable (e.g., ā Accept / ā Reject / šØ Fraud)
- A refresh option to invoke
getNotifications()again
š§ APIs Involved
| API | Direction | Description |
|---|---|---|
getNotifications | App ā SDK | Requests notification data from server |
onGetNotifications | SDK ā App | Callback invoked with notification data payload |
š API to Call
Method: getNotifications(recordCount, enterpriseID, startIndex, startDate, endDate)
getNotifications(recordCount, enterpriseID, startIndex, startDate, endDate)| Parameter | Type | Description |
|---|---|---|
| recordCount | Number | Number of records to fetch. Use 0 to fetch all active notifications. |
| enterpriseID | String | Optional enterprise ID. Blank if not applicable. |
| startIndex | Number | Index to begin fetching from (must be ā„ 1). |
| startDate | String | Optional. Format: yyyy-MM-dd'T'HH:mm:ssz |
| endDate | String | Optional. Format: yyyy-MM-dd'T'HH:mm:ssz |
The response is delivered through the onGetNotifications event.
š” SDK Event: onGetNotifications
onGetNotificationsš§© Overview
The onGetNotifications event is emitted by the REL-ID SDK after the getNotifications API is called. It provides an array of notification objects that may require user action such as Accept, Reject, or Fraud report.
š¼ļø Sample Payload
{
"eMethId": 14,
"pArgs": {
"response": {
"ResponseData": {
"notifications": [
{
"notification_uuid": "abc123",
"ds_required": true,
"action_performed": "",
"expiry_timestamp": "2024-10-23T06:22:50UTC",
"create_ts": "2024-10-23T06:19:51UTC",
"actions": [
{ "label": "Accept", "action": "accept", "authlevel": "0" },
{ "label": "Reject", "action": "reject", "authlevel": "0" },
{ "label": "Fraud", "action": "fraud", "authlevel": "0" }
],
"body": [
{
"lng": "English",
"subject": "Device Activation",
"message": "You are attempting to activate a new device.",
"label": {
"Accept": "Accept",
"Reject": "Reject",
"Fraud": "Fraud"
}
}
]
}
]
}
}
}
}š§© Payload Fields
| Field | Type | Description |
|---|---|---|
notification_uuid | String | Unique identifier for the notification |
status | String | Final status of the notification: EXPIRED, UPDATED, TAMPERED, etc. |
signing_status | String | Signature validation status: Verified, Failed, NA |
action_performed | String | Action taken by user, e.g., Accept, Reject, Fraud |
update_ts | String | Timestamp of user action or system update (ISO format) |
create_ts | String | Time the notification was generated (ISO format) |
expiry_timestamp | String | Expiry time of the notification (ISO format) |
body | Array | Localized content (subject/message pairs), each with: |
ā lng | String | Language code of the message content (e.g., "English") |
ā subject | String | Notification title shown to the user |
ā message | String | Notification body message |
actions | Array | List of possible actions (rare in history; mostly used in active notif) |
ā label | String | Text to show on the button (e.g., "Accept") |
ā action | String | Action value (e.g., accept, reject) |
ā authlevel | String | Authentication level needed (usually "0" for most) |
ds_required | Boolean | Whether digital signature was required |
š Possible Values for actions
actions| Action | Description | Action to Take |
|---|---|---|
| Accept | User accepts the notification | Call updateNotification('Accept') |
| Reject | User rejects the notification | Call updateNotification('Reject') |
| Fraud | User marks it as fraudulent | Call updateNotification('Fraud') |
š Digital Signing (ds_required = true)
When a notification includes "ds_required": true, it indicates that digital signing is required before responding.
ā
The SDK automatically handles this signing process internally.
ā The developer does not need to perform any cryptographic signing manually.
Developer Responsibility:
- Display notification and action buttons (Accept/Reject/Fraud).
- Call
updateNotification(notification_uuid, action)based on user input.
ā”ļø SDK will perform the signing before sending the final response to the REL-ID gateway.
ā
Handling Success & Failure
- On success: Parse and display notifications.
- On failure: Use error code to show retry, login, or error message.
š² Code Snippets for getNotifications and onGetNotifications
getNotifications and onGetNotificationsš± React Native
// Trigger API
RdnaClient.getNotifications(0, "", 1, "", "", (syncResponse) => {
console.log("GetNotifications Sync Response:", syncResponse);
});
// Event Listener
RdnaClient.on(RdnaClient.onGetNotifications, (event) => {
console.log("onGetNotifications Event:", event);
});š± Flutter
// Trigger API
rdnaClient.getNotifications("0", "", "1", "", "");
// Event Listener
rdnaClient.on(RdnaClient.onGetNotifications, (data) {
print("onGetNotifications Event: $data");
});š± Cordova
// Trigger API
com.uniken.rdnaplugin.RdnaClient.getNotifications(
function(success) {
console.log("GetNotifications Success:", success);
},
function(error) {
console.error("GetNotifications Error:", error);
},
[0, "", 1, "", ""]
);
// Event is automatically handled in the success callbackš± Native Android
// Trigger API
RDNAError err = rdna.getNotifications(0, "", 1, "", "");
if (err.shortErrorCode != RDNAErrorID.RDNA_ERR_NONE.intValue) {
Log.e("SDK", "Error fetching notifications: " + err.errorString);
}
// Implement callback method for onGetNotifications in RDNACallbacks
@Override
public void onGetNotifications(JSONObject response) {
Log.d("SDK", "onGetNotifications: " + response.toString());
}š± Native iOS
// Trigger API
RDNAError* err = [rdna getNotifications:0 withEnterpriseID:@"" withStartIndex:1 withStartDate:@"" withEndDate:@""];
if (err.shortErrorCode != RDNA_ERR_NONE) {
NSLog(@"Error fetching notifications: %@", err.errorString);
}
// Implement callback method for onGetNotifications in RDNACallbacks
- (void)onGetNotifications:(NSDictionary *)response {
NSLog(@"onGetNotifications: %@", response);
}Updated 8 months ago
