iOS Guide

Install

The iOS SDK is installed via Swift Package Manager in Xcode. Go to File -> Add Package Depencies..., paste in the GitHub repo URL in the upper right (https://github.com/resubscribe/resubscribe-ios-sdk) and then select 'Add Package'. Xcode will fetch the package and make it available in your project.

Usage

First import the SDK where you intend to use it.

import ResubscribeIosSdk

Then include the Resubscribe View in your view hierarchy. It doesn't take up space.

struct ContentView: View {
    var body: some View {
        VStack {
            ...
            Resubscribe.view
        }
    }
}

When you would like to open up Resubscribe, call openWithConsent, replacing the placeholder values with your own values.

Resubscribe.openWithConsent(ResubscribeOptions(
    slug: "{organization-slug}",
    apiKey: "{api-key}",
    aiType: AIType.{intent | churn},
    userId: "{uid}",
    userEmail: "{optionalEmail}"
))

The value of userId MUST be unique. If you do not have a unique user id at the point you want to make this call, we recommend generating a random value prefixed with 'anonymous-' for every user

Configuration

You can pass the following parameters into openWithConsent.

Param nameDescriptionDefault Value

aiType

This value affects how the AI interacts with the user. Options are AIType.intent and AIType.churn. They are described in the Overview page.

AIType.churn

apiKey

The secret for authenticating with Resubscribe

Required

cancelButtonText

The text shown to the user on the button for declining to chat

'Not right now'

description

The smaller text shown in the consent dialog before the user chats with our bot

Varies by aiType

onClose

A function which gets called when the user exits the experience, with a parameter of 'cancel-consent' if the user pressed the cancel button in the dialog or 'close' if they pressed the close button in the chat interface

primaryButtonText

The text shown to the user on the button for consenting to chat

'Let's chat!'

slug

The short string identifying your organization

Required

title

The large text titling the consent dialog shown before the user chats with our bot

Varies by aiType

userEmail

A contact email for the user that gets plumbed through to all reports.

userId

A unique identifier for the user in question.

Required

Last updated