Post

Replies

Boosts

Views

Activity

When to call transaction.finish() when using currentEntitlementTask
When using the new currentEntitlementTask ViewModifier to check for the status of a non-consumable IAP when should you call transaction.finish()? Also, since currentEntitlementTask will trigger whenever the app/view is run it will call transaction.finish every time. Is it bad to repeatedly call .finish on a already finished transaction? Currently my app works fine when making purchases and using currentEntitlementTask and @Environment to grant access to the purchased content but I know that all the transactions are unfinished and the docs say you should call transaction.finish() to tell StoreKit that you have given the user access to the content. Thanks for any help/advice here.
1
0
491
May ’24
SwiftUI changing keyboard type resets scroll on Form
I am seeing an issue in my SwiftUI app where when I have a Form with multiple TextField types that use different keyboards it causes the scrolling to reset when taping on a new textfield that changes the keyboard. In my sample code below if you do the following: Tap "Field 1" -> Scroll down -> tap "Field 3" or "Field 5" It will change the open keyboard to the numberPad/decimalPad keyboard and reset the views scrolling to the top resulting in your focused field to be behind the keyboard. If you do the following instead: Tap "Field 1" -> Scroll down -> tap "Field 2" or "Field 4" It will focus on the new textfield and NOT reset the view scrolling, working as intended. This issue seems to only affect the number keyboards as if you notice in my sample "Field 4" has the emailAddress keyboard and it doesn't cause the scroll reset. It also doesn't seem to happen when you move focus from a number field to a standard keyboard text field or tap a number field as your first focus. Has anyone else seen this issue or have any ideas on fixes/workarounds for this? import SwiftUI struct ContentView: View { @State private var stringOne: String = "" @State private var stringTwo: String = "" @State private var stringThree: String = "" @State private var numberOne: Int = 1 @State private var decimalOne: Double = 0.0 var body: some View { Form { Section("Section 1:") { TextField("Field 1", text: $stringOne) Spacer() Spacer() Spacer() Spacer() Spacer() Spacer() Spacer() Spacer() } Section("Section 2:") { TextField("Field 2", text: $stringTwo) TextField("Field 3", value: $numberOne, format: .number) .keyboardType(.numberPad) } Section("Section 3:") { TextField("Field 4", text: $stringThree) .keyboardType(.emailAddress) TextField("Field 5", value: $decimalOne, format: .number) .keyboardType(.decimalPad) } } } } #Preview { ContentView() }
1
1
432
Apr ’24