@solveo-ai/react-native
v0.2.0
Published
React Native SDK for Solveo AI platform
Maintainers
Readme
@solveo-ai/react-native
React Native SDK for the Solveo AI platform. Build AI-powered chat experiences in your mobile apps.
Supports both React Native CLI and Expo projects.
Installation
npm install @solveo-ai/react-native @solveo-ai/sdk-core
# or
yarn add @solveo-ai/react-native @solveo-ai/sdk-coreReact Native CLI Setup
For projects created with react-native init or Expo Dev Clients:
# Install Firebase for push notifications
npm install @react-native-firebase/app @react-native-firebase/messaging
# Install AsyncStorage (already bundled with this SDK)
npm install @react-native-async-storage/async-storageFirebase Configuration:
Android:
- Download
google-services.jsonfrom Firebase Console - Place it in
android/app/ - Add the Google Services plugin to
android/app/build.gradle:apply plugin: 'com.google.gms.google-services' - Add classpath to
android/build.gradle:classpath 'com.google.gms:google-services:4.3.15'
- Download
iOS:
- Download
GoogleService-Info.plistfrom Firebase Console - Place it in your Xcode project
- Enable "Push Notifications" capability in Xcode
- Add to
ios/YourProject/AppDelegate.m:#import <Firebase.h> - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [FIRApp configure]; [UNUserNotificationCenter currentNotificationCenter].delegate = self; [application registerForRemoteNotifications]; return YES; }
- Download
Expo Setup
For Expo projects (including Expo Go):
npx expo install expo-notificationsNote: For push notifications in production, you'll need to configure Expo Application Services (EAS).
Quick Start
import { SolveoProvider, useChat } from '@solveo-ai/react-native';
// Wrap your app
function App() {
return (
<SolveoProvider
config={{
apiUrl: 'https://api.solveoai.io',
widgetId: 'your-widget-id',
}}
>
<ChatScreen />
</SolveoProvider>
);
}
// Use in any component
function ChatScreen() {
const { conversation, messages, sendMessage, createConversation } = useChat();
useEffect(() => {
createConversation();
}, []);
return (
<View>
{messages.map((msg) => (
<Text key={msg.id}>{msg.content}</Text>
))}
</View>
);
}Push Notifications
The SDK automatically detects which push notification system is available and uses the appropriate one.
Setup for React Native CLI
Follow the Firebase configuration steps above, then use the usePushNotifications hook:
import { usePushNotifications } from '@solveo-ai/react-native';
function ChatScreen() {
const { registerDevice } = usePushNotifications({
mode: 'widget',
conversationId: 'your-conversation-id',
autoRegister: true,
});
// Device will automatically register when permission is granted
}Setup for Expo
import { usePushNotifications } from '@solveo-ai/react-native';
function ChatScreen() {
const { requestPermission, registerDevice } = usePushNotifications({
mode: 'widget',
conversationId: 'your-conversation-id',
});
useEffect(() => {
requestPermission().then(granted => {
if (granted) {
registerDevice();
}
});
}, [requestPermission, registerDevice]);
}Development
From the repo root (monorepo), install and build:
# From platform root
npm install
npm run build --workspace=@solveo-ai/react-nativeOr from this package:
cd sdks/react-native
npm install
npm run buildThis produces dist/index.js, dist/index.mjs, and dist/index.d.ts. Type declarations are included; prepublishOnly runs the build before publishing so published packages include dist and types.
Documentation
See full documentation.
License
MIT
