Pairing
Pair a React Native app with Ansight Studio through native automatic pairing, explicit payloads, saved configs, and host status listeners.
Use connect(null, options) for the default automatic flow.
const result = await Ansight.connect(null, {
clientName: "React Native App",
expectedAppId: "com.example.app",
});
if (!result.success) {
console.warn(result.message);
}
Automatic connection uses the native host connection configuration, including bundled developer config, remembered host profiles, saved config, and bundled config.
Host auto-probe uses the native iOS/Android remembered-host retry behavior.
When enabled and the runtime is active, it remembers previous host connections
and retries them so the app can reconnect after the host disappears and later
reappears. Probing pauses while a live session is connected and resumes after
reconnectDelayMilliseconds when that session is lost:
await Ansight.initializeAndActivate({
useNativeAllInOneDefaults: true,
hostAutoProbe: {
enabled: true,
initialDelayMilliseconds: 1000,
probeIntervalMilliseconds: 5000,
reconnectDelayMilliseconds: 10000,
clientName: "React Native App",
},
});
Use withoutHostAutoProbe() or set hostAutoProbe.enabled to false for
flows where reconnects should only happen after an explicit app action.
Explicit Payload
await Ansight.connect(pairingJson, {
clientName: "React Native App",
expectedAppId: "com.example.app",
hostAddressOverride: "192.168.1.20",
});
React Native does not expose an SDK-owned QR scanner or pairing sheet. Use your app’s scanner, document picker, paste sheet, or deep-link flow, then pass the scanned/imported payload to connect(...):
async function connectScannedPairingCode(pairingJson: string) {
const result = await Ansight.connect(pairingJson, {
clientName: "React Native App",
expectedAppId: "com.example.app",
});
if (!result.success) {
console.warn(result.message);
}
}
Saved Pairing
await Ansight.savePairingConfig(pairingJson, {
expectedAppId: "com.example.app",
});
await Ansight.clearSavedPairing();
await Ansight.clearCachedSession();
await Ansight.disconnect();
Status
const subscription = Ansight.addHostConnectionStatusListener(
(status, capabilities) => {
console.log(status.connectionState, capabilities.canClearSavedConfigs);
},
{ emitCurrent: true },
);
subscription.remove();
Use openSession(pairingPayload, options) only when you need the low-level direct session path. Prefer connect(...) for normal Studio sessions.