React Native SDK
TypeScriptFull-featured Appflow integration for React Native apps with TypeScript support.
The React Native SDK provides a TypeScript-first API for all Appflow v2 features. It wraps native iOS and Android functionality through bridge modules for platform-specific features (StoreKit 2, Google Play Billing, push notifications) while implementing analytics, remote config, and event tracking directly in JavaScript for maximum performance.
Installation
npm
npm install @appflow-ai/react-native
yarn
yarn add @appflow-ai/react-native
For iOS, run cd ios && pod install after installation.
Quick Start
App.tsx
import Appflow from '@appflow-ai/react-native';
// Initialize in your app entry point
Appflow.getInstance().configure('your_api_key', {
enableAutoTracking: true,
logLevel: 'info',
});
// Identify users
Appflow.getInstance().setUserId('user_123');
// Track events
Appflow.getInstance().track('tutorial_completed', {
step: 5,
duration: 120,
});Paywalls
PaywallScreen.tsx
import Appflow from '@appflow-ai/react-native';
async function showPaywall() {
const result = await Appflow.getInstance().presentPaywall('main_paywall');
switch (result.type) {
case 'purchased':
console.log('Purchased:', result.productId);
break;
case 'restored':
console.log('Purchases restored');
break;
case 'dismissed':
console.log('User dismissed paywall');
break;
case 'error':
console.error('Error:', result.message);
break;
}
}Remote Config
config-example.tsx
import Appflow from '@appflow-ai/react-native';
const appflow = Appflow.getInstance();
// Get typed config values with defaults
const showOnboarding = appflow.getBool('show_onboarding', true);
const maxRetries = appflow.getNumber('max_retries', 3);
const welcomeMsg = appflow.getString('welcome_message', 'Hello!');Push Notifications
push-setup.tsx
import Appflow from '@appflow-ai/react-native';
// Request permission and register token
const granted = await Appflow.getInstance().requestPushPermission();
if (granted) {
console.log('Push notifications enabled');
}
// Or set token manually (e.g., from Firebase)
Appflow.getInstance().setPushToken(fcmToken);Attribution & Deep Links
deep-links.tsx
import { Linking } from 'react-native';
import Appflow from '@appflow-ai/react-native';
// Handle deep links for attribution
Linking.addEventListener('url', ({ url }) => {
Appflow.getInstance().handleDeepLink(url);
});
// Handle initial URL (cold start)
const initialUrl = await Linking.getInitialURL();
if (initialUrl) {
Appflow.getInstance().handleDeepLink(initialUrl);
}Key Features
TypeScript-First
Full type safety with comprehensive type definitions
Auto-Tracking
Screen views, sessions, and app lifecycle tracked automatically
Offline Queue
Events persisted to AsyncStorage, synced when online
Native Bridges
StoreKit 2 and Google Play Billing via native modules
Server-Driven Paywalls
Native paywall rendering without app updates
Remote Config
Feature flags and A/B tests with typed getters
Requirements
React Native 0.72+, React 18+, iOS 16+ (for native module), Android API 24+ (for native module). The SDK uses @react-native-async-storage/async-storage for persistence.
Related Guides