dkasaj / swifttipjar Goto Github PK
View Code? Open in Web Editor NEWSwift package that lets you have a tip jar running in minutes
Swift package that lets you have a tip jar running in minutes
Hi,
I've just released my app with SwiftTipJar
integrated into my app and none of the prices are showing.
My button to send the tip also crashes my app.
During the development and in test flight the prices were shown from the store kit configuration file and everything worked fine.
Help.
Here's my code...
import SwiftTipJar
import SwiftUI
struct TipJarView: View {
@EnvironmentObject var tipJar: SwiftTipJar
@State private var showingThankYou = false
@State private var showingTipJarFailure = false
@State private var tipIndex: Int = 1
var buttonText: String {
guard !tipJar.tips.isEmpty else { return "" }
return "\(tipJar.tips[tipIndex].displayPrice)"
}
var body: some View {
VStack {
Text(Strings.settingsTipJarDescription)
.frame(maxWidth: .infinity, minHeight: 100)
Picker(.settingsTipJarPickerLabel, selection: $tipIndex) {
ForEach(0 ..< tipJar.tips.count, id: \.self) { index in
Text("\(tipJar.tips[index].displayPrice)")
}
}
.pickerStyle(SegmentedPickerStyle())
Button(action: {
showingThankYou = false
showingTipJarFailure = false
tipJar.initiatePurchase(
productIdentifier: tipJar.tips[self.tipIndex].identifier)
}, label: {
HStack {
Text(.settingsTipJarButton,
values: [buttonText])
}
.accessibilityElement()
.accessibility(addTraits: .isButton)
})
.frame(maxWidth: .infinity,
minHeight: 50,
alignment: .center)
.buttonStyle(BorderlessButtonStyle())
if showingThankYou {
Text(.settingsTipJarThanks)
.bold()
.multilineTextAlignment(.center)
.padding(15)
}
if showingTipJarFailure {
Text(.settingsTipJarFailure)
.foregroundColor(Color.red)
.multilineTextAlignment(.center)
.padding(15)
}
}
.onAppear {
tipJar.transactionSuccessfulBlock = {
showingThankYou = true
}
tipJar.transactionFailedBlock = {
showingTipJarFailure = true
}
}
}
}
struct MyApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
let tipJar: SwiftTipJar
init() {
tipJar = SwiftTipJar(tipsIdentifiers: Set([
"com.myapp.tinyTip",
"com.myapp.smallTip",
"com.myapp.mediumTip",
"com.myapp.largeTip",
"com.myapp.extraLargeTip"
]))
tipJar.startObservingPaymentQueue()
tipJar.productsRequest?.start()
}
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(tipJar)
Edit....
Hmmm
Hi,
I've been looking through the Xcode output and can't see any error...
The plug-in seems to work fine with iOS 15.4, however with iOS 14.5 it fails to return any products.
To be specific ...
tipJar.tips
= 0
I'm using Xcode 13.3.1
And using the simulator.
Any ideas ?
Thanks,
Jules.
Hi
I love the idea of this plugin.
I was thinking about how this might look, Iโm thinking I would have a number picker and probably buy me a n coffee(s).
Then I thought n coffees a month could be good too, although this would require a subscription.
Just an idea.
Jules.
This works on iPadOS and iOS, but when running the iPad app on MacOS, it crashes.
2023-06-30 15:52:20.118308-0700 Making Cents[53561:8446214] [default] LSPrefs: could not find untranslocated node for <FSNode 0x600000171180> { isDir = ?, path = '/private/var/folders/z1/y19bl3s5323d0ykjxsqdqwmc0000gp/X/2FE04D90-D134-5236-8973-9DD7F1CC0288/d/Wrapper/Making Cents.app' }, proceeding on the assumption it is not translocated: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"
2023-06-30 15:52:20.122081-0700 Making Cents[53561:8446214] [default] LSPrefs: could not find untranslocated node for <FSNode 0x600000171180> { isDir = ?, path = '/private/var/folders/z1/y19bl3s5323d0ykjxsqdqwmc0000gp/X/2FE04D90-D134-5236-8973-9DD7F1CC0288/d/Wrapper/Making Cents.app' }, proceeding on the assumption it is not translocated: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"
2023-06-30 15:52:20.125603-0700 Making Cents[53561:8446214] [default] LSPrefs: could not find untranslocated node for <FSNode 0x600000171180> { isDir = ?, path = '/private/var/folders/z1/y19bl3s5323d0ykjxsqdqwmc0000gp/X/2FE04D90-D134-5236-8973-9DD7F1CC0288/d/Wrapper/Making Cents.app' }, proceeding on the assumption it is not translocated: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"
2023-06-30 15:52:20.997610-0700 Making Cents[53561:8446214] [default] LSPrefs: could not find untranslocated node for <FSNode 0x600000171180> { isDir = ?, path = '/private/var/folders/z1/y19bl3s5323d0ykjxsqdqwmc0000gp/X/2FE04D90-D134-5236-8973-9DD7F1CC0288/d/Wrapper/Making Cents.app' }, proceeding on the assumption it is not translocated: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"
2023-06-30 15:52:21.062872-0700 Making Cents[53561:8446214] [TraitCollection] Class _UIFindNavigatorViewController overrides the -traitCollection getter, which is not supported. If you're trying to override traits, you must use the appropriate API.
2023-06-30 15:52:21.152197-0700 Making Cents[53561:8446214] [default] CGSWindowShmemCreateWithPort failed on port 0
2023-06-30 15:52:21.547331-0700 Making Cents[53561:8446214] void * _Nullable NSMapGet(NSMapTable * Nonnull, const void * Nullable): map table argument is NULL
2023-06-30 15:52:23.187601-0700 Making Cents[53561:8446214] [default] CGSWindowShmemCreateWithPort failed on port 0
SwiftUI/EnvironmentObject.swift:82: Fatal error: No ObservableObject of type SwiftTipJar found. A View.environmentObject(:) for SwiftTipJar may be missing as an ancestor of this view.
2023-06-30 15:52:23.633152-0700 Making Cents[53561:8446214] SwiftUI/EnvironmentObject.swift:82: Fatal error: No ObservableObject of type SwiftTipJar found. A View.environmentObject(:) for SwiftTipJar may be missing as an ancestor of this view.
(lldb)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.