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

APIDirectionDescription
getNotificationsApp → SDKRequests notification data from server
onGetNotificationsSDK → AppCallback invoked with notification data payload


šŸ”— API to Call

Method: getNotifications(recordCount, enterpriseID, startIndex, startDate, endDate)

ParameterTypeDescription
recordCountNumberNumber of records to fetch. Use 0 to fetch all active notifications.
enterpriseIDStringOptional enterprise ID. Blank if not applicable.
startIndexNumberIndex to begin fetching from (must be ≄ 1).
startDateStringOptional. Format: yyyy-MM-dd'T'HH:mm:ssz
endDateStringOptional. Format: yyyy-MM-dd'T'HH:mm:ssz

The response is delivered through the onGetNotifications event.


šŸ“” SDK Event: 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

FieldTypeDescription
notification_uuidStringUnique identifier for the notification
statusStringFinal status of the notification: EXPIRED, UPDATED, TAMPERED, etc.
signing_statusStringSignature validation status: Verified, Failed, NA
action_performedStringAction taken by user, e.g., Accept, Reject, Fraud
update_tsStringTimestamp of user action or system update (ISO format)
create_tsStringTime the notification was generated (ISO format)
expiry_timestampStringExpiry time of the notification (ISO format)
bodyArrayLocalized content (subject/message pairs), each with:
→ lngStringLanguage code of the message content (e.g., "English")
→ subjectStringNotification title shown to the user
→ messageStringNotification body message
actionsArrayList of possible actions (rare in history; mostly used in active notif)
→ labelStringText to show on the button (e.g., "Accept")
→ actionStringAction value (e.g., accept, reject)
→ authlevelStringAuthentication level needed (usually "0" for most)
ds_requiredBooleanWhether digital signature was required

šŸŽ­ Possible Values for actions

ActionDescriptionAction to Take
AcceptUser accepts the notificationCall updateNotification('Accept')
RejectUser rejects the notificationCall updateNotification('Reject')
FraudUser marks it as fraudulentCall 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

šŸ“± 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);
}