SDK reference
Every public function, property, hook, listener and type of Graine's in-app SDKs — React Native, iOS, Android, Flutter, Kotlin Multiplatform and the website loader — with what each is for, signatures, parameters, return values, errors and threading: one complete page per platform, and pages by topic that compare the platforms.
Everything your app can call, read or listen to, on every platform: what it is for, the exact signature, each parameter with its type, default and limits, what comes back (every field, with a real example), when it resolves, every error it can raise and why, what else it does, and which thread it runs on.
Your platform, every symbol
One complete page per SDK, for release 0.8.0. Each is grouped by use case — the same rows as Use cases by SDK, from installing to going live — then events, errors and the lower-level building blocks, and ends with every public symbol from A to Z. Every function, property, event, error and type opens with one sentence on when you use it.
React Native
@graineai/inapp-react-native 0.42.0 and @graineai/inapp-react-native-calls 0.3.0.
iOS
GraineInApp 0.8.0, Swift and SwiftUI, with the Objective-C interface.
Android
ai.graine:inapp-android 0.8.0, Kotlin, with notes for Java.
Flutter
graine_inapp 0.8.0.
Kotlin Multiplatform
ai.graine:inapp-kmp and ai.graine:inapp-kmp-compose 0.8.0.
Website
The loader, https://www.graine.ai/embed/v1.js: everything on GraineAgent.
The pages below compare the platforms topic by topic, with every platform's spelling side by side.
How to read it
- On the topic pages, one tab per platform, always in this order: React Native · iOS · Android · Flutter · Kotlin Multiplatform · Website. Choose yours once — every tab on these pages follows your choice.
- Under the tabs, in this order where they apply: Parameters (type, required, default, limits), Returns (each field and a JSON example), When it resolves, Errors (each code and why), What happens (side effects), and an example.
- JSON shows a real value as it arrives. Every platform's type has the same fields, in its own spelling — Types says how dates and enums look in each language.
- A dash in a tab or a table cell means that platform does not have it.
Kotlin Multiplatform
The Kotlin Multiplatform SDK is one API in shared code over the iOS and Android
SDKs: it follows the same contract, and each call does the same work there.
Its views (the chat, the call screen and the bar) are in
ai.graine:inapp-kmp-compose, for Compose Multiplatform. Its guide:
Kotlin Multiplatform.
The platforms
| Platform | Package | Version | Start it once | Then | Runs on |
|---|---|---|---|---|---|
| React Native | @graineai/inapp-react-native, and @graineai/inapp-react-native-calls for native calls | 0.42.0 · calls 0.3.0 | <GraineProvider> at the root | hooks, or the client from useGraineClient() | The JavaScript thread |
| iOS | GraineInApp (Swift package) | 0.8.0 | GraineInApp.configure(GraineConfig(…)) at launch | GraineInApp.shared | The main thread |
| Android | ai.graine:inapp-android | 0.8.0 | GraineInApp.init(application, GraineConfig(…)) in Application.onCreate | GraineInApp.get() | The main thread |
| Flutter | graine_inapp | 0.8.0 | GraineInApp.init(GraineConfig(…)) before runApp | GraineInApp.instance | The UI isolate |
| Kotlin Multiplatform | ai.graine:inapp-kmp, and ai.graine:inapp-kmp-compose for its views | 0.8.0 | Graine.configure(GraineConfig(…)) at launch | Graine | Any thread; suspending calls never block the main thread |
| Website | The loader script | 1.2.0 | GraineAgent.load(…) | GraineAgent | The page |
Calling anything before start-up is a programming error, said loudly: iOS stops
with a message, Android throws IllegalStateException, Flutter throws
StateError, Kotlin Multiplatform throws IllegalStateException, and a React
Native hook outside <GraineProvider> throws unless you called
setDefaultClient(client) once at start-up. The website loader buffers what you
call before load() and applies it when the widget exists. To ask first:
Graine.isConfigured (Kotlin Multiplatform) or GraineInApp.maybeInstance
(Flutter, null before init).
Several agents. A website runs one agent at a time and switches between
them: GraineAgent.load() with another agent takes the one on the page off and
resolves true once the new one is on it, the visitor still signed in.
GraineAgent.switchesAgents is true on a loader that does this (1.2.0 and
later). See Different agents on different pages.
Installing each SDK, and the options it takes when it starts, are on its own page: React Native, iOS, Android, Flutter, Kotlin Multiplatform, Website and Any other platform.
A result and a failure, per platform
The same call — reading what the agent remembers — in each platform's idiom:
A promise; a failure rejects it with a GraineError.
Every error carries a code — the same words on every platform — and a sentence
for whoever has to fix it. The codes, their HTTP statuses and their fixes are on
Errors.
Several agents (the multi-agent API)
An app can run several agents, each with its own publishable key, and choose one per screen — the guide is Use more than one agent in your app. These are the functions that name them.
React Native has no names for in-app agents: each GraineProvider is one
agent's client, and the providers share the customer, the screen and the line;
with the same storage, the install ID and memory choice too. A conversation
another agent ended closes with the reason another_agent.
name | String, default "default". Trimmed; an empty name is the default agent |
| Returns | The agent: a full SDK instance. Every function on these pages works on it and goes to that agent's key — its session, chat, voice, actions, scheduling and memory requests |
| The default agent | The one configured without a name — else, in an app that named every agent, the first one configured. Views draw it unless handed another |
| Configuring again | A name already configured returns that agent unchanged |
| Errors | None from configuring. Looking up a name never configured returns null (named, find, agent); Android's get(name) throws for one. React Native's startCall rejects for an agent configure did not name |
| Shared by all agents | Who the customer is (identify on any agent applies to all; identify(null) signs out everywhere), the install ID, the memory choice, the current screen, the call engine — and one conversation at a time |
| A view, for one agent | React Native | iOS | Android | Flutter | Kotlin Multiplatform |
|---|---|---|---|---|---|
| The bar | The nearest provider's | GraineAgentBar(graine:) | GraineAgentBarView.graine | GraineAgentBar(app:) | GraineAgentBar(agent =) |
| The chat | The nearest provider's | GraineChatView(graine:) | GraineChatView.source = GraineInApp.get(name).chat, GraineChatActivity.open(context, agent) | GraineChat(app:) | GraineChat(agent =) |
| A call | GraineCalls.startCall({ agent }) | calls.startCall(…, agent:) | calls.startCall(…, agent =) | GraineCalls.instance.startCall(…, agent:) | Graine.calls.startCall(…, agent =) |
The pages by topic
Identity and memory
identify, setMemory, the memory choice, installId, memories, forgetMemory.
Chat
The chat object: transcript, state, typing, send, reconnecting, the chat views.
Voice
Starting, ending and muting the bar's call; its state; the launcher and the bars.
Calls
Native calls: configure, push tokens, startCall, answering, the call's state, outcomes.
Scheduling
schedulingRules, scheduleCall, scheduledCalls, cancelScheduledCall.
Screen context and actions
setScreen, fields, track and taps, prompt variables, actions, components, masking.
Events and listeners
Every listener, callback, event and stream, with its payload and thread.
Types
Every structure the SDKs hand your app, field by field, with JSON.
Errors
Every code: HTTP status, meaning, what raises it, and the fix.
Every function, and where it is
Names differ slightly between platforms; the page shows each platform's own.
| Function | Page |
|---|---|
configure(…, name), named, get(name), find, all, Graine.agent, Graine.agents, GraineCalls.configure({ agents }), switchesAgents — the multi-agent API | SDK reference |
identify, useGraineIdentify | Identity and memory |
setMemory | Identity and memory |
memoryEnabled, memoryChoice | Identity and memory |
installId, getInstallId | Identity and memory |
memories, useGraineMemories | Identity and memory |
forgetMemory | Identity and memory |
identityChannel, getRawTraits, getIdentity | Identity and memory |
chat, useGraineAgent | Chat |
send, sendText, queuedTexts | Chat |
newConversation | Chat |
openChat, open(size:), chatSize, openedSize, GraineChat.open, GraineChatScreen — the window size | Chat |
chatTurnRows, GraineChatRows, ChatRows — the rows a chat window draws (every SDK) | Types |
open, close, retry, clear, isConnected, isMuted, isAgentSpeaking, networkState | Chat |
clear, clearChat, reconnecting, failed, chatFailed, retry, upcomingCalls — the chat's state, emptying it, trying again | Chat |
GraineChatView, GraineChatViewController, GraineChatActivity, GraineChat | Chat |
useGraineSurface, GraineSurface | Chat |
voice.start, end, setMuted, retry, attach, detach | Voice |
connected, phase, connectStage, quality, connectivity, captions | Voice |
captionsOn, setCaptionsOn, clearCaptions — the captions switch | Voice |
useGraineReady, useGraineInit, session, useGraineTheme, themeTokens, tokens, Graine.theme, previewDesign, isAttached, attached, viewOpened, viewClosed | Voice |
GraineVoiceLauncher | Voice |
GraineAgentBar, GraineAgentBarView, GraineVoiceBar, GraineLauncherButton, GraineWidgetView, GraineEngine | Voice |
useGraineConnection, useKeyboardLift, useDraggablePlacement, useGraineVoice, useGraineLoader | Voice |
| The website engine's messages | Voice |
calls.configure, your own call screen on Android (ACTION_SHOW, ACTION_ANSWER, EXTRA_CALL_ID, …) | Calls |
enableVoIPPushes, registerPushToken, onNewToken, handlePush, reportIncomingCall | Calls |
startCall | Calls |
callTransport, transport, transportFallbackReason, GraineCallTransport, GraineRTC.install — calls over WebRTC | Calls |
callBack, missedCall, dismissMissedCall | Calls |
answer, decline, end, setMuted, setSpeaker | Calls |
| The call's state and snapshot | Calls |
onOutcome, onIncomingCall, outcomes, incomingCalls | Calls |
GraineCalls.attach | Calls |
schedulingRules | Scheduling |
scheduleCall | Scheduling |
scheduledCalls | Scheduling |
cancelScheduledCall | Scheduling |
useGraineScheduling | Scheduling |
bookingAvailable, openBooking, presentBooking, GraineBooking.show, GraineBookingSheet | Scheduling |
upcomingCalls, refreshUpcomingCalls, cancelUpcomingCall | Scheduling |
setScreen, useGraineScreen, currentScreen | Screen context and actions |
updateField, removeField, clearScreen, useGraineField | Screen context and actions |
track, tap, reportEvent, noteInteraction, captureTap, graineTap, useGraineTap, useGraineTrack, GraineTouchCapture | Screen context and actions |
getScreen, getVariables, getRecentEvents, getAvailableActions, setAppVersion | Screen context and actions |
setVariables, currentVariables, useGraineVariables | Screen context and actions |
registerAction, registerDeferredAction, useGraineAction, checkActions, executeAction, defineAction, removeAction | Screen context and actions |
useGraineWidget, reopenComponent, answerWidget, answerComponent, submitWidget, pendingWidget, clearPendingWidget, present, presentPending, presentWidget, presentPendingWidget | Screen context and actions |
useGraineHighlight, registerHighlightable, getHighlightables, highlight | Screen context and actions |
addMaskRule, Masking.addRule, GraineMasking.addRule, maskString, maskDeep | Screen context and actions |
friction, configureFriction | Screen context and actions |
GraineListener, addListener, removeListener, Graine.events | Events and listeners |
useGraineEvents, client.on | Events and listeners |
GraineCallsListener, GraineCallListener, calls streams | Events and listeners |

