Appearance
Push notifications
The app can notify users on their phone when something happens to their money or orders, even when the app is closed. Pushes go through Firebase Cloud Messaging (FCM), which delivers to both Android and iOS. Nothing is sent until you add your Firebase keys.
What users get
Each push is translated into the language the user picked in the app. Tapping it opens the matching screen.
| Category | Push | When |
|---|---|---|
| Orders and options | Order filled | A spot order fills (at most one push per market every 30 seconds while a big order fills in parts) |
| Option won / Option lost | An options round settles | |
| Deposits and withdrawals | Deposit received | A crypto or fiat deposit is confirmed (internal credits such as vouchers don't push) |
| Deposit rejected | A fiat deposit is rejected | |
| Withdrawal completed | A crypto or fiat withdrawal is sent | |
| Withdrawal rejected / failed | An admin rejects it, or the network send fails | |
| P2P | New P2P order | Someone opens an order on your ad |
| Buyer marked as paid | Sent to the seller | |
| Coins released | Sent to the buyer | |
| P2P order cancelled | Sent to the other side (both sides when the order expires) | |
| New message | A chat message from the other side (at most one per order per minute) | |
| Appeal opened / Appeal updated / Support replied | Appeal steps | |
| Account and support | Identity verified / rejected | An admin approves or rejects KYC |
| Merchant approved / rejected | An admin decides a merchant application | |
| Support replied | You answer a ticket in the Support center |
Users switch notifications off, or switch single categories off, in the app under Settings → Notifications. Emails are sent as before; pushes come on top.
Also in the Notification Center
Every event that sends a push is also saved in the user's Notification Center (the bell on the website and Notifications in the app), even without Firebase or the app. Messages you send from Admin → Users → Notifications go to both as well.
How it works
- After sign-in, the app asks for notification permission and registers the device (
POST /api/v1/push/tokens) with its language and category choices. Devices are stored in thepush_tokenstable. - When an event above happens, the server queues a
SendPushNotificationjob on the default queue (Queues). - The job sends one message per device to FCM, signed with your Firebase service account. Devices that FCM reports as gone (app uninstalled) are deleted.
- Signing out removes the device. A device whose app login was revoked (password reset, logout elsewhere) stops getting pushes too.
Setup
1. Create the Firebase project
- Open the Firebase console and Add project. Google Analytics isn't needed.
- Add app → Android with your Android application ID (for example
exchange.cryptotech.exchange_app). You don't need to downloadgoogle-services.json. - Add app → iOS with your iOS bundle ID (for example
exchange.cryptotech.exchangeApp). You don't needGoogleService-Info.plist.
2. Connect Apple (iOS only)
- In your Apple Developer account, create an APNs authentication key (Keys → +, tick Apple Push Notifications service) and download the
.p8file. - In Firebase: Project settings → Cloud Messaging → Apple app configuration, upload the key with its Key ID and your Team ID.
- In Xcode, open
mobile/ios/Runner.xcworkspace→ Runner → Signing & Capabilities → + Capability → Push Notifications. (Background mode Remote notifications is already enabled inInfo.plist.)
3. Server key
- Firebase: Project settings → Service accounts → Generate new private key. A JSON file downloads.
- Copy it to the server outside the public folder, for example
storage/app/firebase.json, readable by the web user. - Set it in
.env:
ini
FIREBASE_CREDENTIALS=storage/app/firebase.jsonThe path can be absolute or relative to the project folder.
- Clear the config cache and restart the queue workers so they load the key:
bash
php artisan config:clear
php artisan horizon:terminateKeep the key secret
The service-account file can send pushes to all your users. Never put it in public/, in Git, or in the app.
4. App keys
In Firebase: Project settings → General → Your apps. Copy these values into the app's build file (mobile/env/prod.json, see Building and releasing):
| Build key | Firebase value |
|---|---|
FIREBASE_API_KEY | Web API key (shown under the project, or the Android app's API key) |
FIREBASE_PROJECT_ID | Project ID |
FIREBASE_SENDER_ID | Project number (Cloud Messaging Sender ID) |
FIREBASE_ANDROID_APP_ID | Android app's App ID (1:…:android:…) |
FIREBASE_IOS_APP_ID | iOS app's App ID (1:…:ios:…) |
FIREBASE_IOS_BUNDLE_ID | Your iOS bundle ID |
Then rebuild the app. With these keys empty the app works normally without push, and Settings → Notifications says "Push notifications are not set up in this build."
Testing
- Install the new build on a real phone (iOS simulators don't receive pushes), sign in and allow notifications.
- Check the device was registered:
bash
php artisan tinker --execute="echo App\Models\Push\PushToken::count();"- Trigger something, for example reply to one of that user's support tickets. The push arrives within seconds; while the app is open it shows as an in-app message instead.
Troubleshooting
| Symptom | Check |
|---|---|
No device in push_tokens | The app was built without the FIREBASE_* keys, the user denied permission, or the user turned Push notifications off |
| Devices registered, nothing arrives | FIREBASE_CREDENTIALS path and file permissions; Horizon running and restarted after setting it; storage/logs/laravel-YYYY-MM-DD.log for "FCM send failed" |
| Android works, iOS doesn't | APNs key uploaded in Firebase, Push Notifications capability added in Xcode, real device |
| A user gets pushes in the wrong language | The app sends the language chosen in its settings; the user can change it there |
