Post

Replies

Boosts

Views

Activity

Handle no internet access edge case on StoreKit 2
Is there a way to programmatically know if the user cant access their currentEntitlements due to an internet error (or any other error really) in StoreKit 2? If a user has no internet access when they first open an app, and they had previously purchased some items for this app on another device, they will not get access to these items on the device with no internet. This makes perfect sense, but we should have a way to inform the user this is the reason they can't access their items. When this happens I get the following error in Xcode: Error enumerating all current transactions: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={AMSStatusCode=0, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <33FA368E-0213-4D4D-AF53-C93CE9E32018>.<1>, NSErrorFailingURLKey=https://mzstorekit-sb.itunes.apple.com/inApps/v1/history?guid=00008027-001970E00185002E&reason=initial, _kCFStreamErrorDomainKey=1, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <33FA368E-0213-4D4D-AF53-C93CE9E32018>.<1>" ), NSLocalizedDescription=The Internet connection appears to be offline., NSErrorFailingURLStringKey=https://mzstorekit-sb.itunes.apple.com/inApps/v1/history?guid=00008027-001970E00185002E&reason=initial, NSUnderlyingError=0x281c314d0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_NSURLErrorNWPathKey_desc=unsatisfied (No network route), _kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _kCFStreamErrorCodeKey=50} Which is great, but I can't catch it anywere in my code to trigger UI changes. Do you know how could I catch this error? Thanks!
0
0
558
Jun ’23
How to show the monthly price of a yearly subscription in StoreKit 2?
Hi! I can show the total yearly (or 6-month) auto renewable subscription price using displayPrice just fine, but I also want to show how much that would be per month, as I think its more enticing. I could just use price and divide by 12 (or 6), but then I wouldn't know how to show the local currency symbol next to the price. According to my googling this is easy to do in StoreKit 1 using SKProduct, but how do I do it in StoreKit 2 using Product? Thanks! PD: I'd also love to be able to test the different locales to make sure their prices/currency symbols are showing correctly.
1
0
894
May ’23
Get debug symbols for SwiftUI functions as well as app's
Hi, I have some crash reports which I want to symbolicate. When I do so (following Apple's guide, and many of the other ones you can find online) I always get a partially symbolicated crash report. By partially I mean it only symbolicates the calls to code belonging to my app, but not the lines belonging to native frameworks like SwiftUI. How can I symbolicate the lines in my crash report which belong to native iOS frameworks like SwiftUI? PD: I tried the native XCode way of symbolicating by dragging the crash report into the device's logs. I also tried extracting the dSYM file from the app's archive and then using the symbolicatecrash tool. Both work, but only partially.
0
0
544
May ’23
3 year old bug in SwiftUI's Navigation Bar still present. Anyone know a good workaround?
It is well known that a trailing button on a SwiftUI navigation bar is hard to tap. Its tappable area seems to be covered by a trailing inset, making it not register taps correctly (its as if the trailing half of its tappable area is disabled). I wrote a minimum reproducible example to make it clearer. struct ContentView: View { var body: some View { NavigationView { Text("Hello, world!") .navigationBarItems( trailing: Button(action: { print("Tapped!") }) { Image(systemName: "plus") } ) } .navigationViewStyle( StackNavigationViewStyle() ) } } Copy and paste this on a new Xcode project, run it on an iPhone (not a simulator, it works fine there), and try to tap the plus button, you'll see what I mean. Anyone have a way to get around this? I've tried the usually suggested ones like .imageScale(.large), overlaying a rectangle, and using other types of view with a .onTapmethod, but they don't work. Thanks!
1
0
576
Mar ’23
Did Apple really remove the ability to handle navigation with enums outside of List views in iOS 16?
In iOS 15 you used to be able to do something like they do in the Fruta sample SwiftUI app: Define an enum which will hold which screen the user is currently in enum NavigationItem {     case menu     case favorites     case recipes } And then add links in your app to modify the current screen enum, triggering a screen transition. NavigationLink(tag: NavigationItem.menu, selection: $selection) { SmoothieMenu() } label: { Label("Menu", systemImage: "list.bullet") } The problem is that migrating to iOS16 Swift now warns me with: 'init(tag:selection:destination:label:)' was deprecated in iOS 16.0: use NavigationLink(value:label:) inside a List within a NavigationStack or NavigationSplitView Did Apple really decide to force us to chose between containing all our links inside Lists and not using enums to define the current screen? It seems overly restrictive for no reason and forces me to write some really ugly hacks to have stand-alone links that don't belong to a list.
2
0
650
Mar ’23