A comprehensive React Native application demonstrating Firebase Push Notifications and Firebase Analytics integration with a beautiful, production-ready UI.
- β Foreground Notifications - Alert dialogs when app is active
- β Background Notifications - System notifications in notification bar
- β Notification Channels - Proper Android 8.0+ channel management
- β FCM Token Management - Easy token copying for testing
- β Local Notifications - Test notifications without server
- β Notification History - Track received notifications in-app
- β Event Tracking - Comprehensive user interaction analytics
- β Screen Views - Automatic screen tracking
- β User Properties - User segmentation support
- β Custom Events - Business-specific event logging
- β Real-time Testing - DebugView integration for live testing
- β Error Tracking - Analytics error monitoring
- β Modern Material Design - Clean, professional interface
- β Status Indicators - Real-time feature status display
- β Interactive Testing - Built-in test buttons for all features
- β Comprehensive Guides - In-app testing instructions
- β Responsive Layout - Works on all Android screen sizes
- React Native development environment set up
- Android Studio installed
- Firebase project created
- Physical Android device (recommended for push notifications)
- Clone the repository
git clone https://github.com/salmanazamdev/rn-firebase-complete
cd rn-firebase-complete
- Install dependencies
npm install
# or
yarn install
- Install required Firebase packages
npm install @react-native-firebase/app
npm install @react-native-firebase/messaging
npm install @react-native-firebase/analytics
npm install react-native-push-notification
-
Firebase Setup
- Create a Firebase project at Firebase Console
- Add Android app to your project
- Download
google-services.json
- Place it in
android/app/
directory - Enable Cloud Messaging and Analytics in Firebase Console
-
Android Configuration
Add to android/app/build.gradle
:
dependencies {
implementation 'com.google.firebase:firebase-messaging:23.1.0'
implementation 'com.google.firebase:firebase-analytics:21.5.0'
}
apply plugin: 'com.google.gms.google-services'
Add to android/build.gradle
:
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.4.0'
}
}
- Run the application
npx react-native run-android
-
Get FCM Token
- Launch the app
- Tap "Copy Token to Console"
- Copy the token from terminal
-
Send Test Notification
- Go to Firebase Console β Cloud Messaging
- Click "Send your first message"
- Enter title and body
- Click "Test on device"
- Paste your FCM token
- Send!
-
Test Different States
- Foreground: Keep app open β Should show alert
- Background: Press home button β Should show in notification bar
- Closed: Close app completely β Should show in notification bar
- Enable Debug Mode
adb shell setprop debug.firebase.analytics.app com.pushnotificationdemo
-
Real-time Testing
- Go to Firebase Console β Analytics β DebugView
- Tap "Test Analytics Event" in app
- See events appear in real-time!
-
View Reports
- Firebase Console β Analytics β Events
- Firebase Console β Analytics β Dashboard
- Data appears within 24-48 hours for reports
- Firebase Console β Project Settings β Cloud Messaging
- Note your Server Key for API testing
- Firebase Console β Analytics β Dashboard
- Click "Enable Analytics" if not enabled
- Link to Google Analytics account
- Check that
google-services.json
package name matches your app - Ensure both services are enabled in your Firebase project
import analytics from '@react-native-firebase/analytics';
// Log custom event
await analytics().logEvent('custom_event_name', {
parameter_1: 'value1',
parameter_2: 123,
timestamp: Date.now(),
});
// Set user properties
await analytics().setUserProperty('user_type', 'premium');
await analytics().setUserProperty('preferred_category', 'tech');
PushNotification.createChannel({
channelId: "custom_channel",
channelName: "Custom Notifications",
importance: 5,
vibrate: true,
});
The app automatically tracks:
app_open
- App launchesscreen_view
- Screen transitionsnotification_received
- Push notifications receivednotification_opened_app
- App opened via notificationfcm_token_received
- FCM token generationtest_local_notification_sent
- Test notification sentanalytics_initialized
- Analytics setup completenotifications_cleared
- Notification history cleared
Notifications not appearing?
- Check device notification permissions
- Disable battery optimization for your app
- Ensure
google-services.json
is in correct location - Verify notification channel setup
Analytics not working?
- Check if Analytics is enabled in Firebase Console
- Verify
google-services.json
configuration - Use DebugView for real-time testing
- Events may take 24-48 hours to appear in reports
Build errors?
cd android && ./gradlew clean && cd .. && npx react-native run-android
# Check app logs
adb logcat | grep -i "firebase"
# Enable analytics debug mode
adb shell setprop debug.firebase.analytics.app YOUR_PACKAGE_NAME
# Clear app data
adb shell pm clear YOUR_PACKAGE_NAME
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- React Native Firebase for excellent Firebase integration
- Firebase for powerful backend services
- React Native Push Notification for local notifications
If you have any questions or need help:
β Star this repo if it helped you! It motivates me to create more awesome projects.
- β Added comprehensive Firebase Analytics integration
- β Enhanced UI with real-time status indicators
- β Added in-app testing tools for both features
- β Improved error handling and logging
- β Added user properties and custom event tracking
- β Added detailed testing guides and troubleshooting