Code Monkey home page Code Monkey logo

supersimpleinapppurchasedemo's Introduction

Super Simple In-App Purchase Demo

Overview

This app aims to demonstrate a minimal setup for an in-app purchase, using the most up-to-date available tools at time of writing. Namely:

  • StoreKit 2
  • SwiftUI
  • Observability framework
  • iOS 17+ StoreKit views (ProductView, StoreView or SubscriptionStoreView)

I've assumed the following requirements:

  • A single, non-consumable in-app purchase. Typically this would be used for unlocking a premium feature.
  • Must cater for Strong Customer Authentication (SCA) or Ask to Buy.
  • Must work online and offline.
  • Must handle purchases that took place on another device.

Why did I make this?

As I've been learning StoreKit 2, I've tried to create a sample app that demonstrates the best practices as I understand them.

While Apple's Backyard Birds sample code is comprehensive, it contains a lot more than I need and is rather overwhelming.

Other examples that I've read are typically out-of-date or incomplete in some aspect. For example, they may be using StoreKit views but not the new observability framework. Or they may demonstrate handling a purchase, but not how to check for existing purchases on app start-up.

This demo app is intended to fill these gaps, document my learnings and serve as a quick reference. I want it to be a minimal, end-to-end, working example.

As this topic and my understanding of it continue to evolve, I have no doubt that this repository will soon also be out-of-date and/or incomplete. ๐Ÿ™‚

Running the app

The app uses a StoreKit configuration file for local testing.

  • Click the scheme and choose Edit Scheme.
  • Go to the Options tab.
  • For StoreKit Configuration, select SuperSimpleInAppPurchaseConfig.storekit.

Now the app is ready to run on simulator or device.

Animation showing an in-app purchase of a premium feature

References

https://developer.apple.com/documentation/swiftui/backyard-birds-sample https://developer.apple.com/documentation/storekit/in-app_purchase/implementing_a_store_in_your_app_using_the_storekit_api https://github.com/RevenueCat/storekit2-demo-app https://swiftwithmajid.com/2023/08/01/mastering-storekit2/ https://www.hackingwithswift.com/quick-start/swiftui/how-to-add-in-app-purchases-in-swiftui

supersimpleinapppurchasedemo's People

Contributors

lorin-vr avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.