Developer docs
Build calling into your app. Keep numbers private.
AppDial adds masked, in-app voice calling to delivery, ride and on-demand apps. Your drivers and customers talk without ever seeing each other's phone number, and your team gets recordings, live monitoring and quality review. These docs take you from an API key to a first call on Android and iPhone.
- React Native SDK: Android and iPhone
- REST API
- Signed webhooks
- Test sandbox
Overview
AppDial runs the calls, the ringing, the recordings and the review, so you don't operate any calling infrastructure. You connect it in two places: your backend tells AppDial who is on which order, and your app places and receives the calls through the SDK.
What works where
| Capability | Android | iPhone |
|---|---|---|
| Calls while the app is open | Supported | Supported |
| Ringing while the app is closed or the phone is locked | Supported push, full-screen call screen, Bluetooth and car buttons | Supported VoIP push and the native call screen; needs an Apple Developer Program account |
| Headsets and routing | Bluetooth and wired headsets win automatically | Follows the system route, so connected headsets and AirPods work |
| Echo cancellation, noise suppression, auto gain | On by default | On by default |
| Trip chat, voice notes, shared location | Yes (see More than calls) | Yes |
| Requirements | React Native 0.74 or newer (tested on 0.86) | React Native 0.74 or newer (tested on 0.86), iOS 16.4 or newer |
The SDK is written once in React Native and runs on both platforms. There are no separate Kotlin or Swift libraries to integrate. The only native code you may add is the optional call layer that rings a closed app (see Ringing when closed).
How it works
Three parties are involved. Each does one job, and only your backend ever holds your API key.
- Holds a short-lived session token
- Calls
dial(tripId) - Shows your own call screen
- Registers each trip as drivers are assigned
- Mints session tokens
- Receives webhooks
- Calls, ringing and push
- Recording and review
- Dashboard and webhooks
The call, end to end
Your backend registers the trip
PUT /v1/trips/:idwith a driver and a customer, using your own ids. An active trip is what allows its two people to call each other. No phone numbers are involved.Your backend mints a session token
After your app has signed its user in, your backend calls
POST /v1/sessionsand returns the token to the app. The token is short-lived and belongs to one user.The driver taps Call
The app calls
dial(tripId). The customer's phone rings inside the app, or through a push notification when the app is closed.They talk, masked
Each side sees the other's name (and photo, if you set one), never a number. The call is recorded, with a spoken notice and a short tone at the start.
The result reaches you
AppDial sends
call.ended, thencall.recording.ready, and optionallycall.insights.readyto your webhook. Your team sees the call in the dashboard, live and afterwards.
Call states
initiated→ringing→active→completed
ormissedrejectedfailed
The SDK reports its own, finer states to your UI. See Call state and actions.
Technology
AppDial is built on open standards and each platform's own calling features. That keeps calls behaving like the rest of the phone and keeps your app light. This is what sits in each layer, and what it means for you.
| Layer | Built with | What you get |
|---|---|---|
| Real-time voice | WebRTC, with the Opus speech codec | Low-latency two-way audio that adapts to the network, with no plugins and no phone-network minutes. |
| Weak networks | Opus DTX and redundant audio (RED), plus echo cancellation, noise suppression and auto gain | No data is sent during silence, which also saves battery. Syllables survive packet loss on poor mobile links. |
| Transport security | DTLS-SRTP for media, TLS for every API call and the signalling channel | Calls and requests are encrypted in transit. |
| Connection recovery | Automatic resume on network changes, with timed retries for up to 60 seconds (configurable) | Calls survive 4G and Wi-Fi handovers and short dead zones. Your UI shows reconnecting instead of a dropped call. |
| Ringing a closed app: Android | Firebase Cloud Messaging data pushes, a full-screen call notification, Android's self-managed calling (Telecom) and a foreground service | Rings on the lock screen, answers from a Bluetooth headset or the car, and keeps a call alive in the background. |
| Ringing a closed app: iPhone | PushKit VoIP pushes through APNs, with CallKit | The native iPhone call screen, lock-screen answer, and AirPods and CarPlay buttons. Calls stay out of the Phone app's Recents, so numbers stay private. |
| Identity | Your own user and trip ids, with display names and photos | AppDial never needs a phone number from you, and none is ever shown to a caller. |
| Authorization | Active trips, and signed session tokens that last one hour by default | Only the driver and the customer of an active trip can call each other. |
| Recording | Server-side recording with a spoken notice, kept in private storage | Recordings are reached through short-lived signed links, by your webhook or the dashboard. |
| Webhooks | JSON signed with HMAC-SHA256, retried with backoff, with stable event ids | You can verify every event and safely handle duplicates. |
| AI review Optional | Speech-to-text and language models, switched on per company | A transcript, an English and Arabic summary, the reason for the call, its outcome, flags such as "asked for money", and a suggested score. |
| Test mode | A separate sandbox company with its own ad_test_ keys | Test the whole flow without touching real data, recordings or reports. |
Media servers, push delivery, call recording and storage, webhook retries and the reporting dashboard are all operated by AppDial. You keep two small pieces: a backend endpoint that mints session tokens and a webhook receiver.
Quickstart
Five steps from nothing to a first call. Use test mode while you build: it behaves like the real thing, but nothing is recorded or analysed and nothing mixes with your live data. See Test mode.
-
Get your keys
AppDial creates your company and gives you a dashboard login and a live API key (
ad_live_…, shown once). In the dashboard, open Developers → Sandbox to create your test company and itsad_test_…keys. Keep the key on your server only.export APPDIAL_URL="https://app.appdial.io" export APPDIAL_KEY="ad_test_..." # a test key while you build -
Register a trip from your backend
When a driver is assigned to an order, register the trip with your own ids. People are created automatically, and you can repeat the call safely.
curl -X PUT "$APPDIAL_URL/v1/trips/order-8812" \ -H "Authorization: Bearer $APPDIAL_KEY" \ -H "Content-Type: application/json" \ -d '{ "driver": { "id": "drv-7", "displayName": "Omar Khaled" }, "customer": { "id": "cus-9", "displayName": "Mona Ahmed" }, "label": "Order #8812 · Burger House" }' -
Give your app a session token
Add one endpoint to your backend. After it has authenticated the user, it asks AppDial for a token and returns it. The app never sees your API key.
app.post('/me/appdial-token', requireLogin, async (req, res) => { const r = await fetch(`${process.env.APPDIAL_URL}/v1/sessions`, { method: 'POST', headers: { Authorization: `Bearer ${process.env.APPDIAL_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ userId: req.user.id }), // YOUR user id }); if (!r.ok) return res.sendStatus(502); res.json(await r.json()); // { token, expiresAt, user } });import os, requests def appdial_token(request): # behind your own login r = requests.post( f"{os.environ['APPDIAL_URL']}/v1/sessions", headers={"Authorization": f"Bearer {os.environ['APPDIAL_KEY']}"}, json={"userId": request.user.id}, # YOUR user id timeout=10, ) r.raise_for_status() return r.json() # { token, expiresAt, user } -
Add the SDK to your app
Install the package and its native modules, then wrap your app. Platform details are in Android setup and iPhone setup.
npm install ./appdial-react-native-0.1.0.tgz @livekit/react-native@3.0.0 @livekit/react-native-webrtc@144.2.0 livekit-client@2.22.3import { AppDialProvider } from '@appdial/react-native'; // Keep this function stable (define it outside the component). const getToken = async () => (await api.post('/me/appdial-token')).token; export default function App() { return ( <AppDialProvider baseUrl="https://app.appdial.io" getToken={getToken}> <Navigation /> </AppDialProvider> ); } -
Place the call
The driver's app dials by your trip id. The customer's app rings on its own, with no extra code.
import { useCall } from '@appdial/react-native'; function TripScreen({ trip }: { trip: { id: string } }) { const call = useCall(); if (call.status === 'incoming') { return <Incoming name={call.peer?.displayName} onAccept={() => call.accept()} onDecline={() => call.decline()} />; } if (call.status !== 'idle' && call.status !== 'ended') { return <InCall name={call.peer?.displayName} status={call.status} muted={call.muted} onMute={call.toggleMute} onHangup={call.hangup} />; } return <Button title="Call customer" onPress={() => call.dial(trip.id)} />; // YOUR trip id }
Open the dashboard: the call appears under Reports, and under Live now while it is in progress. Set a webhook URL in Developers to receive the call.ended event. When you are ready, swap the test key for your live key. The URL stays the same.
Backend API
Your server talks to AppDial over HTTPS and JSON. Everything is scoped to your company, and you only ever see and send your own ids.
Authentication
Base URL: https://app.appdial.io. Send your API key on every /v1 request:
Authorization: Bearer ad_live_... (or ad_test_... for the sandbox)
Content-Type: application/json
Never put an API key in an app: anyone can extract it from the binary. Apps only receive session tokens from your backend. You can create, rotate and revoke keys yourself in the dashboard (Developers), and AppDial stores only a hash of each key.
Users
Users are created automatically when you register a trip, so you only call these to set a photo or a team, or to read a user back.
/v1/users/:id| Field | Type | Notes |
|---|---|---|
role | string | driver or customer. Required. A user cannot change role. |
displayName | string | Required, up to 200 characters. This is what the other side sees. |
avatarUrl | string or null | An https URL, up to 500 characters. Shown on the other side's call screen. |
team | string or null | Drivers only: a branch, city or shift, up to 80 characters. Created if new, and null removes it. A dashboard supervisor limited to a team sees only that team's calls. |
{ "id": "drv-7", "role": "driver", "displayName": "Omar Khaled", "avatarUrl": null, "status": "active", "team": "Cairo" }
/v1/users/:idReturns the same object.
Trips
A trip links one driver to one customer. An active trip is what allows the driver and the customer to call each other. Complete or cancel it when the order is done.
/v1/trips/:id| Field | Type | Notes |
|---|---|---|
driver | object | Required: { id, displayName?, avatarUrl? }. |
customer | object | Required: the same shape. |
status | string | active (default), completed or cancelled. |
label | string or null | Up to 120 characters, shown while the call rings, for example Order #8812 · Burger House. |
driverLocation, customerLocation | object or null | { lat, lng }, for the dashboard's live map. See below. |
Returns 201 when created and 200 on a repeat, so the call is idempotent.
{
"id": "order-8812", "status": "active", "label": "Order #8812 · Burger House",
"driverId": "drv-7", "customerId": "cus-9",
"driverLocation": null, "customerLocation": null,
"createdAt": "2026-11-06T09:12:03.221Z", "updatedAt": "2026-11-06T09:12:03.221Z"
}
/v1/trips/:idSend status, driverLocation, customerLocation, or any mix. Use it to close the trip, and to stream the driver's position as it moves.
curl -X PATCH "$APPDIAL_URL/v1/trips/order-8812" \
-H "Authorization: Bearer $APPDIAL_KEY" -H "Content-Type: application/json" \
-d '{ "status": "completed" }'
/v1/trips/:idReturns the trip as above.
- A trip's driver and customer cannot be swapped once set (
409). - One user id cannot be a driver and a customer at the same time (
409). - Positions are optional. They feed your dashboard's live map only: the other party never sees them. The apps can add positions too (a location shared in the chat, and the phone's position when a call starts, if the user has allowed location).
Sessions
Mint a token for a user whose identity your app has already verified.
/v1/sessionscurl -X POST "$APPDIAL_URL/v1/sessions" \
-H "Authorization: Bearer $APPDIAL_KEY" -H "Content-Type: application/json" \
-d '{ "userId": "drv-7" }'
{ "token": "eyJ...", "expiresAt": "2026-11-06T10:12:03.000Z",
"user": { "id": "drv-7", "role": "driver", "displayName": "Omar Khaled", "avatarUrl": null, "status": "active" } }
The token lasts one hour by default. The SDK asks your getToken() again shortly before it expires. The user must exist (404 otherwise) and be active (403 if suspended).
Looking up calls
/v1/callsFilter with tripId, userId, status (initiated, ringing, active, completed, missed, rejected, failed), limit (1 to 100, default 20) and offset. The response is { items, total, limit, offset }, newest first.
/v1/calls/:idReturns one call in the same shape as the webhook payload, with a fresh recording link. Recording links from this API are short-lived (five minutes by default), so fetch one when you need it.
Branding
Set the colour and logo your company uses in the dashboard.
/v1/branding PATCH/v1/branding{ "brandColor": "#1A73E8", "logoUrl": "https://cdn.example.com/logo.png" }
brandColor is a hex colour and logoUrl an https URL. Send null to clear either.
Webhooks
AppDial sends your server an HTTPS POST when something happens to a call. Set the endpoint once, in the dashboard (Developers) or with the API:
/v1/webhookcurl -X PUT "$APPDIAL_URL/v1/webhook" \
-H "Authorization: Bearer $APPDIAL_KEY" -H "Content-Type: application/json" \
-d '{ "url": "https://api.example.com/appdial/webhook" }'
# → { "url": "...", "secret": "whsec_...", "apiVersion": "2026-09-24" }
The URL must be a public https address. Send { "rotateSecret": true } for a new signing secret, or { "url": null } to turn webhooks off. POST /v1/webhook/test sends a webhook.test event, and GET /v1/webhook/deliveries lists the last 50 attempts with status codes and errors.
Events
| Type | When |
|---|---|
call.ended | A call reached a final state: completed, missed, rejected or failed. |
call.recording.ready | The recording finished processing. It carries a download link. |
call.recording.failed | The recording failed for this call. |
call.insights.ready | The AI review finished. Sent once per call, and only when AI review is on for your company. |
webhook.test | You asked for it. |
A recorded call produces call.ended first, with recording.status set to "recording", and call.recording.ready a few seconds later.
{
"id": "evt_b8ceeb54-...",
"type": "call.ended",
"apiVersion": "2026-09-24",
"livemode": true,
"createdAt": "2026-11-06T12:37:57.445Z",
"data": {
"call": {
"id": "0dcfb539-...",
"status": "completed",
"initiatedBy": "driver",
"disconnectReason": "ended_by_participant",
"trip": { "id": "order-8812" },
"driver": { "id": "drv-7", "displayName": "Omar Khaled" },
"customer": { "id": "cus-9", "displayName": "Mona Ahmed" },
"createdAt": "...", "ringingAt": "...", "answeredAt": "...", "endedAt": "...",
"ringSeconds": 6,
"durationSeconds": 94,
"recording": { "status": "completed", "url": "https://...signed...", "expiresAt": "..." }
}
}
}
durationSecondsis talk time. It isnullunless the call wascompleted.recording.urlis a temporary signed link (one hour by default). Download it promptly, or fetch a fresh one any time withGET /v1/calls/:id.- The payload contains no phone numbers, and only your own ids.
livemodeisfalsefor events from your sandbox.
The AI review event
call.insights.ready carries the call as above, plus data.insights:
"insights": {
"language": "ar",
"reason": "building_access",
"outcome": "resolved",
"summary": { "en": "The driver reached the building; the customer came down.", "ar": "..." },
"flags": ["complaint"],
"suggestedScore": 4,
"transcript": "...",
"lines": null,
"analyzedAt": "2026-11-06T12:40:03.120Z"
}
| Field | Values |
|---|---|
reason | address, customer_unavailable, building_access, late, order_issue, payment, other |
outcome | resolved, rescheduled, cancelled, unresolved, unknown |
flags | rude_or_shouting, asked_for_phone_number, asked_for_money, shared_phone_number, complaint, not_resolved, harassment_or_threat, long_call |
suggestedScore | 1 to 5 for the driver's conduct. It is a suggestion: your supervisors decide. |
lines | The transcript split by speaker, when each side was recorded separately; otherwise null. Use transcript for the text. |
New fields can be added at any time. Don't reject payloads that contain fields you don't know.
Verify the signature
Every request carries AppDial-Signature: t=<unix seconds>,v1=<hex>, where v1 is HMAC-SHA256(secret, "<t>.<raw body>"). Two more headers are sent: AppDial-Event-Id and AppDial-Event-Type. Always verify against the raw body, not re-serialised JSON, and reject old timestamps.
const crypto = require('crypto');
app.post('/appdial/webhook', express.raw({ type: 'application/json' }), (req, res) => {
const m = /t=(\d+),v1=([0-9a-f]{64})/.exec(req.get('AppDial-Signature') || '');
if (!m) return res.sendStatus(400);
const [, t, v1] = m;
const expected = crypto.createHmac('sha256', process.env.APPDIAL_WEBHOOK_SECRET)
.update(`${t}.${req.body}`).digest('hex');
const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
if (!fresh || !crypto.timingSafeEqual(Buffer.from(v1, 'hex'), Buffer.from(expected, 'hex'))) {
return res.sendStatus(400);
}
const event = JSON.parse(req.body);
// Deduplicate on event.id: retries reuse the same id.
res.sendStatus(200); // answer fast, do the heavy work afterwards
});import hashlib, hmac, os, re, time
def verify(raw_body: bytes, header: str) -> bool:
m = re.search(r"t=(\d+),v1=([0-9a-f]{64})", header or "")
if not m:
return False
t, v1 = m.groups()
expected = hmac.new(
os.environ["APPDIAL_WEBHOOK_SECRET"].encode(),
t.encode() + b"." + raw_body,
hashlib.sha256,
).hexdigest()
fresh = abs(time.time() - int(t)) < 300
return fresh and hmac.compare_digest(v1, expected)Retries
Any non-2xx answer, a timeout (10 seconds) or a connection error is retried after 10 seconds, 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours: eight attempts in all. After that the delivery is marked failed and stays visible in the dashboard and in /v1/webhook/deliveries. Redirects are not followed. Events can arrive more than once and out of order, so key your handling on event.id and data.call.id.
Test mode
Your managers can create a sandbox in the dashboard (Developers → Sandbox). It is a separate test company with its own API keys, webhook URL and secret.
- The address and every endpoint are the same. Only the key changes: test keys start with
ad_test_, live keys withad_live_. - Users, trips and calls made with a test key live in the sandbox only. They never mix with your real data and never appear in your reports.
- Sandbox calls ring and connect exactly like real ones, so you can test the SDK end to end. They are never recorded or analysed.
- Every webhook event carries
"livemode": falsefor the sandbox andtruefor real traffic. - A session token is tied to the company whose key minted it, so a test token only works with test data.
Install the SDK
@appdial/react-native is a React Native library, so one integration covers Android and iPhone. It exposes the call as state plus a handful of actions, and renders no UI of its own: you design the call screens.
It needs React Native 0.74 or newer (tested on 0.86) and a development build rather than Expo Go, because it uses native audio modules. Expo projects run npx expo prebuild, and bare React Native projects link them automatically.
npm install ./appdial-react-native-0.1.0.tgz @livekit/react-native@3.0.0 @livekit/react-native-webrtc@144.2.0 livekit-client@2.22.3
During the preview, AppDial sends you the package as a file, appdial-react-native-0.1.0.tgz, with your account, together with its SHA-256 so you can check it arrived whole. Put it next to your package.json and run the command above. The other three packages are the audio modules it runs on, so they must be installed in your app too, at the versions shown: those are the versions the SDK is tested with, and the package refuses newer majors of them until they have been tested.
With Expo, add the two config plugins and rebuild the native projects:
npm install --save-dev @livekit/react-native-expo-plugin@1.0.2 @config-plugins/react-native-webrtc@15.0.2
{
"expo": {
"plugins": [
"@livekit/react-native-expo-plugin",
"@config-plugins/react-native-webrtc"
]
}
}
Then follow your platform: Android setup and iPhone setup.
Android setup Supported
Permissions
Declare the audio and network permissions. The SDK asks the user for the microphone at call time, so you don't need your own prompt.
{
"expo": {
"android": {
"permissions": [
"RECORD_AUDIO",
"MODIFY_AUDIO_SETTINGS",
"INTERNET",
"ACCESS_NETWORK_STATE",
"BLUETOOTH_CONNECT"
]
}
}
}<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />BLUETOOTH_CONNECT lets the SDK route audio to a Bluetooth headset on Android 12 and newer.
What you get
- Audio routing. Drivers start on the speaker (hands-free) and customers on the earpiece. A connected Bluetooth or wired headset always wins. Change the defaults with
defaultAudioOutput. - The microphone prompt. If the user refuses, the call ends with
permission_deniedbefore anything is sent, and an incoming call is declined so the caller isn't left ringing. - Calls that outlive the screen. To keep a connected call going when the driver leaves your app, Android needs a foreground service for the microphone and the call. AppDial's call layer (see Ringing when closed) provides one, with its permissions.
Ringing a closed app
With the app closed, a call reaches the phone as a push notification. On Android this needs a Firebase project, a few device settings and a native call layer. It is covered in Ringing when closed.
Calls work on emulators with a microphone, but push, the lock screen, Bluetooth and battery behaviour only show up on a real device. Test on at least one phone from each of the makers your drivers use.
iPhone setup Supported
Permissions and build settings
Add the microphone usage text. The system asks the user the first time a call needs it, and a refusal ends the call with permission_denied.
{
"expo": {
"ios": {
"infoPlist": {
"NSMicrophoneUsageDescription": "Allow microphone access so you can talk during in-app calls.",
"UIBackgroundModes": ["voip", "audio"]
},
"entitlements": { "aps-environment": "production" }
},
"plugins": [
["expo-build-properties", { "ios": { "deploymentTarget": "16.4" } }]
]
}
}<key>NSMicrophoneUsageDescription</key>
<string>Allow microphone access so you can talk during in-app calls.</string>
<key>UIBackgroundModes</key>
<array>
<string>voip</string>
<string>audio</string>
</array>The audio background mode keeps a call going when the user leaves your app. The voip mode and the aps-environment entitlement are only needed for ringing a closed app. Set the iOS deployment target to 16.4 or newer, then run pod install in the ios folder (Expo does it during prebuild).
Audio routing
On iPhone, "earpiece" means the system's default route, which includes connected headsets and AirPods. The speaker is a forced override: toggleSpeaker() switches between the two.
Ringing a closed app
The iPhone rings a closed app through a VoIP push and Apple's CallKit. Apple requires a paid Apple Developer Program account for this, and an APNs key that you hand to AppDial. The steps are in Ringing when closed. Until that is set up, calls ring while your app is open.
The simulator cannot receive VoIP pushes and has no proper audio route. Use a device for anything involving ringing, headsets or the lock screen.
Using the SDK
Wrap your app
<AppDialProvider> goes around the part of your app where a signed-in user can call or be called. It starts watching for incoming calls and refreshes the session token for you.
import { AppDialProvider } from '@appdial/react-native';
const getToken = async () => (await api.post('/me/appdial-token')).token; // stable function
export default function App() {
return (
<AppDialProvider baseUrl="https://app.appdial.io" getToken={getToken}>
<Navigation />
</AppDialProvider>
);
}
A new getToken function rebuilds the call engine. Define it outside your component, or memoise it, and let it change only when the user signs in or out.
Show the call
useCall() returns the current call and every action. Build whatever screens you like on top of it.
import { useCall } from '@appdial/react-native';
function TripScreen({ trip }: { trip: { id: string } }) {
const call = useCall();
if (call.status === 'incoming') {
return (
<Incoming
name={call.peer?.displayName}
subtitle={call.tripLabel}
onAccept={() => call.accept()}
onDecline={() => call.decline('I will call you back')} // an optional quick reply
/>
);
}
if (call.status !== 'idle' && call.status !== 'ended') {
return (
<InCall
name={call.peer?.displayName}
status={call.status} // dialing | ringing | connecting | connected | reconnecting
connectedAt={call.connectedAt}
muted={call.muted}
onMute={call.toggleMute}
onSpeaker={call.toggleSpeaker}
onHangup={call.hangup}
/>
);
}
if (call.status === 'ended') {
return <Ended reason={call.endReason} onRate={call.rate} onClose={call.reset} />;
}
return <Button title="Call customer" onPress={() => call.dial(trip.id)} />; // YOUR trip id
}
That is the whole integration. The other side's app starts ringing (status: 'incoming') with no extra code.
The SDK plays no ringtone or ringback. Play your own while the status is incoming (the ringtone) and ringing on an outgoing call (the ringback tone), and stop when the status changes. Tell the user the call is being recorded when call.recorded is true: the call also plays a spoken notice itself.
Outside components
For a list row or a navigation action, use the imperative shortcuts. They act on the mounted provider:
import { AppDial } from '@appdial/react-native';
await AppDial.dial('order-8812');
await AppDial.hangup();
const state = AppDial.getState();
Headless engine
The engine behind the hook works without React:
import { AppDialClient, nativePlatform } from '@appdial/react-native';
const client = new AppDialClient({ baseUrl, getToken }, { platform: nativePlatform });
await client.start();
client.subscribe((state) => render(state));
await client.dial('order-8812');
Call state and actions
States
One call at a time per device. Outgoing calls go idle → dialing → ringing → connected. Incoming calls go idle → incoming → connecting → connected. Either can pass through reconnecting, and both finish at ended.
| Field | Meaning |
|---|---|
status | idle, dialing, ringing, incoming, connecting, connected, reconnecting or ended. |
direction | outgoing or incoming. |
peer | { displayName, avatarUrl } of the other side. Never a phone number. |
tripId, tripLabel | Your trip id, and the label you set on it. |
connectedAt | Epoch milliseconds when audio connected, for a call timer. |
muted | Whether this device's microphone is muted. |
audioOutput, availableOutputs | Where audio plays (earpiece, speaker, bluetooth or headset), and the outputs the user can pick right now. |
quality | This device's link: excellent, good, poor, lost or unknown. |
reconnectingSince | When the current reconnect began, for "Reconnecting… 12s". |
peerReconnecting | The other side dropped and is being waited for. |
peerReply | Outgoing: the quick reply the customer sent when declining. |
recorded | The call is being recorded. Show a notice. |
expiresAt, actionToken | Incoming: when it stops ringing, and a token a notification can use to decline without a session. |
endReason | Why the call ended. See below. |
error | A readable detail, when there is one. |
End reasons
| endReason | Meaning |
|---|---|
hangup | This user hung up. |
remote_hangup | The other side hung up, or left for good. |
declined | The customer declined (outgoing), or this user declined (incoming). |
missed | Nobody answered before the ring timeout. |
answered_elsewhere | Incoming: another device of this user answered. |
not_allowed | The trip isn't active, or this user isn't on it. |
permission_denied | The microphone permission was refused. |
network | The connection was lost and could not be recovered in time. |
failed | Anything else went wrong. See error. |
Actions
| Action | What it does |
|---|---|
dial(tripId) | Calls the other person on your trip. Resolves once it is ringing. |
accept(callId?) | Answers the incoming call. Pass a callId when answering from a notification. |
decline(reply?) | Declines, optionally with a quick reply the caller sees ("On my way"). |
hangup() | Ends the call. |
setMuted(b), toggleMute() | Mutes or unmutes the microphone. |
setAudioOutput(o), toggleSpeaker() | Moves audio between the earpiece, speaker and any connected headset. |
rate(score) | Rates the call that just ended, 1 to 5 (answered calls only). |
reset() | Clears an ended call back to idle. |
Configuration
| Prop | Default | Notes |
|---|---|---|
baseUrl | required | Your AppDial server address, https://app.appdial.io. |
getToken | required | () => Promise<string>. Called at start, shortly before expiry, and after any 401 (then the request is retried once). |
defaultAudioOutput | { driver: 'speaker', customer: 'earpiece' } | Where audio goes when a call starts. |
incomingPollIntervalMs | 2000 | How often the app checks for incoming calls while in the foreground. |
maxReconnectMs | 60000 | How long to try restoring a dropped call before ending it with network. |
noiseFilter | none | An optional hook that returns an on-device noise-cancellation processor for the microphone. If it fails, the call carries on with the standard noise suppression. |
logger | none | (level, message, extra) => void for diagnostics. |
Ringing when closed
While your app is open, the SDK finds incoming calls by itself. When it is closed or the phone is locked, the call has to arrive as a push notification and be turned into a ringing call screen. AppDial sends the pushes. You choose how to show them:
- AppDial's call layer (recommended): a ready-made native module for Android and iPhone, used by AppDial's own demo app. It registers the push token, draws the full-screen call screen, integrates with the phone's calling features and keeps the call alive in the background. Ask your AppDial contact for it.
- Your own push stack: register tokens and hand the pushes to the SDK with the three calls below, and show the call notification yourself.
Android: set up
- Use your Firebase project and add your Android app to it. Put
google-services.jsonin your app. - Give AppDial the project's service account key (a JSON file, from Firebase project settings → Service accounts). AppDial stores it encrypted and uses it only to send your calls' pushes. Share it with your AppDial contact, never by public channels.
- Register the device token after sign-in (below).
iPhone: set up
- Join the Apple Developer Program, and give your app's ID the Push Notifications capability.
- Create an APNs authentication key (a
.p8file) in your Apple developer account. - Give AppDial the key's contents, its Key ID, your Team ID and the app's bundle id. AppDial stores the key encrypted and never returns it.
- Add the
voipbackground mode (see iPhone setup) and register the VoIP token after sign-in (below).
Every VoIP push must be shown to the user as a CallKit call. An app that receives a VoIP push and doesn't report a call is terminated by iOS, and repeated misses stop VoIP delivery altogether. That is why AppDial sends VoIP pushes to iPhones only for calls and the call layer reports every one.
The three SDK calls
import { useEffect } from 'react';
import { Platform } from 'react-native';
import { useAppDial } from '@appdial/react-native';
export function PushSetup({ token, projectOrBundleId }: { token: string | null; projectOrBundleId: string }) {
const client = useAppDial();
// 1. After sign-in, register this install so calls can ring it.
// Android: the FCM token and your Firebase project id.
// iPhone: the VoIP token and your app's bundle id.
useEffect(() => {
if (!token) return;
client.registerPushToken(token, projectOrBundleId, Platform.OS === 'ios' ? 'ios' : 'android').catch(() => {});
}, [client, token, projectOrBundleId]);
// 2. Hand AppDial's pushes to the SDK, from your push handler. A call rings
// at once instead of on the next check, and a cancel stops it. Duplicates
// are ignored. It returns true when the call state changed.
const onPush = (data: Record<string, string>) => client.receivePush(data);
// 3. On sign-out, stop this device ringing for the user.
const onSignOut = () => token && client.unregisterPushToken(token);
return null;
}
The push messages
All values are strings. Android receives them as FCM data messages and iPhone as VoIP pushes.
| type | Fields |
|---|---|
incoming_call | callId, callerName, callerAvatarUrl, tripId, tripLabel, expiresAt (ISO time), actionToken |
call_cancelled | callId, reason: answered, declined, missed or ended |
chat_message Android | tripId, messageId, senderName, preview, kind |
Declining from the notification
A "Decline" button can reject the call even when your app isn't running, using the push's actionToken. No session is needed:
curl -X POST "https://app.appdial.io/calls/$CALL_ID/push-reject" \
-H "Content-Type: application/json" \
-d '{ "actionToken": "...", "reply": "I will call you back" }' # reply is optional
Android device settings
Phone makers differ, so a call can be delayed or silenced by settings the user controls. The call layer can check them and open the right screen. Guide your drivers through these on first use:
- Notifications allowed (a runtime permission on Android 13 and newer).
- Full-screen call alerts allowed, so the call can light up a locked screen (Android 14 and newer).
- Battery: "Unrestricted" for your app.
- Autostart, on phones that have such a setting (for example Xiaomi, Oppo, Vivo, Huawei and some Samsung and OnePlus models).
More than calls
The same session also carries a few things your app can use. They are on useAppDial() and on client.api.
Call history, ratings
import { useAppDial, useCall } from '@appdial/react-native';
// Inside a component:
const client = useAppDial();
const call = useCall();
const items = await client.history({ tripId: 'order-8812', limit: 20 });
// each: callId, direction, peer, status, trip, createdAt, durationSeconds, replyMessage, myRating
await call.rate(5); // the customer rates a call that just ended, 1 to 5
const mine = await client.myRating(); // a driver's own rating: { score, qaAverage, customerAverage, ... }
Trip chat
Drivers and customers can message each other per trip, with text, voice notes and a shared location. Numbers stay private here too. The chat becomes read-only when the trip ends (active: false).
const { items, unread, active } = await client.api.messages(tripId);
await client.api.sendMessage(tripId, 'I am at the gate');
await client.api.sendVoice(tripId, audioBlob, 'audio/mp4', durationMs);
await client.api.sendLocation(tripId, { lat: 30.0444, lng: 31.2357, accuracyM: 12 });
await client.api.markRead(tripId);
| Message kind | Meaning |
|---|---|
text, voice | A written message, and a voice note (client.api.voiceUrl(tripId, messageId) returns a link to play it). |
quick | A quick reply sent instead of answering a call. |
location | A shared location, with its accuracy in metres. |
Quiet location for your live map
await client.api.reportLocation(tripId, { lat, lng }); // dashboard only; the other side never sees it
Built-in behavior
- Reconnection. The connection resumes on network changes and the call shows
reconnectinginstead of dropping. Retries come at 0, 0.3, 1, 2 and 3 seconds, then every 5 seconds, up tomaxReconnectMs(60 seconds by default). After that the call ends withnetwork. If the other side drops,peerReconnectingistrueuntil they are back, and the call ends withremote_hangupif they don't return. - Audio quality. A speech preset of about 24 kbps Opus, with DTX (nothing is sent in silence) and RED (redundant audio so packet loss doesn't cut out syllables), plus echo cancellation, noise suppression and auto gain.
- Audio routing. Drivers start on the speaker and customers on the earpiece. A connected headset always wins on Android, and on iPhone "earpiece" is the system default route.
- Microphone permission. Requested at call time. A refusal ends the call with
permission_deniedbefore anything reaches the server, and an incoming call is declined so the caller isn't left ringing. - Session tokens.
getToken()is called on start, again shortly before the token expires, and on any401. - Battery. Nothing runs while the app is idle except the customer's incoming-call check, every two seconds and only while the app is in the foreground. While a call rings, the caller checks every two seconds for a decline or a timeout. Nothing else polls.
- One call at a time. Dialing while a call is in progress throws, and an incoming call that arrives during one is ignored.
Troubleshooting
| Symptom | Likely cause and fix |
|---|---|
The call ends at once with not_allowed | The trip isn't active, or the user isn't one of its two people. Check the trip's status and the ids you registered. |
permission_denied | The microphone was refused. Ask the user to allow it in the phone's settings, then try again. |
| The other side doesn't ring while the app is open | Make sure that app is signed in with <AppDialProvider> mounted, and that its user is the trip's other person. The foreground check runs every two seconds. |
| Android: no ring when the app is closed | Check that the device token is registered, that your Firebase service account is saved with AppDial, and the device settings above: notifications, full-screen alerts, battery and autostart. |
| iPhone: no ring when the app is closed | This needs the Apple Developer Program account, the APNs key saved with AppDial, the voip background mode, and a real device. |
Requests fail with 401 | Your getToken() returned an expired token, or one minted by a different company's key (a live token against test data, or the reverse). |
| Connected, but no sound | Check the microphone permission and the audio output, and test on a real device. Make sure nothing else in your app is holding the microphone or the audio session, for example another voice or call library. |
network after a while | The connection was lost for longer than maxReconnectMs. Raise it if your drivers regularly lose signal for longer. |
| Webhooks don't arrive | The URL must be public https. Read GET /v1/webhook/deliveries for the status codes and errors, and make sure you answer with a 2xx quickly. |
| Signature check fails | Verify against the raw request body, with the secret of the right environment (live and sandbox have different secrets). |
Security and privacy
Privacy is the point of the product, so it is built into how the pieces fit, not added on top.
- No phone numbers, anywhere. You never send AppDial a number, and no API response, webhook or app screen ever shows one. People are known by your ids and display names.
- Only the right two people can call. A call needs an active trip, and only that trip's driver and customer can start one. Anything else is refused with
not_allowed. - Your key stays on your server. AppDial stores only a hash of each API key. It is shown once, and you can rotate or revoke keys at any time. Apps get short-lived session tokens that are signed, last one hour by default, and belong to one user of one company.
- Companies are isolated. Every request is scoped to your company. Something that belongs to another company looks like it doesn't exist (
404), and you only ever see your own ids. - Encrypted in transit. Every API call and the signalling channel use TLS, and call audio is encrypted with DTLS-SRTP.
- Webhooks you can trust. Each delivery is signed with HMAC-SHA256 over a timestamp and the body. AppDial only delivers to public
httpsaddresses, checks the address again before each send, and does not follow redirects. - Recordings are private. They sit in private storage and are reached only through short-lived signed links. Every recorded call starts with a spoken notice and a short tone. Opening a recording from the dashboard is written to the activity log.
- Push keys are protected. Firebase and APNs keys are stored encrypted and are never returned by any API.
- Control over your dashboard. Roles (manager, supervisor, viewer), accounts limited to one team, optional two-step sign-in with an authenticator app, one-time invite and reset links, rate-limited sign-in, and an activity log of who did what, when and from where.
- AI review is opt-in. It is off until it is switched on for your company. When it is on, the audio of your calls is processed by an AI service to produce the transcript and summary. Sandbox calls are never analysed. Ask your AppDial contact for the data-processing details.
Dashboard
Everything your calls produce is visible to your team in a web dashboard, in English or Arabic, dark or light. It shows only your company's data.
| Area | What it gives your team |
|---|---|
| Reports | Calls per day, outcomes, answer time and answer rate, with filters by date and team, tables per driver, customer and date, and CSV export. Recordings play right in the call log. |
| Live now | Calls that are ringing or in progress, an alert when the answer rate drops, and a live map of drivers and drop-offs when you send positions. |
| Quality review | Supervisors review calls with stars, a checklist and notes. Reviews feed each driver's rating together with customers' ratings. |
| AI review Optional | Transcript, summaries in English and Arabic, the reason for the call, its outcome, flags and a suggested score. Flagged calls show up in Live now. |
| Alerts | Rules on missed-call rate, average rating, failure rate and answer time, delivered by email or webhook, with a history your managers can acknowledge and resolve. |
| Teams and people | Teams, role-based accounts, invites, two-step sign-in and an activity log. |
| Developers | API keys, your webhook and its recent deliveries, and the sandbox. |
Errors and limits
Errors are JSON, { "error": "…", "code"?: "…" }, with a conventional status:
| Status | Meaning |
|---|---|
400 | Invalid input. The message says which field. |
401 | Missing or invalid API key (or session token). |
403 | A suspended company or user, or the action isn't allowed. |
404 | Not found, including anything that belongs to another company. |
409 | Conflict: a role or a trip party that doesn't match what is already stored. |
Limits
| Item | Limit |
|---|---|
| Ids (user, trip) | Up to 200 characters. Use your own. |
| Display name | Up to 200 characters. |
| Trip label | Up to 120 characters. |
| Team name | Up to 80 characters. |
| Photo and logo URLs | https only, up to 500 characters. |
| Call list page | limit 1 to 100 (default 20), with offset. |
| Ring time | An unanswered call stops ringing after about 45 seconds and becomes missed. |
| Session token | One hour by default. |
| Recording link | One hour in a webhook and five minutes from the API, by default. |
| Webhook delivery | 10-second timeout, and eight attempts over about a day. |
Go-live checklist
- Trips follow your orders. You register the trip when a driver is assigned, and set it to
completedorcancelledwhen the order ends. - The token endpoint is protected. It sits behind your own sign-in and mints a token only for the signed-in user.
- Keys are safe. The live API key is in your server's secret store, not in the app or in source control, and you know how to rotate it.
- Webhooks are handled. You verify the signature on the raw body, reject old timestamps, answer quickly and deduplicate on
event.id. - Permissions and texts are set. The microphone usage text on iPhone, the audio permissions on Android, and your own wording in the call screens, including the recording notice.
- Android push works. Your Firebase service account is saved with AppDial, and you tested ringing a closed app on phones from different makers.
- iPhone push works. Your APNs key is saved with AppDial, the
voipbackground mode is on, and you tested on a real iPhone. - You tested in the sandbox, end to end, with two devices.
- You switched to the live key, and made a real call that appeared in your dashboard.
Versions and support
| Component | Current |
|---|---|
@appdial/react-native | 0.1.0 Preview |
| Webhook API version | 2026-09-24, sent as apiVersion in every event |
The SDK is in preview. Its call engine is covered by automated tests and runs in AppDial's own Android and iPhone apps.
How we change things
Changes to the API and webhooks are additive: new fields and new events can appear, and existing ones aren't renamed or removed. Ignore fields you don't recognise. A change that could break an integration comes with a new apiVersion.
Get help
Write to contact-us@appdial.io for access to the SDK, your keys, push setup or anything in these docs. Live service health is at appdial.io/status.