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:
- Process the event data promptly to maintain responsiveness
- Display appropriate feedback to users based on the event data
- Implement proper error handling for any issues
- 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:
Field | Type | Description |
---|---|---|
threatId | Integer | Unique ID for the threat |
threatName | String | Name of the detected threat |
threatMsg | String | Human-readable message |
threatReason | String | Internal reason or metadata |
threatCategory | String | SYSTEM , APP , or NETWORK |
threatSeverity | String | LOW , MEDIUM , HIGH |
configuredAction | String | Usually "REPORT" |
shouldProceedWithThreats | Boolean | Indicates if app wants to continue despite threat |
rememberActionForSession | Boolean | Whether to remember decision for current session |
appInfo | Object | App-related info (populated for app threats) |
networkInfo | Object | Network-related info (for network threats) |
🧩 Sub-Objects
appInfo
appInfo
Field | Type | Description |
---|---|---|
appName | String | Threatening app's name |
appSha256 | String | SHA256 hash of app |
packageName | String | App package name |
networkInfo
networkInfo
Field | Type | Description |
---|---|---|
ssid | String | Wi-Fi SSID |
bssid | String | MAC address |
maliciousAddress | String | Malicious IP (if any) |
maliciousMacAddress | String | Malicious 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.
Updated about 1 month ago