Introducing a new way to review your PRs.

Read the announcement

appwrite / sdk-for-react-native

[READ ONLY] Official Appwrite React Native SDK 💙 ⚛︎

View on GitHub

24 documents · Updated Nov 18, 2026

docs / application-and-integration-services

Application and integration services

The application and integration services connect external applications to Appwrite. They manage app registration and credentials, grant access through OAuth 2, record product events, and deliver push messages to signed-in users or chosen topics.

Service boundary

The SDK exposes four related services for this area. Apps manages the app records that define clients and installations. Oauth2 runs authorization and token flows. Analytics sends event data. Push keeps topic subscriptions and delivers messages to the React Native app. All four services are public SDK exports and use the configured Client; see src/index.ts• L1-28.

Service roles

Each service owns a different part of the integration lifecycle. An application supplies the identity and access rules for an external client. OAuth 2 turns a user decision into a grant and then into tokens. Analytics records activity. Push carries later messages to a running or backgrounded app.

ServiceSystem roleMain result
AppsRegisters applications and controls their access resourcesApplication, credential, installation, or token records
Oauth2Coordinates user consent and token exchangeRedirect URLs, grants, tokens, and access lists
AnalyticsRecords an event for an analytics propertyAccepted tracking event
PushSubscribes a React Native app to message topicsCallback messages and optional local notifications

References: src/index.ts• L1-28 src/…/apps.ts• L11-14 src/…/oauth-2.ts• L6-9 src/…/analytics.ts• L5-8 src/…/push.ts• L123-146

Application registration

An application is the shared definition of an external client. It holds the client-facing details used on consent screens, redirect destinations, OAuth 2 client type, device-flow support, team ownership, and the scopes requested for team installations.

Application lifecycle

The Apps service supports the full application lifecycle. Engineers can discover available OAuth 2 and installation scopes, create or update an app, transfer it between teams, and remove it when it is no longer trusted. Application settings define the boundaries used later by authorization and installation flows. An app can also define where a user returns after an installation change; see src/…/apps.ts• L548-638, src/…/apps.ts• L177-197, src/…/apps.ts• L747-794, and src/…/apps.ts• L2290-2413.

Application records also support registered post-logout destinations. This lets an OAuth 2 client end a user session and return the user to a destination that the app has declared.

References: src/…/apps.ts• L148-192 src/…/apps.ts• L548-638 src/…/apps.ts• L747-794 src/…/apps.ts• L1141-1193 src/…/apps.ts• L2290-2413

Application credentials

An app key is an app-management credential. It has no service scopes and is used with the app identity to inspect that app’s installations or create installation access tokens. A client secret is an OAuth 2 client credential. Confidential clients use it at the token or revocation boundary, while public clients use PKCE instead of storing a secret.

The service can list, create, inspect, and delete both credential types. Creating a client secret returns its plaintext form, so the caller must treat that result as the credential hand-off point; see src/…/apps.ts• L1580-1926 and src/…/apps.ts• L1928-2287.

References: src/…/apps.ts• L1580-1774 src/…/apps.ts• L1776-1926 src/…/apps.ts• L1928-2122 src/…/apps.ts• L2124-2287

Application installations

An installation records an app’s relationship with a team. It keeps the scopes and authorization details granted to that installation. App owners or an app key can list and inspect installations, while app update access is needed to delete one.

An installation token carries the granted scope and authorization details into later API calls. Updating or deleting an installation revokes previously issued installation tokens, and the app service can also revoke all tokens for an app; see src/…/apps.ts• L1195-1484, src/…/apps.ts• L1486-1578, and src/…/apps.ts• L2415-2470.

References: src/…/apps.ts• L1195-1312 src/…/apps.ts• L1314-1484 src/…/apps.ts• L1486-1578 src/…/apps.ts• L2415-2470

See Application management and installations for the detailed application resource lifecycle.

OAuth 2 authorization

The Oauth2 service supports the complete path from an authorization request to usable access tokens. It supports browser-based authorization, public clients with PKCE, OpenID Connect values, device authorization for input-limited devices, pushed authorization requests, consent decisions, token exchange, logout, and token revocation.

Authorization request flow

An OAuth 2 client starts by sending its client identity, redirect URI, response type, scope, and optional security values such as state, nonce, or a PKCE challenge. The service can store that request first through PAR, which returns a short-lived request_uri; the client then passes that handle to authorization.

When a signed-in user reaches the consent step, the app reads the grant details and chooses approval or rejection. Approval returns a redirect URL for the client. Rejection returns a redirect URL with the denied result. The client exchanges a returned authorization code, refresh token, or device code for access and refresh tokens.

The diagram shows the main browser and device paths. Both paths converge on a grant decision or token exchange.

flowchart LR
    A[Client request] --> B[Authorize or PAR]
    B --> C[Consent grant]
    C -->|approve| D[Redirect with code]
    C -->|reject| E[Redirect with access_denied]
    D --> F[Token exchange]
    G[Device authorization] --> H[User code]
    H --> C
    F --> I[Access and refresh tokens]
    I --> J[Appwrite APIs]

authorize and authorizePost begin the request. createPAR stores a request for later use. getGrant, approve, reject, createDeviceAuthorization, createGrant, and createToken provide the steps around consent and token issuance; see src/…/oauth-2.ts• L11-120, src/…/oauth-2.ts• L122-655, src/…/oauth-2.ts• L657-882, and src/…/oauth-2.ts• L1353-1622.

References: src/…/oauth-2.ts• L11-120 src/…/oauth-2.ts• L122-655 src/…/oauth-2.ts• L657-882 src/…/oauth-2.ts• L1353-1622 src/…/oauth-2.ts• L1737-1811 src/…/oauth-2.ts• L1927-2145

Token and resource access

OAuth 2 tokens carry the access granted during consent. The service can revoke an access or refresh token and can end an OpenID Connect session through RP-initiated logout. It can also resolve the projects and organizations that a token is allowed to access, including wildcard authorization details; see src/…/oauth-2.ts• L969-1240 and src/…/oauth-2.ts• L1242-1350.

This resource view connects OAuth 2 authorization to the identity and collaboration services. A token does not only identify a client. Its granted details also define which Appwrite resources the client may act on.

References: src/…/oauth-2.ts• L969-1240 src/…/oauth-2.ts• L1242-1350 src/…/oauth-2.ts• L1624-1735 src/…/oauth-2.ts• L1813-1925

Analytics events

The Analytics service sends one tracking event to an analytics property. It requires an event name and a page URL or screen identifier. The event can include context such as domain, referrer, screen size, session hash, scroll depth, engagement time, and custom properties.

Event names define the event class. pageview and screen_view count as views. Other names count as custom events. The interactive value marks whether an event is a visitor interaction that can end a bounce. API-key callers with the analytics write scope can override the user ID, IP address, or user agent; see src/…/analytics.ts• L10-28 and src/…/analytics.ts• L175-272.

References: src/…/analytics.ts• L5-28 src/…/analytics.ts• L175-272

See Analytics tracking for the client-side tracking flow and its relation to push activity.

Push delivery

The Push service provides Appwrite push delivery for React Native without requiring FCM or APNs as the message path. A subscription matches one or more topics and sends each matching message to a callback. A topic-less subscription targets the signed-in user’s topic, which gives application code a user-level delivery path.

Push subscriptions

Subscriptions are live handles. The caller can unsubscribe or update background delivery, notification titles, foreground notification behavior, and retry behavior without creating a new handle. The service waits for broker subscription acknowledgement before resolving a new subscription, so a publish that follows an awaited subscribe does not race the registration.

The service can connect push delivery to an analytics tracker. A background message that produces a notification records push_received, and a notification tap records push_opened; each event can carry the Appwrite Messaging message ID. This links delivery activity to the same tracking service without changing the message callback contract; see src/…/push.ts• L429-465.

Retry uses at-least-once delivery for a subscription. Turning retry off selects at-most-once delivery. The callback receives the topic, text data, raw payload, and quality-of-service value; see src/…/push.ts• L27-37 and src/…/push.ts• L480-711.

References: src/…/push.ts• L27-37 src/…/push.ts• L71-115 src/…/push.ts• L429-465 src/…/push.ts• L480-711

Background delivery

A subscription can continue while the app is in the background or closed. The service can post a local notification for a matching message and reports notification taps through an initial-notification read or a notification-opened listener. Android may use a native host and foreground service; other platforms use the supported background task and notification peers.

Background delivery depends on platform limits and permissions. The service exposes a status check and user-directed requests for exact alarms or battery-optimization exemption on Android. A caller should use these signals when it needs timely delivery rather than assuming that a closed app always receives a message at once; see src/…/push.ts• L39-105 and src/…/push.ts• L296-421.

References: src/…/push.ts• L39-105 src/…/push.ts• L296-421 src/…/push.ts• L1010-1124 src/…/push.ts• L1238-1265

Push configuration

Push uses the client’s authentication and project settings. The client can set a dedicated MQTT broker endpoint and a stable push client ID. If no push endpoint is set, the push service derives its broker host from the normal endpoint; see src/client.ts• L273-289 and src/client.ts• L364-401.

The credential matters to delivery scope. A JWT or session must be present before the service can open a user-authenticated connection. Saved background subscriptions resume with the current session when possible, and signing out must close delivery when the app no longer has a valid user credential; see src/…/push.ts• L251-257 and src/…/push.ts• L1371-1389.

References: src/client.ts• L273-289 src/client.ts• L364-401 src/…/push.ts• L251-257 src/…/push.ts• L1324-1382

See OAuth, analytics, and push integration for the detailed integration flows.

Cross-service relationships

These services form a chain rather than a single feature. An app definition supplies redirect and credential rules. OAuth 2 creates access that can reach Appwrite resources. Analytics measures activity from a client or server. Push provides a later delivery path that uses the client’s current identity and can report receipt and open activity to analytics.

The application service and the team services meet at installations. The application owns the integration, while a team grants it scopes and authorization details. For team identity and membership context, see Identity and collaboration services. For shared client setup and request behavior, see Client configuration and requests.

References: src/…/apps.ts• L586-632 src/…/apps.ts• L1195-1578 src/…/oauth-2.ts• L122-138 src/…/push.ts• L429-465 src/…/push.ts• L1324-1382

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to application redirect or post-logout URI rules must stay aligned with the OAuth 2 authorize and logout inputs.
  • Changes to installation scopes or authorization details must stay aligned with installation tokens and the resource lists exposed by OAuth 2.
  • Changes to app key or client secret meaning must preserve the difference between app-management access and OAuth 2 client authentication.
  • Changes to push endpoint or client ID settings must preserve the broker session and replay behavior across foreground and background delivery.
  • Changes to push credentials must cover session rotation and sign-out so saved background subscriptions do not use stale access.
  • Changes to push notification receipt or open events must stay aligned with the analytics tracking event contract and message ID fields.

Important failure modes

TriggerConsequenceGuard
A public app omits the PKCE challenge or verifierAuthorization or token exchange failsKeep PKCE values with the authorization request and send the matching verifier at token exchange
A redirect URI is not registered on the appAuthorization cannot return safely to the clientRegister the exact redirect URI before starting the flow
An installation is updated or deletedExisting installation access tokens are revokedTreat installation changes as token changes and obtain a new token
Background push is requested without the required native or peer supportSubscription setup fails or falls back to foreground deliveryCheck platform support and use the background status and permission APIs
Push delivery starts without a JWT or sessionThe broker connection cannot authenticateSet the client credential before subscribing
Push tracking is set without a usable analytics trackerPush receipt or open activity is not recordedConfigure the tracking service before calling setTracking

Key files

FileWhy to read it
src/index.tsShows the public service exports and push value types
src/…/apps.tsDefines application, credential, installation, and installation-token lifecycles
src/…/oauth-2.tsDefines authorization, consent, PAR, device, token, logout, and revoke flows
src/…/analytics.tsDefines the event contract and accepted tracking context
src/…/push.tsDefines topic subscriptions, message callbacks, background delivery, notification handling, and push analytics hooks
src/client.tsDefines push endpoint, push client ID, project, and credential settings used by the services