A lightweight React Native sample application demonstrating Service Agent integration with Salesforce Agentforce SDK for both iOS and Android.
This sample app demonstrates how to integrate the Agentforce Mobile SDK with Service Agents in your React Native applications for both iOS and Android.
The Agentforce Mobile SDK empowers you to integrate Salesforce's trusted AI platform directly into your mobile applications. Service Agents provide AI-powered conversational experiences for customer support scenarios.
- Service Agent Configuration - Configure and initialize the SDK with Service Agent settings
- Full UI Experience - Use the pre-built chat interface provided by the Agentforce SDK
- Cross-Platform - Single codebase for both iOS and Android with native SDK integration
- Persistent Configuration - Settings are saved and restored automatically
- Conversation Continuity - Conversations persist across app launches
- Native Layer: Kotlin + Jetpack Compose
- Pattern: Singleton
AgentforceClientHolderfor lifecycle management - UI: Native
ServiceAgentConversationActivitywith Compose - SDK Integration: Service Agent mode with simplified credential provider
- Native Layer: Swift + SwiftUI
- Pattern: Singleton
ServiceAgentManagerfor lifecycle management - UI: Native
AgentforceConversationContainerwith SwiftUI - SDK Integration: Service Agent mode with simplified credential provider
- Framework: React Native + TypeScript
- Navigation: React Navigation
- Bridge: Native modules for SDK initialization and conversation launch
- Screens: Home, Settings, About
- Node.js 18+ and npm/yarn
- Git
- Android Studio
- Android SDK 24+
- Gradle 8.0+
- macOS
- Xcode 15+
- CocoaPods
- iOS 17.0+
# Clone the repository
git clone <repository-url>
cd AgentforceSDK-ReactNative
# Install JavaScript dependencies
npm install# Run iOS setup script (installs pods)
node installios.js
# Run on iOS
npm run ios# Android setup is automatic with Gradle
# Just run the app directly
npx react-native run-androidWhen you first launch the app, navigate to Settings and configure:
-
Service API URL (required)
- Your Salesforce instance URL
- Example:
https://your-domain.my.salesforce.com
-
Organization ID (required)
- Your 15 or 18 character Salesforce Org ID
- Example:
00D000000000000
-
ES Developer Name (required)
- The API name of your Einstein Service Agent
- Example:
Your_Service_Agent_Name
-
Save the configuration
- From the Home screen, tap Launch Agentforce
- The SDK will initialize with your configuration
- Native conversation UI will appear
- Start chatting with your Service Agent!
AgentforceSDK-ReactNative/
βββ src/ # React Native JavaScript/TypeScript
β βββ screens/
β β βββ HomeScreen.tsx # Home screen with launch button
β β βββ SettingsScreen.tsx # Service Agent configuration
β β βββ AboutScreen.tsx # App information
β βββ services/
β β βββ AgentforceService.ts # Bridge wrapper for native modules
β βββ types/
β βββ agentforce.types.ts # TypeScript types
βββ android/ # Android native code
β βββ app/src/main/
β βββ java/.../agentforce/
β β βββ AgentforceModule.kt # RN bridge
β β βββ AgentforceClientHolder.kt # Singleton manager
β β βββ ServiceAgentConversationActivity.kt # Compose UI
β β βββ ServiceAgentCredentialProvider.kt # Auth
β βββ AndroidManifest.xml
βββ ios/ # iOS native code
β βββ ReactAgentforce/
β βββ Agentforce/
β β βββ AgentforceModule.swift # RN bridge
β β βββ AgentforceModule.m # ObjC bridge
β β βββ ServiceAgentManager.swift # Singleton manager
β β βββ ServiceAgentCredentialProvider.swift # Auth
β βββ AppDelegate.h
β βββ AppDelegate.m
βββ App.tsx # Root component with navigation
# Start Metro bundler
npm start
# In another terminal, run Android
npx react-native run-android
# View logs
npx react-native log-android# Start Metro bundler
npm start
# In another terminal, run iOS
npm run ios
# View logs
npx react-native log-ios- React Native Debugger: Use Flipper or React Native Debugger
- Native Android: Use Android Studio logcat
- Native iOS: Use Xcode console
- JavaScript logs: Check Metro bundler output
-
Configuration Test
- Open Settings
- Fill in all Service Agent fields
- Save and verify success message
-
Initialization Test
- Return to Home screen
- Tap "Launch Agentforce"
- Verify "Initializing..." message appears
-
Conversation Test
- Wait for conversation UI to load
- Send a test message
- Verify response from Service Agent
-
Error Handling Test
- Try launching without configuration
- Verify appropriate error message
Pod install fails
cd ios
pod deintegrate
pod cache clean --all
pod install --repo-updateBuild fails in Xcode
# Clean build folder
cd ios
xcodebuild clean -workspace ReactAgentforce.xcworkspace -scheme ReactAgentforce
# Rebuild
npm run iosGradle sync fails
cd android
./gradlew clean
./gradlew buildApp crashes on launch
- Check Android logcat:
npx react-native log-android - Verify SDK dependencies in
build.gradle - Ensure minimum SDK version is 24+
Metro bundler errors
npm start -- --reset-cacheNavigation not working
- Verify
react-native-gesture-handleris imported inindex.js - Check that
GestureHandlerRootViewwraps the app