Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debugRevenueCatOverlay: display receiptURL #2652

Merged
merged 2 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/Purchasing/Purchases/Purchases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,10 @@ internal extension Purchases {
return self.systemInfo.responseVerificationMode.publicKey
}

var receiptURL: URL? {
return self.receiptFetcher.receiptURL
}

}

#endif
Expand Down
43 changes: 33 additions & 10 deletions Sources/Support/DebugUI/DebugContentViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
import StoreKit
import SwiftUI

#if os(macOS)
import AppKit
#endif

// swiftlint:disable file_length

@available(iOS 16.0, macOS 13.0, *)
struct DebugSwiftUIRootView: View {

Expand Down Expand Up @@ -113,18 +119,35 @@ internal struct DebugSummaryView: View {
Text("Loading...")

case let .loaded(config):
LabeledContent("SDK version", value: config.sdkVersion)
LabeledContent("Observer mode", value: config.observerMode.description)
LabeledContent("Sandbox", value: config.sandbox.description)
LabeledContent("StoreKit 2", value: config.storeKit2Enabled ? "on" : "off")
LabeledContent("Offline Customer Info",
value: config.offlineCustomerInfoSupport ? "enabled" : "disabled")
LabeledContent("Entitlement Verification Mode", value: config.verificationMode)

ShareLink(item: config, preview: .init("Configuration")) {
Label("Share", systemImage: "square.and.arrow.up")
Group {
LabeledContent("SDK version", value: config.sdkVersion)
LabeledContent("Observer mode", value: config.observerMode.description)
LabeledContent("Sandbox", value: config.sandbox.description)
LabeledContent("StoreKit 2", value: config.storeKit2Enabled ? "on" : "off")
LabeledContent("Offline Customer Info",
value: config.offlineCustomerInfoSupport ? "enabled" : "disabled")
LabeledContent("Entitlement Verification Mode", value: config.verificationMode)
LabeledContent("Receipt URL", value: config.receiptURL?.absoluteString ?? "")
#if os(macOS)
.contextMenu {
Button {
if let url = config.receiptURL {
NSWorkspace.shared.selectFile(
nil,
inFileViewerRootedAtPath: url.deletingLastPathComponent().path
)
}
} label: {
Text("Show in Finder")
}
}
Comment on lines +132 to +143
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you can open the folder in macOS :)

#endif

ShareLink(item: config, preview: .init("Configuration")) {
Label("Share", systemImage: "square.and.arrow.up")
}
}
.textSelection(.enabled)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also allowed selecting text here.

.frame(maxWidth: .infinity)
}
}
Expand Down
4 changes: 3 additions & 1 deletion Sources/Support/DebugUI/DebugViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class DebugViewModel: ObservableObject {
var storeKit2Enabled: Bool
var offlineCustomerInfoSupport: Bool
var verificationMode: String
var receiptURL: URL?

}

Expand Down Expand Up @@ -125,7 +126,8 @@ private extension DebugViewModel.Configuration {
sandbox: purchases.isSandbox,
storeKit2Enabled: purchases.storeKit2Setting.isEnabledAndAvailable,
offlineCustomerInfoSupport: purchases.offlineCustomerInfoEnabled,
verificationMode: purchases.responseVerificationMode.display
verificationMode: purchases.responseVerificationMode.display,
receiptURL: purchases.receiptURL
)
}

Expand Down
3 changes: 2 additions & 1 deletion Tests/UnitTests/Support/DebugViewSwiftUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class DebugViewSwiftUITests: TestCase {
sandbox: true,
storeKit2Enabled: true,
offlineCustomerInfoSupport: true,
verificationMode: "Enforced"
verificationMode: "Enforced",
receiptURL: URL(string: "file://receipt")
))
model.diagnosticsResult = .loaded(())
model.customerInfo = .loaded(try Self.mockCustomerInfo)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.