- Updated: March 20, 2026
- 8 min read
Cross‑Platform React Native Explainability Widget for OpenClaw Rating API Edge
You can build a cross‑platform React Native explainability widget for the OpenClaw Rating API Edge by reusing the iOS and Android SDKs, wiring them through a native bridge, and deploying the final app with UBOS’s low‑code hosting platform.
🚀 Why AI Agents Like OpenClaw Are the Hottest Development Trend
In 2024‑2025 AI agents have moved from experimental labs to production‑ready services that can explain, audit, and improve every decision a model makes. OpenClaw’s Rating API Edge is a prime example: it delivers real‑time confidence scores and rationale for any LLM output, turning a black‑box into a transparent partner. For mobile developers, this means you can embed explainability directly into your apps, boosting user trust and compliance with emerging AI regulations.
React Native, with its single‑code‑base approach, is the perfect vessel for delivering this capability on both iOS and Android without duplicating effort. Below you’ll find a step‑by‑step guide that synthesizes the official iOS and Android SDK tutorials, adds a React Native bridge, and shows you how to ship the widget using host OpenClaw on UBOS.
1️⃣ Overview of OpenClaw Rating API Edge
The Rating API Edge provides three core endpoints:
- Score – Returns a numeric confidence value (0‑100).
- Rationale – Supplies a human‑readable explanation for the score.
- Trace – Gives a step‑by‑step log of the model’s reasoning path.
All endpoints are secured with API keys and support both synchronous HTTP calls and asynchronous streaming for low‑latency mobile experiences.
2️⃣ Summary of the iOS SDK Tutorial
The official iOS SDK is delivered as a Swift Package. Key steps from the tutorial include:
- Adding
OpenClawRatingSDKvia Xcode’s Swift Package Manager. - Configuring the
OCRatingClientwith your API key. - Calling
fetchScore(for:completion:)and handling theOCScoreResponseobject. - Parsing the
rationalestring for UI display.
Here’s a minimal Swift snippet from the tutorial:
import OpenClawRatingSDK
let client = OCRatingClient(apiKey: "YOUR_API_KEY")
client.fetchScore(for: "What is the capital of France?") { result in
switch result {
case .success(let response):
print("Score: \(response.score)")
print("Rationale: \(response.rationale)")
case .failure(let error):
print("Error: \(error.localizedDescription)")
}
}
3️⃣ Summary of the Android SDK Tutorial
The Android SDK is distributed as an AAR library and integrates via Gradle:
implementation "com.openclaw.rating:rating-sdk:1.2.3"Key Android steps:
- Instantiate
OpenClawRatingClientwith the API key. - Invoke
getScoreAsync(query, callback). - Handle
RatingResultwhich containsscoreandrationale.
Example Kotlin code:
import com.openclaw.rating.OpenClawRatingClient
val client = OpenClawRatingClient("YOUR_API_KEY")
client.getScoreAsync("Explain quantum entanglement") { result ->
result.onSuccess { rating ->
Log.d("OpenClaw", "Score: ${rating.score}")
Log.d("OpenClaw", "Rationale: ${rating.rationale}")
}.onFailure { error ->
Log.e("OpenClaw", "Error: ${error.message}")
}
}
4️⃣ Designing the Cross‑Platform React Native Architecture
To bridge the native SDKs with React Native we’ll create a native module for each platform and expose a single JavaScript API:
OpenClaw.getScore(query:string): Promise<{score:number, rationale:string}>- Internally, the iOS module forwards the call to
OCRatingClient. - The Android module forwards the call to
OpenClawRatingClient.
This design follows the MECE principle: each platform handles its own SDK, while the JavaScript layer remains agnostic.
5️⃣ Step‑by‑Step Implementation
5.1 Setting Up the React Native Project
Start with the latest React Native CLI (v0.74+). The following command creates a fresh project:
npx react-native init OpenClawWidgetNavigate into the folder and install the required dependencies:
cd OpenClawWidget
npm install @react-native-community/async-storage
We’ll also add Tailwind CSS for styling via tailwindcss-react-native:
npm install tailwindcss-react-native5.2 Integrating the iOS SDK
Open ios/OpenClawWidget.xcworkspace in Xcode and add the Swift Package:
- File → Swift Packages → Add Package Dependency.
- Enter
https://github.com/openclaw/rating-sdk-ios(replace with the real repo). - Select the latest version and finish.
Create a new Swift file OpenClawBridge.swift that conforms to RCTBridgeModule:
import Foundation
import OpenClawRatingSDK
@objc(OpenClawBridge)
class OpenClawBridge: NSObject {
private let client = OCRatingClient(apiKey: "YOUR_API_KEY")
@objc
func getScore(_ query: NSString, resolver: @escaping RCTPromiseResolveBlock,
rejecter: @escaping RCTPromiseRejectBlock) {
client.fetchScore(for: query as String) { result in
switch result {
case .success(let response):
let payload: [String: Any] = [
"score": response.score,
"rationale": response.rationale
]
resolver(payload)
case .failure(let error):
rejecter("E_OPENCLAW", error.localizedDescription, error)
}
}
}
@objc static func requiresMainQueueSetup() -> Bool { return false }
}
Don’t forget to expose the module to React Native by adding it to Podfile:
pod 'OpenClawRatingSDK', :git => 'https://github.com/openclaw/rating-sdk-ios.git'5.3 Integrating the Android SDK
Open android/app/build.gradle and add the AAR dependency:
dependencies {
implementation "com.openclaw.rating:rating-sdk:1.2.3"
}
Create a Java class OpenClawModule.java that implements ReactContextBaseJavaModule:
package com.openclawwidget;
import com.facebook.react.bridge.*;
import com.openclaw.rating.*;
public class OpenClawModule extends ReactContextBaseJavaModule {
private final OpenClawRatingClient client = new OpenClawRatingClient("YOUR_API_KEY");
public OpenClawModule(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return "OpenClaw";
}
@ReactMethod
public void getScore(String query, Promise promise) {
client.getScoreAsync(query, new RatingCallback() {
@Override
public void onSuccess(RatingResult result) {
WritableMap map = Arguments.createMap();
map.putInt("score", result.getScore());
map.putString("rationale", result.getRationale());
promise.resolve(map);
}
@Override
public void onFailure(Throwable t) {
promise.reject("E_OPENCLAW", t);
}
});
}
}
Register the module in OpenClawPackage.java and add the package to MainApplication.java:
public class OpenClawPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Collections.singletonList(new OpenClawModule(reactContext));
}
// View managers omitted for brevity
}
5.4 Building the Explainability Widget UI
Now that the native bridge is ready, we can create a reusable React component. We’ll use Tailwind for quick styling.
import React, {useState} from 'react';
import {View, TextInput, Button, Text, ActivityIndicator} from 'react-native';
import {NativeModules} from 'react-native';
const {OpenClaw} = NativeModules;
export default function ExplainabilityWidget() {
const [query, setQuery] = useState('');
const [result, setResult] = useState(null);
const [loading, setLoading] = useState(false);
const fetchScore = async () => {
setLoading(true);
try {
const response = await OpenClaw.getScore(query);
setResult(response);
} catch (e) {
console.warn(e);
setResult({score: -1, rationale: 'Error fetching data'});
} finally {
setLoading(false);
}
};
return (
<View className="p-4 bg-white rounded-lg shadow">
<Text className="text-xl font-bold mb-2">OpenClaw Explainability</Text>
<TextInput
className="border border-gray-300 rounded p-2 mb-3"
placeholder="Enter your prompt"
value={query}
onChangeText={setQuery}
/>
<Button title="Get Score" onPress={fetchScore} disabled={loading} />
{loading && <ActivityIndicator className="mt-3" />}
{result && (
<View className="mt-4">
<Text className="font-medium">Score: {result.score}</Text>
<Text className="mt-2 text-gray-700">Rationale: {result.rationale}</Text>
</View>
)}
</View>
);
}
The component is fully functional on both platforms. You can now drop <ExplainabilityWidget /> into any screen of your app.
6️⃣ Deployment Tips for iOS and Android
When you’re ready to ship, follow these best‑practice steps:
- iOS: Use
fastlaneto automate code signing and App Store submission. Ensure theOpenClawRatingSDKis compiled withBitcodedisabled if your app does not need it. - Android: Generate a signed
.aabbundle and upload via the Google Play Console. EnableApp Bundle Signingfor optimal delivery. - Environment variables: Store the OpenClaw API key in
.envand inject it at build time usingreact-native-config. Never hard‑code secrets. - Testing: Run
detoxend‑to‑end tests on both simulators and real devices to verify the native bridge works under low‑memory conditions.
7️⃣ Testing and Validation
Effective testing covers three layers:
- Unit tests for the JavaScript wrapper using
jestandreact-test-renderer. - Native unit tests with
XCTest(iOS) andJUnit(Android) to validate SDK responses. - Integration tests that simulate real API calls against a sandbox OpenClaw endpoint.
Example Jest test for the widget:
import React from 'react';
import {render, fireEvent, waitFor} from '@testing-library/react-native';
import ExplainabilityWidget from '../ExplainabilityWidget';
jest.mock('react-native', () => {
const RN = jest.requireActual('react-native');
RN.NativeModules.OpenClaw = {
getScore: jest.fn().mockResolvedValue({score: 92, rationale: 'High confidence'}),
};
return RN;
});
test('displays score after button press', async () => {
const {getByPlaceholderText, getByText, queryByText} = render(<ExplainabilityWidget />);
fireEvent.changeText(getByPlaceholderText('Enter your prompt'), 'What is AI?');
fireEvent.press(getByText('Get Score'));
await waitFor(() => expect(queryByText('Score: 92')).toBeTruthy());
});
8️⃣ Conclusion & Next Steps
By combining the native iOS and Android SDKs with a lightweight React Native bridge, you can deliver a polished explainability widget that works everywhere—without sacrificing performance or security. The widget not only showcases OpenClaw’s Rating API Edge but also positions your app as a leader in responsible AI.
Ready to go live? Explore UBOS pricing plans to find a tier that matches your traffic, then host OpenClaw on a managed instance. Need a starter template? Check out the UBOS templates for quick start and adapt the code snippets above.
Stay ahead of the AI compliance curve—integrate explainability today and let your users see exactly why the model answered the way it did.
Explore more about UBOS:
For a visual walkthrough of OpenClaw setup, watch this tutorial:
Full OpenClaw Setup Tutorial: Step‑by‑Step Walkthrough (Clawdbot)