Posts

Post not yet marked as solved
9 Replies
4.6k Views
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.
Posted Last updated
.
Post not yet marked as solved
2 Replies
382 Views
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()) } }
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.4k Views
Hello,Suddenly my distribution certificate disappeared, invalidating all my provisioning profiles.Is it possible to see a log or similar to know what happended?Will Xcocde delete a certificate if I activate the "Automatically manage signing" checkbox?Thanks.
Posted Last updated
.
Post not yet marked as solved
0 Replies
443 Views
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.
Posted Last updated
.
Post not yet marked as solved
0 Replies
508 Views
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.
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.4k Views
Hello,I'm creating a small app to log all the domains the iPhone uses.I use NEPacketTunnelProvider, creating a virtual interface and redirecting all DNS traffic there, which means I don't have to manage TCP flows, just extract DNS queries from IP packets, and managing UDP sessions, which is much easier than managing TCP flows.I also use NEOnDemandRuleConnect so my VPN is always connected.My app works fine and I can see how all the domains are logged properly and the user can see them. I also inject back the actual DNS responses and the network works properly (you can browse website and use apps)This is the problem I have: Sometimes, whem going to WiFi to cellular, from cellular to WiFi or airplain mode to Wifi/3G, I see how the VPN starts again (probably because NEOnDemandRuleConnect, which is what I want) but then I see that the network does not work. No websites are loaded. If I check the system console (filtering by process name, otherwise it is impossible to see anything), I see something I don't see when everything works fine:error 21:19:25.226644 +0100 Domain Checker Extension __nw_socket_service_writes_block_invoke sendmsg(fd 5, 40 bytes): [51] Network is unreachableerror 21:19:25.227015 +0100 Domain Checker Extension nw_endpoint_flow_prepare_output_frames Failing the write requests: [51] Network is unreachableSo, maybe I'm missing something but I cannot see it.The documentation is not very clear about how to implement fault tolerant VPNs/tunnels, although I saw this document that perhaps says something that could be used for that:https://developer.apple.com/documentation/networkextension/neprovider/1406740-defaultpathShould I create a KVO observer in order to start the tunnel again when the interface changes?Perhaps when "defaultPath" changes, I should reconnect, but, the problem is that my extension is not connected to anything.When going to airplane mode, 3G, WifI... I see how "defaultPath" changes, so perhaps that's what I'm missing.Do you have any idea about what I should do? Or what could I try to solve this?Thank you very much for your suggestions.
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.6k Views
Hello,I already spent a while with MeasurementFormatter but I don't find a way to format a distance (person's height) to something like "5 ft, 11 in"I can only get one unit, but not 2.I already tried LengthFormatter with isForPersonHeightUse, which works properly but only when the locale is US.I need to format the height using ft/in because that is used in the UK, despite the fact the system says metric system is used there.Is this possible?Thanks a lot.
Posted Last updated
.
Post not yet marked as solved
1 Replies
366 Views
Hello,I have a view controller container. When I transition from the first child view controller (a simple view controller) to the second one that has a tabbar and navigation bar, it appears that the initial position of the tabbar and the navigation bar are not the as expected, they are slightly outside the screen. See the GIF and the code. Do you know how can I avoid that strange animation? Or the root of the problem. Thanks. dashboardCoordinator = DashboardCoordinator() rootViewController.addChild(dashboardCoordinator!.rootViewController) let fromVC = onboardingCoordinator!.rootViewController let toVC = dashboardCoordinator!.rootViewController fromVC.willMove(toParent: nil) rootViewController.transition(from: fromVC, to: toVC, duration: 5, options: .transitionCrossDissolve, animations: nil, completion: { [weak self] finished in guard let self = self else { return } fromVC.removeFromParent() self.onboardingCoordinator = nil toVC.didMove(toParent: self.rootViewController) })Animated GIFhttps://i.stack.imgur.com/Qo5Mn.gifThanks a lot.
Posted Last updated
.