Post

Replies

Boosts

Views

Activity

Problem with openSettingsURLString
Hello,Sometimes, this piece of code opens iPhone Settings (instead of app Settings)let url = URL(string: UIApplication.openSettingsURLString) UIApplication.shared.open(url!, options: [:], completionHandler: nil)But other times, it opens app settings, as the documentation says.(I am using iPhone X and iOS 12)I think the reason is that when the app does not appear in the settings list (because it is the first time that app is exectured), then openURL does not know how to open app settings (because it does not exist) and opens iphone settings. To test that, create an app with those 2 lines of code. And remember to reset the simulator entirely to test the wrong case.Do you have or see the same problem?Thanks a lot.
Topic: UI Frameworks SubTopic: UIKit Tags:
10
2
6.1k
May ’22
How can I modify layout to have a custom variable aspect ratio, or width never higher than height
I created a small component using a Text and optionally an Image, inside an HStack. Then I apply padding and clipping using a Capsule shape. Below you have the code and the results. The problem I have is that I want to constraint the component in a way that the width is always equal or higher than its height. That is, a vertical capsule is not allowed, only an horizontal capsule or a circle. I tried different approaches. For example, measure the component size using Geometry reader. We can use the .measure modifier, which basically puts everything inside .background and applies a Geometry Reader, and moves the value up using Preference Keys. Measure modifier: swiftuirecipes.com/blog/getting-size-of-a-view-in-swiftui But it does not work, looks like the HStack is returning zero, or causing issues. In any case, I was told to avoid GeometryReader whenever possible. What other approaches I could follow? There must be a way playing with .background and .layoutPriority, butI don't know exactly how to do it. Would be nice to have something like an .aspectRatio modifier where we can pass something like "1 or higher", but I have no idea about how to implement that. Do you have any idea or suggestion? Thanks a lot. [![enter image description here][1]][1] struct ContentView: View { var body: some View { VStack(spacing: 20) { Label(text: "2", showIcon: true) Label(text: "99+", showIcon: true) Label(text: "1", showIcon: false) // Case to fix } } } struct Label: View { let text: String let showIcon: Bool var body: some View { HStack { if showIcon { Image(systemName: "bolt") .resizable() .frame(width: 15, height: 15) } Text(text) } .padding(4) .background(Color.red) .clipShape(Capsule()) } }
2
0
578
Apr ’22
How do I detect a refund? (question about cancellation_date)
How do I detect a refund? (question about cancellation_date) My system uses auto-renewal subscriptions. After reading this document: https://developer.apple.com/library/archive/technotes/tn2413/_index.html#//apple_ref/doc/uid/DTS40016228-CH1-RECEIPT-HOW_DO_I_USE_THE_CANCELLATION_DATE_FIELD_ I am not sure about how to manage the refund scenario. The docs say that I have to check cancellation_date field. But what I don’t know is WHEN I will receive that. When the user requests a refund to apple and apple accepts it, will my app receive a new transaction in  func paymentQueue(_ queue: SKPaymentQueue,  updatedTransactions transactions: [SKPaymentTransaction]) the next time the user runs the app? Or do I have to use polling (my server checks every day with apple server all subscribers) or use server-to-server notifications? Thanks for clarification.
0
0
602
Dec ’20
Do I need server-to-server notifications to implement Billing Grace Period properly?
Hello, I would like to use “Billing Grace Period” But there is a scenario I don’t know how to manage. My app sends the receipt to my server, my server verifies the receipt with apple and then unlocks content. I am not using server-to-server notifications, basically because I will only have an iPhone app, moreover, seems server-to-server adds more complexity and this is a small project. The scenario I don’t know how to manage is this: Imagine I activate the “Billing Grace Period”, then the user, after buying an auto-renewal subscription, cancels it. Because the expiry date in the server takes into consideration graceperiodexpiresdatems, the real expiry date is longer, but my server does not know that the subscription was cancelled, which means the user that cancelled the subscription will always enjoy the grace period. I think in this case, when cancelling, the app does not receive any transaction or something like that From StoreKit that says that the subscription was cancelled. That is the issue. In this document: https://developer.apple.com/documentation/storekit/in-app_purchase/subscriptions_and_offers/reducing_involuntary_subscriber_churn?preferredLanguage=occ I see: “When implementing Billing Grace Period, use the verifyReceipt JSON response and server-to-server notifications. ” So, I would say it is mandatory to use server-to-server notifications to implement “Billing Grace Period” properly. Am I right? Is it totally mandatory? Thanks a lot.
0
0
707
Dec ’20