This guide provides step-by-step instructions to complete the OneSignal integration for your Flutter app.
The following have already been set up in your project:
- ✅ OneSignal Flutter plugin added to
pubspec.yaml - ✅ Android permissions and configuration added to
AndroidManifest.xml - ✅ iOS configuration added to
Info.plist - ✅ OneSignal service class created (
lib/services/onesignal_service.dart) - ✅ OneSignal initialization added to
main.dart - ✅ Notification settings screen created
- ✅ CocoaPods dependencies installed for iOS
-
Visit OneSignal Dashboard
- Go to https://onesignal.com/
- Create a free account or sign in
-
Create New App
- Click "New App/Website"
- Enter your app name: "Nexa Prime"
- Select "Mobile App"
-
Note Your App ID
- Once created, copy your OneSignal App ID (it looks like:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
- Once created, copy your OneSignal App ID (it looks like:
-
In OneSignal Dashboard:
- Select "Android" platform
- You'll need your Firebase Server Key and Sender ID
-
Firebase Setup (if not already done):
- Go to Firebase Console
- Create a new project or use existing one
- Add Android app with package name:
com.chainfinance.app - Download
google-services.jsonand place it inandroid/app/
-
Get Firebase Credentials:
- In Firebase Console, go to Project Settings > Cloud Messaging
- Copy the "Server Key" and "Sender ID"
- Enter these in OneSignal Android configuration
-
Update Android Configuration:
- Open
android/app/src/main/AndroidManifest.xml - Replace
YOUR_ONESIGNAL_APP_IDwith your actual OneSignal App ID - Replace
YOUR_GOOGLE_PROJECT_NUMBERwith your Firebase Sender ID
- Open
-
In OneSignal Dashboard:
- Select "iOS" platform
- Upload your iOS Push Certificate or use iOS Push Key
-
iOS Push Certificate Setup:
- Open Keychain Access on Mac
- Go to Certificate Assistant > Request a Certificate from a Certificate Authority
- Save the CSR file
- Go to Apple Developer Console > Certificates
- Create new certificate > Apple Push Notification service SSL
- Upload the CSR file and download the certificate
- Upload this certificate to OneSignal
-
Update iOS Configuration:
- Open
ios/Runner/Info.plist - Replace
YOUR_ONESIGNAL_APP_IDwith your actual OneSignal App ID
- Open
-
Xcode Configuration:
- Open
ios/Runner.xcworkspacein Xcode - Select the Runner target
- Go to "Signing & Capabilities"
- Add "Push Notifications" capability
- Add "Background Modes" capability and check "Remote notifications"
- Open
-
Update OneSignal App ID in Service:
# Open lib/services/onesignal_service.dart # Replace "YOUR_ONESIGNAL_APP_ID" with your actual App ID
-
Add Navigation to Notification Settings:
- You can add a button in your Settings screen to navigate to notification settings:
// In your settings screen, add: GestureDetector( onTap: () => Get.toNamed(Routes.notificationSettings), child: // Your notification settings tile )
-
Build and Install Debug Version:
flutter run
-
Test Notification Permission:
- Open the app
- Check if notification permission dialog appears
- Grant permission when prompted
-
Send Test Notification:
- Go to OneSignal Dashboard
- Navigate to "Messages" > "Push"
- Click "New Push"
- Enter a test message
- Send to "All Users" or specific segments
-
Test Deep Linking (Optional):
- In OneSignal dashboard, add custom data in "Advanced Settings"
- Handle the data in
_handleNotificationClickmethod in the service
-
Android Release Configuration:
- Ensure you have a signed release APK
- The Firebase configuration works for both debug and release
-
iOS Production Configuration:
- Create a Production Push Certificate (not Development)
- Upload to OneSignal
- Test with TestFlight builds
-
User Segmentation:
// Set user tags for targeted notifications OneSignalService.sendTags({ 'user_type': 'premium', 'preferred_currency': 'USD', 'app_version': '1.0.0', });
-
External User ID:
// Link OneSignal user with your user system OneSignalService.setExternalUserId(userController.currentUser.id);
-
Custom Notification Sounds:
- Add sound files to
android/app/src/main/res/raw/ - Add sound files to iOS bundle
- Configure in OneSignal dashboard
- Add sound files to
- ✅
pubspec.yaml- OneSignal dependency added - ✅
android/app/src/main/AndroidManifest.xml- Permissions and meta-data added - ✅
ios/Runner/Info.plist- iOS configuration added - ✅
lib/main.dart- OneSignal initialization added - ✅
lib/services/onesignal_service.dart- Service class created - ✅
lib/views/home/notification_settings_screen.dart- Settings screen created - ✅
lib/routes/routes.dart- Route added
- 📝
android/app/src/main/AndroidManifest.xml- Replace placeholder App ID - 📝
ios/Runner/Info.plist- Replace placeholder App ID - 📝
lib/services/onesignal_service.dart- Replace placeholder App ID
-
iOS Build Errors:
cd ios && pod install --repo-update
-
Android Build Errors:
- Ensure Firebase configuration is correct
- Check package name matches everywhere
-
Notifications Not Received:
- Check app is not in "Do Not Disturb" mode
- Verify notification permissions are granted
- Check OneSignal dashboard for delivery reports
-
Permission Issues:
- Test on real device (simulator may have limitations)
- Check device notification settings
# Clean and rebuild
flutter clean
flutter pub get
cd ios && pod install
flutter run
# Build release versions
flutter build apk --release
flutter build ios --release- Keep your OneSignal App ID and Firebase Server Key secure
- Don't commit sensitive keys to version control
- Consider using environment variables for production builds
- OneSignal Documentation: https://documentation.onesignal.com/
- Flutter Plugin Docs: https://pub.dev/packages/onesignal_flutter
Next Action:
- Create OneSignal account and get your App ID
- Replace all placeholder App IDs in the configuration files
- Test the integration with debug builds