Push notifications
What the Mobiari mobile apps receive by push. The kinds of notification, what each push carries, where a tap leads, and how operators turn APNs and FCM on.
Not part of the public API yet
Push notifications are not part of the public API yet: registering a device, notification preferences and the notification list will be documented here when they are. This page describes how push behaves in the Mobiari apps.
The merchant apps (iOS and Android, application id com.mobiari.merchant)
receive the same team alerts the platform sends by e-mail and WhatsApp: new
and paid orders, cancellations, low stock, and conversations that are
assigned to you or to nobody. The server sends iOS pushes through APNs,
Android pushes through Firebase Cloud Messaging (FCM), and browser pushes
through Web Push (see Browsers).
Push is for team members signed in to the app.
Incoming calls
A customer's WhatsApp call rings every live device of every team member who
may answer conversations (conversations.reply), even with the app closed.
These pushes skip the notification center: no bell entry, no e-mail, and no
per-kind preference. They carry data only, all strings:
| Field | |
|---|---|
kind | call.incoming when it starts ringing, call.ended when it was answered elsewhere, declined, missed or hung up. |
call_id, store_id | The call and its store. |
contact_name, contact_phone | Who is calling (empty on call.ended). |
- iOS: a VoIP push (
apns-push-type: voip, topic<bundle id>.voip) to the device's PushKit (VoIP) token. The app must report a call to CallKit for every one it receives. Devices without a VoIP token are not rung. - Android: a high-priority FCM data message, dropped after 60 seconds.
A ring is worthless after about a minute: a push still queued by then is dropped. To answer, the app fetches the call's offer and follows the same steps as the web admin.
Preferences
A push is one channel of the member's notifications: the same notification also lands in their bell and, if they choose, in their e-mail or WhatsApp. Each member picks, per store and per kind, where it reaches them.
Members choose in the Mobiari admin, under Notifications → Preferences. Preferences apply to every device of the user.
| Kind | When | Who gets it | Needs | Push by default |
|---|---|---|---|---|
orders.created | A new order (online or a manual sale) | Every member, except whoever placed it | orders.read | yes |
orders.paid | Payment confirmed (once per order, however many times the provider confirms) | Every member, except whoever took the payment | orders.read | yes |
orders.cancelled | Someone cancelled an order | Every member, except whoever cancelled | orders.read | yes |
customers.address_changed | A customer changed the delivery address with orders not shipped | The customer's owner, else every member | orders.read | yes |
inventory.low_stock | A variant reached its reorder point (or 5 units) at a location, at most once a day | Every member | inventory.read | no |
inventory.out_of_stock | A variant ran out at a location, at most once a day | Every member | inventory.read | yes |
conversations.started | A customer started a conversation and the chat bot is off | The assignee, or every member when unassigned | conversations.read | yes |
conversations.message_received | A customer wrote and the chat bot is off | Same | conversations.read | yes |
conversations.handed_over | The chat bot handed the conversation to the team | Same | conversations.read | yes |
conversations.assigned | Someone else assigned a conversation to you | The new assignee | conversations.read | yes |
tasks.assigned | Someone assigned you a task | The assignee | yes | |
tasks.due | A task of yours is due | The assignee | yes | |
customers.note_mention | Someone mentioned you in a customer note | The members mentioned | customers.read | yes |
customers.privacy_request | A customer asked from their account for their data to be deleted or corrected (LGPD, answer within 15 days) | Every member | customers.write | yes |
fiscal.document_rejected | SEFAZ rejected or denied an NF-e | Every member | orders.write | yes |
purchasing.documents_received | Purchase NF-e issued to the store arrived from SEFAZ | Every member | purchasing.read | no |
purchasing.invoice_cancelled_after_receipt | A supplier cancelled an invoice already received: the reversal waits for a decision | Every member | purchasing.read | yes |
documents.expiring | A store document is about to expire | Every member | documents.write | no |
signatures.updated | A signature request you sent was signed by everyone or declined | The sender | documents.read | no |
workflows.run_failed | An automation failed, at most once an hour per automation | Every member | workflows.write | no |
New kinds will be added. Ignore a kind you do not know, or open its
link (below).
What a push carries
Every push has a localized title and body, and deep-link data:
| Key | Present |
|---|---|
kind | Always. One of the kinds above, or test for a test push. |
store_id | Always, except test. |
order_id | orders.*, and customers.address_changed about one order |
conversation_id | conversations.* |
product_id, variant_id | inventory.* |
customer_id | customers.* about a customer |
link | The admin path the notification opens (/orders/<id>, /tasks, ...), when it has one |
All values are strings.
iOS (APNs). The data keys sit at the top level of the payload, next to
aps:
{
"aps": {
"alert": { "title": "Pedido #1042 pago", "subtitle": "Loja Azul", "body": "R$ 1.234,56 · Ana Souza" },
"sound": "default",
"badge": 3,
"thread-id": "store-0199a0c4-..."
},
"kind": "orders.paid",
"store_id": "0199a0c4-...",
"order_id": "0199b7e2-...",
"link": "/orders/0199b7e2-..."
}subtitle is the store name. thread-id groups a conversation's pushes
(conv-<conversation id>) and a store's other alerts (store-<store id>).
Pushes use apns-push-type: alert, priority 10, and expire after an hour.
Android (FCM). A notification message with the data under data:
{
"notification": { "title": "Order #1042 paid", "body": "R$1,234.56 · Ana Souza" },
"data": { "kind": "orders.paid", "store_id": "0199a0c4-...", "order_id": "0199b7e2-...", "link": "/orders/0199b7e2-..." },
"android": {
"priority": "high",
"ttl": "3600s",
"collapse_key": "order-0199b7e2-...",
"notification": { "channel_id": "orders", "tag": "order-0199b7e2-...", "notification_count": 3, "sound": "default" }
}
}Create four notification channels in the app so users can mute them
separately: orders, conversations, inventory and general (tasks,
fiscal, purchasing, documents, automations). Until a channel exists,
Android shows the push in the app's default channel.
Collapsing. Pushes about the same subject share a collapse key
(apns-collapse-id / collapse_key and tag): order-<order id>, so an
order's "paid" replaces its "new"; conversation-<conversation id>, so a
burst of messages leaves one notification with the latest text;
variant-<variant id> for stock. Kinds that each say something of their
own (a task, a mention) never collapse.
Badge. The badge is the member's unread notifications in the store the push is about: the same number as the bell.
Handling a tap
Read kind and store_id from the push data. If store_id is not the
store currently selected in the app, switch to it first (the user may belong
to several stores), then:
kind | Open |
|---|---|
orders.created, orders.paid, orders.cancelled | The order (order_id) |
conversations.* | The conversation thread (conversation_id) |
inventory.* | The variant's stock (variant_id), or the product (product_id) |
test | Nothing in particular (the home screen) |
| anything else | The screen for link if the app has one, else the home screen |
If the user lost access to the store or the record is gone, show the store's home instead.
Browsers
The admin (app.mobiari.com) gets the same pushes in the browser, also with
every Mobiari tab closed (the browser itself has to be running). Turning on
desktop notifications in Conversations (the bell in the inbox toolbar)
subscribes the browser and registers it as a web device of the session;
turning them off, or signing out, removes it. Which alerts arrive follows
the same notification preferences as the apps (the "Phone and browser"
column).
The service worker (/sw.js) shows a push only when no Mobiari tab is in
front: an open tab shows its own toast and plays its own sound, and a
notification about a conversation is silent while a tab is open in the
background. Clicking one opens its page, switching to its store. Browsers
that cannot reach their push service (Chromium builds without Google's
services, such as Helium or ungoogled-chromium) fall back to notifications
from an open tab.
For operators
Push is off until credentials are configured. With none, the backend logs
push notifications disabled once at startup and everything else works as
before. Each provider is enabled on its own: configure only APNs and Android devices
simply get nothing (and vice versa). A key that does not parse disables that
provider with an error in the startup log; the backend still starts.
| Variable | |
|---|---|
APNS_KEY_P8 | Contents of the APNs auth key (AuthKey_XXXXXXXXXX.p8, PKCS#8 PEM). In an env file, put it on one line with \n for the newlines. |
APNS_KEY_PATH | Alternative to APNS_KEY_P8: path to the .p8 file inside the container. |
APNS_KEY_ID | The key's 10-character id. |
APNS_TEAM_ID | The Apple Developer team id. |
APNS_TOPIC | The app's bundle id. Default com.mobiari.merchant. |
FCM_SERVICE_ACCOUNT_JSON | A Firebase service-account key JSON (Project settings, Service accounts, "Generate new private key"), minified to one line. |
FCM_SERVICE_ACCOUNT_PATH | Alternative: path to the JSON file inside the container. |
FCM_PROJECT_ID | The Firebase project id. Defaults to the service account's project_id. |
WEB_PUSH_VAPID_KEY | Web Push: the VAPID P-256 private key, PKCS#8 PEM (openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256). In an env file, one line with \n for the newlines. |
WEB_PUSH_VAPID_KEY_PATH | Alternative: path to the PEM file inside the container. |
WEB_PUSH_SUBJECT | The contact push services see in the VAPID token, mailto: or https:. Default https://mobiari.com. |
APNs uses token-based auth: the backend signs an ES256 JWT with the key and
talks HTTP/2 to api.push.apple.com (or api.sandbox.push.apple.com for
debug builds run from Xcode). One key works for both
gateways and every app of the team. FCM uses the HTTP v1 API; the backend
exchanges a JWT signed with the service account for an OAuth2 access token
and reuses it until it expires.
Web Push signs an ES256 VAPID token with that key and encrypts each payload
to the browser's key (RFC 8291, aes128gcm); browsers subscribe with the
public half, served at GET /me/devices/web-push-config. Changing the key
invalidates every browser subscription: browsers subscribe again on their
next visit. Only the push services of Chrome, Firefox, Safari and Edge are
accepted as endpoints.
Deliveries go through the job queue (jobs table, kind push.deliver):
one job per device, retried with exponential backoff on provider 5xx, 429
and network errors, and dead-lettered after 5 attempts or on errors a retry
cannot fix (bad credentials, rejected payload). A dead-lettered push job
with InvalidProviderToken or THIRD_PARTY_AUTH_ERROR means the credentials
are wrong.