Order shipped push
Your backend notifies the user when an order ships. The app is closed, so the runtime pushes through your Firebase project; a tap opens the chat.
Goal
Warehouse scans the parcel → your server calls Kletso → the user’s phone shows “Order ORD-2201 shipped” in the OS tray → tap → the app opens the chat on the conversation with a trip-plan surface.
Pieces
- Secret key
kl_sec_live_…on your server. - Push: the app registered its FCM token with
registerPushToken(KletsoPushToken(platform: KletsoPushPlatform.fcm, token: t)); the dashboard’s Triggers → Push delivery points at the secret holding your Firebase service-account JSON. - SDK:
onSystemNotificationshows OS notifications with your plugin; the OS tap handler callsKletso.instance.ui.openNotification(n); incoming pushes go tohandlePushPayload.
Two ways to send
From your backend (no app event involved):
curl -X POST https://api.kletso.ai/v1/notifications \
-H "Authorization: Bearer kl_sec_live_…" -H "Content-Type: application/json" \
-d '{ "externalId": "user-42",
"notification": { "title": "Order ORD-2201 shipped", "body": "Arrives tomorrow. Tap to track it.",
"channel": "system", "openChat": true } }'
From an app event with the sample rule “Order shipped push”: track('order_shipped', {'orderId': 'ORD-2201'}) → system notification with the trip-plan surface. Useful when the app learns about the shipment first.
Verify
- Response
202 { sent, conversationId, notificationId }. - App in foreground: the notification renders in the tray via your plugin (or as a banner if the plugin declines).
- App in background or killed: FCM delivers; the OS shows it; tap → app opens →
openNotificationswitches to the conversation and opens the chat. - Deliver twice with the same
notificationId: rendered once.
Notes
systemalways pushes, even with a live socket, because the tray is the point.- APNs and Web Push delivery are planned; iOS via Firebase works today.