onTerminateWithThreats

📱 Overview

The onTerminateWithThreats event is triggered when the REL-ID SDK detects critical security threats that require immediate termination of the SDK, resulting in the app being closed on the device.

Since the SDK is already terminated at this point, the client is not required to invoke the takeActionsOnThreats API in response to this event.



Purpose

  • Notifies your application about important REL-ID SDK events
  • Provides critical information through event parameters
  • Allows your application to respond appropriately
  • Ensures proper handling of asynchronous processes


🖥️ User Interface Requirements

When handling the onTerminateWithThreats event, mobile application developers should:

  1. Process the event data promptly to maintain responsiveness
  2. Display appropriate feedback to users based on the event data
  3. Implement proper error handling for any issues
  4. Consider both success and failure scenarios in your UI design

🔌 Event Handling

onTerminateWithThreats Event

React Native
// Import the necessary modules
import RdnaClient from 'react-native-rdna-client';

// This is an event handler, not a method to call directly
// Set up event listener for onTerminateWithThreats event
let onTerminateWithThreatsSubscription = rdnaEventRegistery.addListener(
  'onTerminateWithThreats', (response) => {
    // Handle the response
    console.log("onTerminateWithThreats event received:", response);
    // Implement your logic here
  }
);

// Don't forget to remove the event listener when component unmounts
componentWillUnmount() {
  onTerminateWithThreatsSubscription.remove();
}
Flutter
import 'package:flutter/material.dart';
import 'package:rdna_plugin/rdna_plugin.dart';

// This is an event handler, not a method to call directly
// Set up event listener for onTerminateWithThreats event
rdnaClient.on(RdnaClient.onTerminateWithThreats, onTerminateWithThreats);

// Define the callback function
void onTerminateWithThreats(RDNATerminateWithThreats response) {
  // Handle the response
  print("onTerminateWithThreats event received");
  // Implement your logic here
}
Cordova
// This is an event handler, not a method to call directly
// Set up event listener for onTerminateWithThreats event
document.addEventListener('onTerminateWithThreats', onTerminateWithThreats);

// Define the callback function
function onTerminateWithThreats(response) {
  // Handle the response
  console.log("onTerminateWithThreats event received:", response);
  // Implement your logic here
}
Native iOS
// Objective-C
// This is an event handler, not a method to call directly
// Implement the event handler method
- (void)onTerminateWithThreats:(RDNAChallengeResponse *)response {
    // Handle the response
    NSLog(@"onTerminateWithThreats event received");
    // Implement your logic here
}

// Swift
// This is an event handler, not a method to call directly
// Implement the event handler method
func onTerminateWithThreats(_ response: RDNAChallengeResponse) {
    // Handle the response
    print("onTerminateWithThreats event received")
    // Implement your logic here
}
Native Android
// This is an event handler, not a method to call directly
// Implement the event handler method
@Override
public void onTerminateWithThreats(RDNA.RDNAChallengeResponse response, RDNAError error) {
    // Handle the response
    Log.d("REL-ID", "onTerminateWithThreats event received");
    // Implement your logic here
}

Event Payload

The onTerminateWithThreats event provides information through its payload that your application needs to process. The structure may vary by platform but typically includes the following data:

Sample Payload

[
  {
    "threatId": 17,
    "threatName": "Developer Options",
    "threatMsg": "Device is insecure, developer option is enabled.",
    "threatReason": "",
    "threatCategory": "SYSTEM",
    "threatSeverity": "LOW",
    "configuredAction": "REPORT",
    "appInfo": {
      "appName": "",
      "appSha256": "",
      "packageName": ""
    },
    "networkInfo": {
      "ssid": "",
      "bssid": "",
      "maliciousAddress": "",
      "maliciousMacAddress": ""
    },
    "shouldProceedWithThreats": false,
    "rememberActionForSession": false
  }
]

Each threat is an object with the following structure:

FieldTypeDescription
threatIdIntegerUnique ID for the threat
threatNameStringName of the detected threat
threatMsgStringHuman-readable message
threatReasonStringInternal reason or metadata
threatCategoryStringSYSTEM, APP, or NETWORK
threatSeverityStringLOW, MEDIUM, HIGH
configuredActionStringUsually "REPORT"
shouldProceedWithThreatsBooleanIndicates if app wants to continue despite threat
rememberActionForSessionBooleanWhether to remember decision for current session
appInfoObjectApp-related info (populated for app threats)
networkInfoObjectNetwork-related info (for network threats)

🧩 Sub-Objects

appInfo

FieldTypeDescription
appNameStringThreatening app's name
appSha256StringSHA256 hash of app
packageNameStringApp package name

networkInfo

FieldTypeDescription
ssidStringWi-Fi SSID
bssidStringMAC address
maliciousAddressStringMalicious IP (if any)
maliciousMacAddressStringMalicious MAC (if any)

✅ What to Do Next

After receiving this event:

  • Present the threat(s) to the user.
  • Capture only the user's denial.

Until then, no other SDK API should be invoked.