Docs

Add Snag to your app

Install the SDK, configure it at launch, identify signed-in users, and connect your subscriptions. Or copy the prompt and let your AI coding agent do it.

Get your SDK key →

Install with AI

Paste this into Claude Code, Cursor, Codex or any coding agent that can edit your project. Replace pk_live_YOUR_KEY with the public SDK key from Settings → SDK keys. Review the changes before you ship them.

Install prompt
Install the Snag SDK in this mobile app.

1. Work out the platform: native iOS (Swift), native Android (Kotlin), React Native, Expo or Flutter. Docs: https://snag.cx/docs
2. Add the Snag SDK for that platform.
3. Configure it once at launch with my public SDK key, pk_live_YOUR_KEY (Snag dashboard → Settings → SDK keys):
   - iOS: Snag.configure(appKey: "pk_live_YOUR_KEY") in App.init or application(_:didFinishLaunchingWithOptions:)
   - Android: Snag.configure(this, "pk_live_YOUR_KEY") in Application.onCreate
4. After the user logs in, call identify with their user ID and a userHash: HMAC-SHA256 of the user ID with the Snag identity secret, computed on our server and returned to the app. Never put the identity secret in the app. Pass email and name if the app has them.
   - iOS: Snag.identify(userId:userHash:traits:)
   - Android: Snag.identify(userId, userHash = …, traits = SnagTraits(…))
5. Call Snag.logout() when the user logs out.
6. Add a "Help" or "Contact us" entry that opens the messenger with Snag.presentMessenger().
7. If the app sells subscriptions, pass Snag.appAccountToken as appAccountToken (StoreKit) or obfuscatedAccountId (Play Billing) when starting a purchase.

Don't change unrelated code. When you're done, show me the changes and list anything I still need to set up in the Snag dashboard.

iOS

Swift Package, iOS 15 and later, no dependencies. In Xcode, choose File → Add Package Dependencies and add the Snag library to your app target.

Swift
import Snag

// On launch (App.init or application(_:didFinishLaunchingWithOptions:))
Snag.configure(appKey: "pk_live_…")

// After your user signs in
Snag.identify(userId: user.id,
              userHash: user.snagHash,
              traits: SnagTraits(email: user.email, name: user.name))

// Open the messenger from a Help button
Snag.presentMessenger()

// On sign out
Snag.logout()

Android

Kotlin with Jetpack Compose UI, Android 8.0 (API 26) and later.

Kotlin
// Application.onCreate
Snag.configure(this, "pk_live_…")

// After your user signs in
Snag.identify(user.id, userHash = user.snagHash,
              traits = SnagTraits(email = user.email))

// Open the messenger from a Help button
Snag.presentMessenger(activity)

// On sign out
Snag.logout()

Flutter

The snag_flutter plugin wraps the native SDKs, so the messenger, help center and cancel flow are the same native screens. iOS 15+ with Swift Package Manager, Android 8.0 (API 26) and later.

Dart
import 'package:snag_flutter/snag_flutter.dart';

// In main(), before runApp
await Snag.configure('pk_live_…');

// After your user signs in
await Snag.identify(user.id, userHash: user.snagHash,
    traits: SnagTraits(email: user.email));

// Open the messenger from a Help button
Snag.presentMessenger();

// On sign out
await Snag.logout();

Identify users

userHash proves a user ID came from your app. Compute it on your server as HMAC-SHA256 of the user ID, keyed with the identity secret from Settings → SDK keys, as a hex string. Send it to the app with the signed-in user. Never put the identity secret in the app itself.

Node.js
import { createHmac } from "node:crypto";

const snagHash = createHmac("sha256", process.env.SNAG_IDENTITY_SECRET)
  .update(user.id)
  .digest("hex");

Subscriptions

Connect the App Store and Google Play in Settings → Store connections, or connect RevenueCat, Superwall or Adapty in Settings → Integrations. The SDK reports each purchase and links it to the signed-in user.

If you start purchases yourself, pass Snag.appAccountToken as StoreKit’s appAccountToken or Play Billing’s obfuscatedAccountId. Then store notifications match the right person even before the app reports the purchase.

Swift
let options: Set<Product.PurchaseOption> =
    Snag.appAccountToken.map { [.appAccountToken($0)] } ?? []
let result = try await product.purchase(options: options)

If Snag is unreachable

The SDKs never block your app or throw at it. Every call returns immediately and does its network work in the background; failures go to the optional completion callback.

  • Events are saved on the device and sent when Snag is reachable again, each exactly once.
  • Retries spread out over time, and the SDK waits as long as the server asks it to.
  • Chat reconnects by itself, and an unsent message can be retried from the conversation.
  • If we ever need to pause Snag for your app, the SDK goes quiet until it’s switched back on.

Connect your AI agent

Snag runs an MCP server, so any agent that speaks the Model Context Protocol can work your inbox and churn moments. Create a secret key in Settings → SDK keys. Each key gives access to one app. Keep it on your server or in your agent’s config, never in your app.

Claude Code
claude mcp add --transport http snag https://api.snag.cx/mcp \
  --header "Authorization: Bearer sk_live_YOUR_SECRET_KEY"
Cursor · .cursor/mcp.json (or any client that takes a URL and headers)
{
  "mcpServers": {
    "snag": {
      "url": "https://api.snag.cx/mcp",
      "headers": { "Authorization": "Bearer sk_live_YOUR_SECRET_KEY" }
    }
  }
}

Your agent gets these tools:

search_usersFind users by name, email or user id
get_userProfile, subscription and recent events
list_conversationsSupport conversations, newest first
read_conversationA conversation’s full history
replyAnswer in-app, with push if they’re offline
track_eventTrack an event, which can start workflows
list_segmentsSegments with live user counts
list_workflowsWorkflows with enrollment and conversions
search_help_centerSearch published help-center articles

Agents can’t give refunds, change plans or delete data through Snag. Those stay with your team.

React Native and Expo

The @snag/react-native package wraps the native SDKs, so the messenger, help center and cancel flow are the same native screens. It works in Expo apps (with a development build, not Expo Go) and in bare React Native apps that have Expo modules installed. iOS 16.4+, Android 8.0 (API 26) and later.

app.json (Expo)
"plugins": ["@snag/react-native"]
TypeScript
import Snag from '@snag/react-native';

// Once, when the app starts
await Snag.configure('pk_live_…');

// After your user signs in
await Snag.identify(user.id, { userHash: user.snagHash,
  traits: { email: user.email } });

// Open the messenger from a Help button
Snag.presentMessenger();

// On sign out
await Snag.logout();