In-App Chat

Set up support chat in your iOS app, from turning it on to answering your first message.

Overview

This guide takes you from nothing to a working support chat in your SwiftUI app: users message your team from inside the app, you answer from the dashboard, and they see your reply live, or get a push notification if they've left the chat.

You'll need:

  • A SeggWat project on the Pro plan (chat is a Pro feature)
  • An iOS app on iOS 16+ with the iOS SDK 1.3.0 or later (1.4.0 for quoted replies)
  • An Apple Developer account, if you want push notifications or App Attest

1. Pick how users are identified

Every conversation belongs to one identity. Choose before you write any code:

Signed tokens Anonymous
Best for Apps with user accounts and a backend Apps without accounts or a server
Conversation follows the user Across devices, and shared with the web widget chat Per install, survives app restarts
You know who's writing Yes No
Reply emails when they've left Yes, if the token has an email No
Spam protection Your backend decides who gets a token App Attest

If users can sign in later, you can use both: anonymous until sign-in, then a token. Signing in starts a separate conversation; the anonymous one isn't merged.

2. Turn on chat in the dashboard

1

Open Widget Defaults

Go to Project → Settings → Widget Defaults.

2

Enable Live Chat

Turn on Live Chat. This enables chat for both the web widget and the iOS SDK.

3

Anonymous only: allow anonymous chat

Turn on Anonymous chat in apps below the Live Chat toggle. Skip this if you use signed tokens.

For signed tokens, also set up the project's signing secret under End-User Authentication.

3. Add chat to your app

Configure the SDK as usual (see the Quickstart), then connect the chat identity.

Your backend mints a short-lived token for the signed-in user, signed with the project's signing secret (claims and signing). Hand it to the SDK after sign-in and clear it on sign-out:

swift
// After sign-in
SeggWat.setChatToken(tokenFromYourBackend)

// On sign-out
SeggWat.setChatToken(nil)

That's enough for users to start chatting: the feedback form now shows a Chat with us button.

Open the chat from your own UI

To add a "Contact support" row or similar:

swift
SeggWat.presentChat()

The floating feedback button already shows an unread count. For your own badge, observe SeggWat.shared.unreadCount. It refreshes every minute in the foreground; call await SeggWat.shared.refreshUnreadCount() to update it right away.

4. Block spam (anonymous only)

Without checks, anyone can script anonymous conversations into your inbox. App Attest makes SeggWat accept only genuine installs of your app on real devices.

1

Enter your Team ID

Below the anonymous chat toggle, enter your Apple Team ID (Apple Developer account → Membership details).

2

Check your bundle ID

Make sure your app's bundle ID is in Allowed Bundle IDs.

3

Add the capability

In Xcode, add App Attest under Signing & Capabilities. No code changes: the SDK attests on its own, once per install.

5. Add push notifications

Without push, users only see your reply when they next open the app (or by email, with signed tokens). With push, their iPhone gets a notification from your app about 10 seconds after you reply, unless they've already read it in the open chat. Tapping it opens the conversation.

1

Create an APNs key

In your Apple Developer account, under Certificates, Identifiers & Profiles → Keys, create a key with Apple Push Notifications service (APNs) enabled and download the .p8 file. Keep the environment at Sandbox & Production.

2

Upload it to SeggWat

In Widget Defaults, the iOS app: push notifications card asks for your Team ID, Key ID, bundle ID and the .p8 file. Click Turn on push; SeggWat checks the key with Apple before saving.

3

Wire up your app

Add the Push Notifications capability, call SeggWat.enablePushNotifications(), and pass the device token and notification taps to the SDK with SeggWat.setPushToken(_:) and SeggWat.handleNotification(_:). The full AppDelegate code is in Wire up your app.

Don't ask for notification permission yourself: the SDK asks after the user's first chat message, when they have a reason to say yes.

6. Test it end to end

  1. Run the app on a real iPhone (the Simulator usually can't get a push token).
  2. Open the chat and send a message. Allow notifications when asked.
  3. In the dashboard, open Messages → Live chat. The message is there and your team got an in-app notification.
  4. Reply. With the chat still open, the reply appears live.
  5. Close the chat or background the app and reply again. About 10 seconds later the push arrives; tap it to land in the conversation.
  6. Push not arriving? Use Send test push on the push card. It targets the most recently registered device and shows Apple's error if delivery fails.

Answering conversations

Conversations land in Messages → Live chat in the dashboard, with items waiting on you first.

  • Quote a message: replies you quote show the quoted message above your reply in the app. Users can quote too, by long-pressing a message.
  • On the go: the SeggWat triage app shows conversations and can send quoted replies.
  • Turn a chat into work: create a feedback item (with the transcript attached) or an idea on your board from any conversation, attributed to the user.
  • Track response times: the Chat tab in Insights shows conversation volume, median first-response time and what's awaiting a reply.
  • Automate: the API can list the inbox and post team replies, including an optional reply_to_id to quote a message.

Troubleshooting

Symptom Likely cause
No Chat with us button Live Chat is off, the project isn't on Pro, or no identity is set (setChatToken / enableAnonymousChat)
Anonymous chat fails in the Simulator A Team ID is set, so App Attest is required. Clear it while testing
Anonymous chat fails on a device Bundle ID missing from Allowed Bundle IDs, or the App Attest capability isn't added
No push after a reply The user was watching the chat (no push needed), the APNs key is limited to one environment, or the app never called setPushToken
Old conversation after sign-out Call setChatToken(nil) on sign-out

Next Steps

Navigation