iOS

A Swift package with native SwiftUI screens and UIKit presentation. iOS 17+, Xcode 15.3+ (Swift 5.10+).

Install#

In Xcode choose File → Add Package Dependencies and enter the repository URL, or add it to Package.swift:

Package.swift
dependencies: [
    .package(url: "https://github.com/nathancjohnson248-glitch/parley", from: "0.1.0")
],
targets: [
    .target(name: "MyApp", dependencies: [.product(name: "Parley", package: "parley")])
]

CocoaPods is also supported: pod 'Parley', :git => 'https://github.com/nathancjohnson248-glitch/parley', :tag => '0.1.0'.

Configure#

Configure once at launch with the public key from Applications → Install.

import Parley

@main
struct MyApp: App {
    init() {
        Parley.configure(appKey: "pk_live_…")
    }
    var body: some Scene { WindowGroup { ContentView() } }
}

Show support#

struct ContentView: View {
    @State private var showSupport = false

    var body: some View {
        Button("Contact support") { showSupport = true }
            .parleySupport(isPresented: $showSupport)
    }
}

// Or embed the support screen in your own navigation:
NavigationStack { ParleySupportView() }

The support screen lists the customer's conversations, opens the current one, and handles sending, photo and file attachments, live updates and offline retries.

Identify users#

try await Parley.identify(
    userId: user.id,
    email: user.email,
    name: user.displayName,
    userHash: session.parleyUserHash,          // from your server, see Customers & identity
    attributes: ["plan": "pro", "seats": 6]
)

// On sign-out
await Parley.logout()
NameTypeDescription
Parley.configure(appKey:options:)funcCall once at launch.
Parley.identify(userId:email:name:avatarURL:userHash:attributes:)async throwsAttach the session to your user.
Parley.updateCustomer(email:name:attributes:)async throwsUpdate details without re-identifying.
Parley.track(_:properties:)async throwsRecord an event on the customer.
Parley.logout()asyncEnd the session and start a new anonymous one.
Parley.presentSupport(from:)@MainActorUIKit presentation.
View.parleySupport(isPresented:)modifierSwiftUI sheet presentation.
Parley.state.unreadCountInt (published)Unread replies, for badges.

Unread badge#

struct SupportButton: View {
    @ObservedObject private var state = Parley.state
    var body: some View {
        Button("Support") { /* … */ }
            .badge(state.unreadCount)
    }
}

Appearance

See Appearance & text for colors, corner radius, fonts and custom strings.

Push notifications

See Push notifications to register the device token and open conversations from a notification.

The core networking layer (ParleyCore) has no UIKit dependency and is covered by unit tests that run with swift test. The SwiftUI and UIKit layers require an Apple platform build.