React Native API Reference
Complete API reference for the Resync React Native SDK.
For the complete documentation including all methods and examples, see the React Native SDK Overview.
Core Methods
All core Resync methods are available in React Native, identical to the JavaScript SDK:
Initialization
Resync.init(options)- Initialize the SDK- See JavaScript SDK API Reference →
Remote Config
Resync.getConfig(key)- Get configuration value- See JavaScript SDK API Reference →
Campaigns
Resync.getVariant(campaignName)- Get campaign variant (for manual use)- Note: For rendering, use
ResyncCampaignViewcomponent instead! - See JavaScript SDK API Reference →
Events
Resync.logEvent(event)- Log custom event- See JavaScript SDK API Reference →
User Management
Resync.loginUser(userId, metadata)- Set user identifierResync.setUserAttributes(attributes)- Set user attributes- See JavaScript SDK API Reference →
Content
Resync.getContent()- Get all content views- See JavaScript SDK API Reference →
Forms
Resync.submitForm(formData)- Submit form data- See JavaScript SDK API Reference →
React Native Specific Components
ResyncCampaignView
Main component for rendering campaign variants.
Props:
interface ResyncCampaignViewProps {
name: string; // Campaign name
loadingComponent?: React.ReactNode;
errorComponent?: React.ReactNode;
emptyComponent?: React.ReactNode;
functionRegistry?: FunctionRegistry;
navigationRegistry?: NavigationRegistry;
logAnalytics?: LogAnalytics;
}
Example:
import { ResyncCampaignView } from 'resync-react-native';
<ResyncCampaignView
name="checkout_test"
functionRegistry={functionRegistry}
navigationRegistry={navigationRegistry}
/>
How it works:
- Automatically calls
getVariant()and tracks impression - Fetches the assigned variant's content view
- Renders it natively
- No manual variant logic needed!
ResyncContentView
Component for rendering regular content views (non-campaign).
Props:
interface ResyncContentViewProps {
name: string; // Content view name
loadingComponent?: React.ReactNode;
errorComponent?: React.ReactNode;
emptyComponent?: React.ReactNode;
functionRegistry?: FunctionRegistry;
navigationRegistry?: NavigationRegistry;
logAnalytics?: LogAnalytics;
}
Example:
import { ResyncContentView } from 'resync-react-native';
<ResyncContentView
name="WelcomeCard"
navigationRegistry={navigationRegistry}
functionRegistry={functionRegistry}
logAnalytics={logAnalytics}
/>
Type Definitions
FunctionRegistry
type FunctionRegistry = {
[key: string]: (data: any) => void | Promise<void>;
};
NavigationRegistry
interface NavigationRegistry {
navigate: (routeName: string, params?: any) => void;
push: (routeName: string, params?: any) => void;
goBack: () => void;
}
LogAnalytics
type LogAnalytics = (logId: string, event: any) => void;
Storage
For React Native, use AsyncStorage:
import AsyncStorage from '@react-native-async-storage/async-storage';
Resync.init({
// ...
storage: AsyncStorage,
});
Platform Compatibility
The SDK works on:
- ✅ iOS 12.0+
- ✅ Android 5.0+
- ✅ Expo (managed and bare workflows)
- ✅ React Native v0.64+
Important Notes
Campaign Rendering
❌ Don't do this:
// Manual variant handling (unnecessarily complex)
const variant = await Resync.getVariant('campaign_name');
if (variant === 101) {
return <VariantA />;
} else {
return <VariantB />;
}
✅ Do this instead:
// Automatic variant handling
<ResyncCampaignView name="campaign_name" />
When to Use getVariant()
Only use getVariant() manually if you need the variant ID for:
- Custom analytics
- Non-rendering logic
- JavaScript/web applications (no ResyncCampaignView available)
For React Native rendering, always use ResyncCampaignView.
More Information
For detailed method documentation, see the JavaScript SDK API Reference as all core methods are identical.
For component usage, see Components Documentation.
For practical examples, see Examples.