Skip to main content
Version: Guardian v0.2.1

Provider Setup

Wrap your app root with GuardianProvider. This initializes the SDK and exposes it to all child components via the useGuardian hook.

App.tsx
import { GuardianProvider } from '@surtai/guardian-rn';

export default function App() {
return (
<GuardianProvider
apiKey="YOUR_API_KEY"
environment="production"
collectLocation={true}
>
<Navigation />
</GuardianProvider>
);
}

Provider Props

PropTypeDefaultDescription
apiKeystringrequiredYour Surt API key (API key)
environment'production' | 'sandbox''production'Backend environment
logLevel'debug' | 'info' | 'warn' | 'error' | 'none''warn'SDK log verbosity
collectLocationbooleanfalseEnable GPS collection (requires permissions)
collectWifiInfobooleanfalseEnable WiFi network details
collectSimCardInfobooleanfalseEnable SIM/carrier info (Android only)
collectCameraInfobooleanfalseEnable camera info

Option B: Imperative API

If you prefer not to use React context, call initialize() directly at app startup:

index.ts
import { GuardianSDK } from '@surtai/guardian-rn';

GuardianSDK.initialize('API keyxxx', {
environment: 'production',
logLevel: 'warn',
collectLocation: true,
});

useGuardian Hook

const {
isInitialized, // boolean - true after SDK is ready
verify, // (type, name?, options?) => Promise<VerificationResult>
setCustomer, // (id, name?, email?) => void
clearCustomer, // () => void
} = useGuardian();
warning

useGuardian() must be called inside a <GuardianProvider>. Calling it outside throws an error.

Troubleshooting

ErrorCauseFix
not_initializedverify() called before SDK is readyUse GuardianProvider or call initialize() at startup
useGuardian hook errorHook used outside providerWrap component tree with <GuardianProvider>
invalid_api_keyWrong or expired API keyVerify your API key key with Surt