/TipJar

Simple app showing how to implement a Tip jar with RevenueCat and SwiftUI

Primary LanguageSwiftMIT LicenseMIT

TipJar

Simple app showing how to implement a Tip jar with RevenueCat and SwiftUI

Table of Contents

  1. Requirements
  2. Install RevenueCat package
  3. Create In-App Purchases in App Store Connect
  4. Configure project in RevenueCat
  5. Configure App Key
  6. Test application

Requirements

Step 1

  1. Install RevenueCat package in your project

Go to File > Add Packages > Search for https://github.com/RevenueCat/purchases-ios.git

Pasted Graphic

  1. Select RevenueCat in the list

Package Product

Step 2

  1. Create project in App Store Connect

image

  1. Create In-App Purchases

  2. Go to Features > In-App Purchases and add a new one

image

Once inside choose Availability, Price, Localization and very important Review information with an image and save it. Create as many In-App purchases as you want

image

NOTE: If your In-App purchase has the status of Missing Metadata, it means something is missing and this could prevent RevenueCat from getting it

  1. Create an App-Specific Shared Secret

Go to General > App Information under App-Specific Shared Secret click on Manage

image

And then in Generate

image

This key will be used when we configure the RevenueCat project

Step 3

  1. Create project in RevenueCat

image

image

  1. Select App Store app, App Bundle ID is the one you find in your Xcode project under Signing & Capabilities and then set the previously created secret key in your project from App Store Connect

image

image

  1. Create Products

Go to Products and create a new one

Identifier should be the same as the Product ID in the App Store Connect

image

Create a Product for each In-App purchase you have created

image

  1. Create Offerings

Identifier and description could be anything

image

Click on your new Offering and create a New Package

image

You can select a default identifier depending on the recurrence of your In-App purchase but in this case as we are creating a tip jar, I will put a custom identifier with the title of each In-App purchase

image

After creating all the necessary Packages

image

You will need to assign your Products to each Package

Select a Package and click on Attach

image

Select the corresponding Product

image

Now you will be able to see all the Products attached to your Packages

image

  1. Create an Entitlement

image

Click on your created Entitlement

image

And Attach all your Products

image

Step 4

Configure your RevenueCat public key in your Xcode project

Go to API Keys in RevenueCat and copy the Public app-specific API keys

image

And then paste that key into you app

image

You can import the IAPManager.swift and the TipJarView.swift into your project to validate your In-App Purchases

Note: Remember to inject the SuscriptionsManager into your main view

  @StateObject var subscriptionManager = IAPManager()

  var body: some Scene {
      WindowGroup {
          ContentView()
              .environmentObject(subscriptionManager)
      }
  }
  init() {
      Purchases.logLevel = .debug
      Purchases.configure(withAPIKey: "PublicKeyFromRevenueCat") //Public key from RevenueCat project
  }

Step 5

Testing your app

If you run your app, you should be able to see all your In-App Purchases that are in status Ready to Submit in the App Store Connect

image

And that is it, to test your In-App Purchases you have to create a Sandbox Tester in App Store Connect and toggle to Sandbox Data in RevenueCat