Developer docs
In-app chat for mobile apps
Your mobile app opens the ocno space chat page in a WebView on its Support screen. Customers chat there; your agents answer from ocno space. No chat SDK is needed in the app.
What your team builds
- Server: one call that returns a chat link for the signed-in customer (step 1).
- App: the Support button opens that link in a WebView (step 2).
- Optional: a push notification when an agent replies while the app is closed (step 3).
Typical effort: 2–4 developer days, plus app store review.
How it works
- The customer taps Support in your app.
- The app asks your server for a chat link; your server calls ocno space with its API key.
- ocno space returns a signed link, valid for 24 hours, for that customer only.
- The app opens the link in a full-screen WebView.
- From here ocno space does everything: messages, photos and PDFs (up to 10 MB), history, live agent replies, ratings and the AI assistant if it is on.
The customer never signs in again: your server vouches for them, so nobody can write as someone else.
Before you start
- In ocno space, an admin connects Integrations → Mobile App Chat.
- The admin creates an API key in Settings → API keys and passes it to your backend team through a secure channel.
- Keep the key on your server only. Never put it in the app — apps can be unpacked.
1. Server: get a chat link
Call this every time the customer opens Support and return the url to the app.
curl -X POST https://ocno.space/api/v1/app-chat/sessions \
-H "Authorization: Bearer od_xxxxxxxx_…" \
-H "Content-Type: application/json" \
-d '{
"customer": {
"externalId": "847392",
"name": "Ayesha Khan",
"phone": "+923001234567",
"email": "[email protected]",
"language": "en"
},
"language": "en"
}'Response 201:
{
"url": "https://ocno.space/api/widget/app?lang=en#t=eyJhbGciOi…",
"token": "eyJhbGciOi…",
"expiresAt": "2026-12-01T11:00:00.000Z"
}| Field | Required | Notes |
|---|---|---|
customer.externalId | yes | The customer’s permanent id in your app. The same id always opens the same chat history. Up to 120 characters. |
customer.name | no | Shown to agents. |
customer.phone | no | International format, e.g. +923001234567. Helps agents find the customer and link chats from other channels. |
customer.email | no | Shown to agents. |
customer.language | no | Two letters: en, ru, ur… |
language | no | Language of the chat page buttons. Default: the customer’s language, else English. |
- A link is valid for 24 hours. An expired link shows “This chat link has expired”.
- Call this only for a signed-in customer, and only from your server.
- Errors:
401wrong or deleted API key;400a field is invalid (the response says which).
2. App: open the chat in a WebView
The Support button opens a full-screen WebView with the url. The page fills the screen and respects the notch and safe areas; it has no close button, so use the app’s own back button or header.
- If the app uses another chat SDK, remove it and its initialisation code.
- On Support tap: get a link from your server, then load it in the WebView.
- WebView settings: JavaScript on, DOM storage on.
- Attachments (the photo / PDF button in the chat):
- Android: implement
WebChromeClient.onShowFileChooser— without it the attach button does nothing. - iOS (WKWebView): works by default; add
NSPhotoLibraryUsageDescriptionandNSCameraUsageDescriptionto Info.plist.
- Android: implement
- Open links that agents send in the system browser, not inside the WebView.
Android (Kotlin)
webView.settings.javaScriptEnabled = true
webView.settings.domStorageEnabled = true
webView.webChromeClient = object : WebChromeClient() {
override fun onShowFileChooser(
view: WebView, callback: ValueCallback<Array<Uri>>, params: FileChooserParams
): Boolean {
fileCallback = callback
fileChooserLauncher.launch(params.createIntent())
return true
}
}
webView.loadUrl(chatUrl) // from your serveriOS (Swift)
let webView = WKWebView(frame: view.bounds)
webView.load(URLRequest(url: URL(string: chatUrl)!)) // from your serverFlutter (webview_flutter) and React Native (react-native-webview) work the same way: load the url, allow JavaScript and enable file uploads as the library describes.
3. Optional: notify when the app is closed
While the chat is open, replies appear instantly. To send a push when the app is closed, set an Outgoing webhook URL on your server (ocno space: Integrations → Mobile App Chat). ocno space then POSTs every agent reply there:
{
"event": "message.created",
"conversationId": "cm4…",
"threadId": "847392",
"customerExternalId": "847392",
"message": {
"id": "cm5…",
"type": "TEXT",
"content": "Your order is on its way",
"createdAt": "2026-11-30T12:00:00.000Z",
"attachments": []
}
}- Check the header
X-OneDesk-Signature: sha256=<hex>: the HMAC-SHA256 of the raw body with the channel’s signing secret (shown in the Mobile App Chat integration). Reject requests where it does not match. - Send your usual push; tapping it opens Support with a fresh link.
- Answer
200within 10 seconds. - The same URL also receives campaign push requests (
"event": "push.send") if you use ocno space campaigns.
Verify the signature (Node.js)
const crypto = require('crypto');
const expected = 'sha256=' + crypto.createHmac('sha256', SIGNING_SECRET).update(rawBody).digest('hex');
const ok = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(req.headers['x-onedesk-signature'] || ''));Testing checklist
- Your server gets a url for a test customer.
- The url opens in a phone browser and shows your greeting.
- A message from the chat appears in ocno space under Mobile App Chat with the customer’s name and phone.
- An agent reply appears in the chat within 1–2 seconds.
- A photo and a PDF can be attached on Android and on iOS.
- Closing and reopening Support keeps the history.
- Optional: a reply while the app is closed triggers a push.