Skip to main content

Integrating Customer Center on iOS

Installationโ€‹

Release

Before integrating the Customer Center in iOS, you need to add the RevenueCatUI SDK 5.14.0 or higher to your app.

Using SPMโ€‹

If you already have RevenueCat in your project:โ€‹

  1. Open your project settings and select "Package Dependencies":

Change version

  1. Double-click and make sure version is at least 5.14.0:

Configure version

  1. Open your target settings and find "Frameworks, Libraries, and Embedded Content":

Find frameworks in your target

  1. Add RevenueCatUI:

Add RevenueCatUI dependency

First time integrating the RevenueCat SDK:โ€‹

  1. Click File -> Add Packages...

  2. Search for git@github.com:RevenueCat/purchases-ios.git and make sure version is at least 5.14.0:

Adding purchases-ios dependency

  1. Add RevenueCat and RevenueCatUI SPM dependency to your project:

Add paywall

Using CocoaPodsโ€‹

Add the following to your Podfile:

pod 'RevenueCat'
pod 'RevenueCatUI'

Integrationโ€‹

You can use the CustomerCenterView directly:

import RevenueCatUI
...

var body: some View {
Group {
NavigationStack {
HomeView()
.navigationTitle("Home")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button {
} label: {
Image(systemName: "line.3.horizontal")
}
}
ToolbarItem(placement: .topBarTrailing) {
Button {
self.isCustomerCenterPresented = true
} label: {
Image(systemName: "person.crop.circle")
}
}
}
}
}
.foregroundColor(.white)
.sheet(isPresented: $isCustomerCenterPresented) {
CustomerCenterView()
}
}

Or via a modifier:

import RevenueCatUI
...

VStack {
Button {
self.presentingCustomerCenter = true
} label: {
TemplateLabel(name: "Customer Center", icon: "person.fill")
}
}
.presentCustomerCenter(isPresented: self.$presentingCustomerCenter) {
self.presentingCustomerCenter = false
}

Listening to eventsโ€‹

We've added a way to listen to events that occur within the CustomerCenterView:

CustomerCenterView { customerCenterAction in
switch customerCenterAction {
case .restoreStarted:
case .restoreFailed(_):
case .restoreCompleted(_):
case .showingManageSubscriptions:
case .refundRequestStarted(_):
case .refundRequestCompleted(_):
}
}

If using the modifier:

.presentCustomerCenter(
isPresented: self.$presentingCustomerCenter,
customerCenterActionHandler: { action in
switch action {
case .restoreCompleted(let customerInfo):
case .restoreStarted:
case .restoreFailed(let error):
case .showingManageSubscriptions:
case .refundRequestStarted(let productId):
case .refundRequestCompleted(let status):
case .feedbackSurveyCompleted(let surveyOptionID):
}
}
) {
self.presentingCustomerCenter = false
}

Setup promotional offersโ€‹

Promotional Offers allow developers to apply custom pricing and trials to new customers and to existing and lapsed subscriptions. Unique promotional offers can be assigned to different paths and survey responses in the Customer Center, but first they must be setup in App Store Connect.

The Customer Center will automatically show offers based on specific user actions. By default we have defined it for cancellations but it can be modified to any of the defined paths. Refer to configuring App Store Connect promotional offers for detailed instructions.

Learn more about configuring the Customer Center in the configuration guide.