Skip to content

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.

25 minutesSetupSite owner, DevOps, mobile developerVerified against the platform code

What users get ​

Each push is translated into the language the user picked in the app. Tapping it opens the matching screen.

CategoryPushWhen
Orders and optionsOrder filledA spot order fills (at most one push per market every 30 seconds while a big order fills in parts)
Option won / Option lostAn options round settles
Deposits and withdrawalsDeposit receivedA crypto or fiat deposit is confirmed (internal credits such as vouchers don't push)
Deposit rejectedA fiat deposit is rejected
Withdrawal completedA crypto or fiat withdrawal is sent
Withdrawal rejected / failedAn admin rejects it, or the network send fails
P2PNew P2P orderSomeone opens an order on your ad
Buyer marked as paidSent to the seller
Coins releasedSent to the buyer
P2P order cancelledSent to the other side (both sides when the order expires)
New messageA chat message from the other side (at most one per order per minute)
Appeal opened / Appeal updated / Support repliedAppeal steps
Account and supportIdentity verified / rejectedAn admin approves or rejects KYC
Merchant approved / rejectedAn admin decides a merchant application
Support repliedYou 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 ​

  1. 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 the push_tokens table.
  2. When an event above happens, the server queues a SendPushNotification job on the default queue (Queues).
  3. 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.
  4. 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 ​

  1. Open the Firebase console and Add project. Google Analytics isn't needed.
  2. Add app → Android with your Android application ID (for example exchange.cryptotech.exchange_app). You don't need to download google-services.json.
  3. Add app → iOS with your iOS bundle ID (for example exchange.cryptotech.exchangeApp). You don't need GoogleService-Info.plist.

2. Connect Apple (iOS only) ​

  1. In your Apple Developer account, create an APNs authentication key (Keys → +, tick Apple Push Notifications service) and download the .p8 file.
  2. In Firebase: Project settings → Cloud Messaging → Apple app configuration, upload the key with its Key ID and your Team ID.
  3. In Xcode, open mobile/ios/Runner.xcworkspace → Runner → Signing & Capabilities → + Capability → Push Notifications. (Background mode Remote notifications is already enabled in Info.plist.)

3. Server key ​

  1. Firebase: Project settings → Service accounts → Generate new private key. A JSON file downloads.
  2. Copy it to the server outside the public folder, for example storage/app/firebase.json, readable by the web user.
  3. Set it in .env:
ini
FIREBASE_CREDENTIALS=storage/app/firebase.json

The path can be absolute or relative to the project folder.

  1. Clear the config cache and restart the queue workers so they load the key:
bash
php artisan config:clear
php artisan horizon:terminate

Keep 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 keyFirebase value
FIREBASE_API_KEYWeb API key (shown under the project, or the Android app's API key)
FIREBASE_PROJECT_IDProject ID
FIREBASE_SENDER_IDProject number (Cloud Messaging Sender ID)
FIREBASE_ANDROID_APP_IDAndroid app's App ID (1:…:android:…)
FIREBASE_IOS_APP_IDiOS app's App ID (1:…:ios:…)
FIREBASE_IOS_BUNDLE_IDYour 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 ​

  1. Install the new build on a real phone (iOS simulators don't receive pushes), sign in and allow notifications.
  2. Check the device was registered:
bash
php artisan tinker --execute="echo App\Models\Push\PushToken::count();"
  1. 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 ​

SymptomCheck
No device in push_tokensThe app was built without the FIREBASE_* keys, the user denied permission, or the user turned Push notifications off
Devices registered, nothing arrivesFIREBASE_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'tAPNs key uploaded in Firebase, Push Notifications capability added in Xcode, real device
A user gets pushes in the wrong languageThe app sends the language chosen in its settings; the user can change it there

Owner documentation for the CryptoTech exchange platform.