React Native SDK
React Native SDK
Reflect SDK for React Native — mobile attribution, event tracking, deep linking, and SKAN. Native modules for iOS and Android.
Installation
npm install @reflect-sdk/react-native
# or
yarn add @reflect-sdk/react-nativeFor now, install from GitHub:
npm install github:bablu147/reflect-sdk-react-native#v1.1.0Then link native modules:
cd ios && pod installRequirements
- React Native >=0.71.0
- React >=18.0.0
- iOS 11.3+, Android (Google Play Services)
- Supports both Old Architecture (Bridge) and New Architecture (TurboModules)
Quick start
import { Reflect } from '@reflect-sdk/react-native';
// Initialize once at app startup
Reflect.initialize({
appKey: 'app_live_...',
companyKey: 'co_live_...',
baseUrl: 'https://api.reflect.cloud',
});API reference
| Method | Description |
|---|---|
Reflect.initialize(config) | Initialize the SDK |
Reflect.trackEvent(name, props?) | Track event with optional properties |
Reflect.trackRevenue(params) | Track revenue event |
Reflect.setUserId(userId) | Set user ID |
Reflect.clearUserId() | Clear user ID |
Reflect.setUserProperties(props) | Set user-level properties |
Reflect.setAdvertisingConsent(granted) | Grant/revoke IDFA/GAID consent |
Reflect.getInstallUuid() | Get persistent install UUID |
Reflect.getAttribution() | Get attribution data |
Reflect.updateConversionValue(...) | Update SKAN CV (iOS only) |
Reflect.getInitialDeepLink() | Get the deep link that opened the app |
Reflect.onDeepLink(listener) | Subscribe to deep link events (returns unsubscribe fn) |
Reflect.trackPurchase(params) | Track purchase with optional receipt data |
Reflect.trackSubscription(params) | Track subscription event |
Reflect.setGlobalProperty(key, val) | Set a property merged into every event |
Reflect.unsetGlobalProperty(key) | Remove a global property |
Reflect.clearGlobalProperties() | Remove all global properties |
Reflect.setAudience(...tags) | Tag install for audience segmentation |
Reflect.deleteUserData() | GDPR — delete all user data |
Reflect.setEnabled(enabled) | Enable/disable at runtime |
Reflect.flush() | Force-flush buffered events |
Event tracking
// Custom event
Reflect.trackEvent('level_complete', { level: 5, score: 12340 });
// Revenue
Reflect.trackRevenue({
amount: 4.99,
currency: 'USD',
productId: 'gems_500',
transactionId: 'txn_abc123',
});Deep linking
import { useEffect } from 'react';
import { Reflect } from '@reflect-sdk/react-native';
function App() {
useEffect(() => {
// Cold launch deep link
Reflect.getInitialDeepLink().then(data => {
if (data) navigate(data.path);
});
// Warm deep links
const unsub = Reflect.onDeepLink(data => {
navigate(data.path);
});
return unsub;
}, []);
}SKAN (iOS)
const result = await Reflect.updateConversionValue(42, 'high', false);
if (!result.success) console.warn('SKAN error:', result.error);Standard events (v1.1.0+)
import { signUpWith, levelCompleted, addedToCart, adShown } from '@reflect-sdk/react-native';
signUpWith('google');
levelCompleted(5, { score: 12340 });
addedToCart('gems_500', 4.99, 'USD');
adShown('interstitial', { network: 'admob' });Global properties & audience
Reflect.setGlobalProperty('ab_group', 'variant_b');
Reflect.setAudience('whale', 'early_adopter');Purchase & subscription
Reflect.trackPurchase({
productId: 'gems_500',
price: 4.99,
currency: 'USD',
receiptData: '<base64>',
});
Reflect.trackSubscription({
productId: 'pro_monthly',
price: 9.99,
currency: 'USD',
isTrial: true,
});Privacy (GDPR)
const deleted = await Reflect.deleteUserData();
// Clears local state + sends server deletion requestv1.1.0 — Feature parity with Unity
Standard event helpers, global properties, audience tagging, purchase/subscription tracking with receipt data, client-side event validation, crash capture, GDPR deletion. Native iOS (Obj-C++) and Android (Java) modules handle GAID, IDFA, ATT, SKAN 2/3/4, and AdAttributionKit.