Giter Site home page Giter Site logo

vaultkit's Introduction

VaultKit

StoreKit2 interface focused on on-device validation of renewables/non-renewables.

Create StoreKit.config file

https://developer.apple.com/documentation/xcode/setting-up-storekit-testing-in-xcode

To create a StoreKit configuration file:

1. Launch Xcode, then choose File > New > File.

2. In the sheet that appears, enter storekit in the Filter search field.

3. Select StoreKit Configuration File, then click Next.

4. In the dialog, enter a name for the file. For a synced configuration file, select the checkbox, specify your team and app in the drop-down menus that appear, then click Next. For a local configuration, leave the checkbox unselected, then click Next.

5. Select a location, and click Create.

6. Save the file to your project.

Create Products

Must inherit String AND VaultProductIterable for now, as the raw Representable just checks for such. Will make more generic.

import VaultKit

struct VaultProducts {
    enum Renewable: String, VaultProductIterable {
        case monthly = "...product_id..."
        
        var kind: VaultProductKind {
            .renewable
        }
    }
    
    enum NonRenewable: String, VaultProductIterable {
        case month = "...product_id..."
        case week = "...product_id..."
        case day = "...product_id..."
        
        var kind: VaultProductKind {
            .nonRenewable
        }
    }
}

Load VaultManager

var manager = VaultManager
                        .load(
                            VaultProducts.Renewable.vaultProducts +
                            VaultProducts.NonRenewable.vaultProducts
                        )

Purchase Product

manager.purchase(VaultProducts.Renewable.monthly)

Restore Purchases

manager.restorePurchases()

Check Purchase

manager.isPurchased(VaultProducts.Renewable.monthly)

Retrieve Metadata

public struct Metadata {
    let displayName: String
    let displayPrice: String
    let isRenewable: Bool
    let isPurchased: Bool
}
manager.metadata(VaultProducts.Renewable.monthly)

//Statically available
VaultManager.metadata(VaultProducts.Renewable.monthly)

Helpers

//VaultManager.swift

public var isSubscribed: Bool { get }

public var products: [VaultProduct] { get }

public var renewableProducts: [VaultProduct] { get }

public var nonRenewableProducts: [VaultProduct] { get }
//Preserves ordering of the enum that stores your products
manager.products.ordered 

//Returns the collection as Metadata objects, best for UI display cases
//Identifiable and Codable
manager.products.ordered.asMetadata
manager.products.asMetadata

vaultkit's People

Contributors

pexavc 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.