Skip to content

Commit

Permalink
chore: rename folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 10, 2024
1 parent 7d95cba commit 339e624
Show file tree
Hide file tree
Showing 18 changed files with 1,041 additions and 1 deletion.
1 change: 0 additions & 1 deletion !examples/InAppPurchaseManager
Submodule InAppPurchaseManager deleted from 393d34
Binary file added examples/InAppPurchaseManager.zip
Binary file not shown.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D4C0A5F2C3ED21B0050CB10"
BuildableName = "InAppPurchaseManager.app"
BlueprintName = "InAppPurchaseManager"
ReferencedContainer = "container:InAppPurchaseManager.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D4C0A5F2C3ED21B0050CB10"
BuildableName = "InAppPurchaseManager.app"
BlueprintName = "InAppPurchaseManager"
ReferencedContainer = "container:InAppPurchaseManager.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<StoreKitConfigurationFileReference
identifier = "../../Product.storekit">
</StoreKitConfigurationFileReference>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D4C0A5F2C3ED21B0050CB10"
BuildableName = "InAppPurchaseManager.app"
BlueprintName = "InAppPurchaseManager"
ReferencedContainer = "container:InAppPurchaseManager.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>InAppPurchaseManager.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>7D4C0A5F2C3ED21B0050CB10</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// ContentView.swift
// InAppPurchaseManager
//
// Created by 王楚江 on 2024/7/10.
//

import SwiftUI

struct ContentView: View {
@EnvironmentObject private var entitlement: EntitlementManager
@State var showingSubscriptionView = false
var body: some View {
VStack {
if entitlement.hasPro == false {
Button("Subscription Purchase") {
showingSubscriptionView.toggle()
}
} else {
Text("You have subscribed to purchase")
}
}
.padding()
.sheet(isPresented: $showingSubscriptionView) {
SubscriptionView()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// InAppPurchaseManagerApp.swift
// InAppPurchaseManager
//
// Created by 王楚江 on 2024/7/10.
//

import SwiftUI

@main
struct InAppPurchaseManagerApp: App {
@StateObject private var entitlementManager: EntitlementManager
@StateObject private var subscriptionsManager: SubscriptionsManager
init() {
let entitlement = EntitlementManager()
let subscriptions = SubscriptionsManager(entitlementManager: entitlement)
self._entitlementManager = StateObject(wrappedValue: entitlement)
self._subscriptionsManager = StateObject(wrappedValue: subscriptions)
}
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(entitlementManager)
.environmentObject(subscriptionsManager)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// SubscriptionView.swift
// InAppPurchaseManager
//
// Created by 王楚江 on 2024/7/10.
//

import SwiftUI
import StoreKit

struct SubscriptionView: View {
@Environment(\.dismiss) var dismiss
@EnvironmentObject private var subscriptions: SubscriptionsManager
@State private var message: String = ""
let privacyPolicy = URL(string: "https://wangchujiang.com/copybook-generator/privacy-policy.html")!
let termsOfService = URL(string: "https://wangchujiang.com/copybook-generator/terms-of-service.html")!
var body: some View {
if !subscriptions.products.isEmpty {
VStack {
SubscriptionStoreView(productIDs: subscriptions.productIDs)
.storeButton(.visible, for: .policies)
.subscriptionStorePolicyDestination(url: privacyPolicy, for: .privacyPolicy)
.subscriptionStorePolicyDestination(url: termsOfService, for: .termsOfService)
.onInAppPurchaseCompletion(perform: { product, result in
if case .success(.success(let transaction)) = result {
print("Purchased successfully: \(transaction.signedDate)")
await subscriptions.updatePurchasedProducts()
dismiss()
} else {
print("Something else happened")
}
})
Button(action: {
Task {
await subscriptions.restorePurchases()
dismiss()
}
}, label: {
Text("Restore Subscription")
})
#if os(macOS)
.buttonStyle(.link)
#endif
.offset(y: -22)
}
.background(.background)
.frame(minWidth: 320, minHeight: 580)
.frame(maxWidth: 450)
} else {
VStack {
if message.isEmpty {
ProgressView().progressViewStyle(.circular).scaleEffect(1).ignoresSafeArea(.all)
} else {
Text(message).foregroundStyle(.red)
}
}
.padding(.horizontal)
.frame(minWidth: 230, minHeight: 120)
}
}
}
Loading

0 comments on commit 339e624

Please sign in to comment.