React Native Chat App
A feature-rich real-time chat application built with React Native, Expo, and Firebase. The app includes text messaging, image sharing, location sharing, and offline caching capabilities.
π Features
- Real-time Messaging: Instant chat with Firebase Firestore integration
- Image Sharing: Camera capture and photo library with Firebase Storage upload
- Location Sharing: GPS coordinates with interactive MapView display
- Offline Support: Local message caching with AsyncStorage for offline functionality
- Network Monitoring: Automatic connection status detection and Firebase network management
- Custom Chat UI: Built from scratch with FlatList, custom message bubbles, and responsive design
- Blob Conversion: Proper image-to-blob conversion for Firebase Storage uploads
- Cross-Platform: iOS, Android, and Web support through Expo
- Accessibility: Screen reader support and comprehensive accessibility features
- Action Sheet Integration: Native action sheets for media and location sharing options
π Prerequisites
Before you begin, ensure you have the following installed:
- Node.js (v16 or later) - Download here
- npm or yarn package manager
- Expo CLI (recommended) -
npm install -g @expo/cli
- Expo Go app on your mobile device
- Android Studio (for Android emulation) - Setup guide
- Xcode (for iOS development on macOS) - Setup guide
π§ Installation & Setup
1. Clone the Repository
git clone https://github.com/your-username/chat-app.git
cd chat-app
2. Install Dependencies
Run the following commands to install all required packages:
# Install main dependencies
npm install
# Install Expo-specific packages
npx expo install expo-location
npx expo install react-native-maps
npx expo install expo-image-picker
npx expo install @expo/react-native-action-sheet
# Install development dependencies
npm install --save-dev expo-module-scripts
3. Firebase Configuration
Option A: Use Mock Authentication (Default)
The app comes pre-configured with mock Firebase authentication for immediate testing.
Option B: Set Up Real Firebase (Production)
- Create a Firebase project at Firebase Console
- Enable Firestore Database and Storage
- Get your Firebase config object
- Replace the mock configuration in
firebase_web.js:
// firebase_web.js
const firebaseConfig = {
apiKey: "your-api-key",
authDomain: "your-project.firebaseapp.com",
projectId: "your-project-id",
storageBucket: "your-project.appspot.com",
messagingSenderId: "123456789",
appId: "your-app-id"
};
4. Environment Setup (Optional)
Create a .env file in the root directory:
EXPO_PUBLIC_FIREBASE_API_KEY=your-api-key
EXPO_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
EXPO_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
πββοΈ Running the Application
Start Development Server
# Run on Android
npx expo start --android
# Run on iOS
npx expo start --ios
# Run on Web
npx expo start --web
# Clear cache and start
npx expo start --clear
Alternative Port (if 8081 is busy)
npx expo start --port 8085
π± Testing the App
1. Basic Setup Test
- Start the development server
- Scan QR code with Expo Go or run in simulator
- Enter your name and background color on Start screen
- Navigate to Chat screen
2. Communication Features Testing
Text Messaging
- Type a message in the text input field
- Press βSendβ button or hit Enter key
- Verify message appears in custom chat bubble with proper styling
- Check real-time sync across multiple devices connected to same Firebase project
Image Sharing
- Tap the blue β+β button next to text input
- Select βChoose From Libraryβ or βTake Photoβ from action sheet
- Grant camera/photo permissions when prompted by the system
- Select image from library or capture new photo with camera
- Wait for image upload to Firebase Storage (blob conversion happens automatically)
- Verify image displays properly in chat bubble with 200x200 dimensions
- Test that image URLs are accessible and persistent
Location Sharing
- Tap the blue β+β button next to text input
- Select βShare Locationβ from action sheet menu
- Grant location permissions when prompted by the system
- Wait for GPS coordinates to be retrieved
- Verify interactive MapView appears in chat bubble showing your location
- Check that map displays correct coordinates with marker pin
- Test that location data persists in Firebase Firestore
Offline Testing
- Turn off internet connection
- Send messages (theyβll be cached locally)
- Reconnect to internet
- Verify messages sync to Firebase
3. Cross-Device Testing
- Run app on multiple devices
- Send messages from one device
- Verify real-time message delivery on other devices
- Test image and location sharing across devices
π Troubleshooting
Common Issues & Solutions
Metro Bundler Cache Issues
npx expo start --clear
rm -rf node_modules package-lock.json
npm install
Port Already in Use
# Kill processes on port 8081
npx kill-port 8081
# Or use alternative port
npx expo start --port 8086
TypeScript Configuration Warnings
The expo-location/tsconfig.json warning is cosmetic and doesnβt affect functionality. This is a known issue where the package references tsconfig.base instead of tsconfig.base.json. The app works perfectly despite this warning.
Firebase Connection Issues
- Check internet connection
- Verify Firebase configuration
- Check Firebase console for any service issues
- Review browser console for detailed error messages
Permission Errors (Camera/Location)
- Ensure youβre testing on a physical device or properly configured simulator
- Check device settings for app permissions
- Reinstall the app if permissions seem stuck
Android Studio Emulator Setup
- Install Android Studio
- Set up AVD (Android Virtual Device)
- Start emulator before running
npx expo start --android
π Project Structure
chat-app/
βββ components/
β βββ Start_firebase.js # Welcome screen with Firebase authentication
β βββ Chat_firebase.js # Main chat interface with custom UI
β βββ CustomActions.js # Action sheet for image/location sharing
β βββ Chat_simple.js # Simple chat implementation (backup)
β βββ Welcome.js # Additional welcome screen
βββ assets/
β βββ images/ # App icons and background images
β βββ background.jpg # Start screen background
βββ firebase_web.js # Firebase configuration and initialization
βββ App.js # Main navigation with ActionSheetProvider
βββ index.js # Entry point
βββ app.json # Expo configuration
βββ package.json # Dependencies and scripts
βββ README.md # This documentation
π§ Key Dependencies
{
"expo": "~54.0.27",
"react": "19.1.0",
"react-native": "0.81.5",
"firebase": "9.23.0",
"@react-navigation/native": "^7.1.24",
"@react-navigation/native-stack": "^7.8.5",
"@react-native-async-storage/async-storage": "2.2.0",
"@react-native-community/netinfo": "^11.4.1",
"expo-image-picker": "~17.0.9",
"expo-location": "~19.0.8",
"react-native-maps": "1.20.1",
"@expo/react-native-action-sheet": "^4.1.1"
}
π Deployment
Expo Application Services (EAS)
# Install EAS CLI
npm install -g eas-cli
# Build for production
eas build --platform all
# Submit to app stores
eas submit
Web Deployment
# Build for web
npx expo export --platform web
# Deploy to hosting service (Netlify, Vercel, etc.)
π€ Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Support
If you encounter issues:
- Check this README for common solutions
- Review logs in the Expo development tools
- Check Firebase Console for backend issues
- Visit Expo Documentation: https://docs.expo.dev/
- Firebase Documentation: https://firebase.google.com/docs
π Acknowledgments
Happy Chatting! π¬π±