iOS is the operating system for iPhone.

Posts under iOS tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

SwiftUI, REST, and websockets
I'm coming back to iOS development after years away and diving head-first into SwiftUI. It's a lot of fun, but I've hit a brick wall. The scenario is I have a main view (which itself is a tabview, not important other than that it's not the top-level of the view hierarchy). This has subviews that rely on data coming back from a REST call to the cloud, but then some subviews need to turn around and make subsequent network calls to set up websockets for realtime updates. In the main view's .onAppear, I fire off an async REST call, it returns JSON that gets parsed into a ModelView. The ViewModel is declared in the top view like this: class ViewModel: ObservableObject { @Published var appData = CurrentREST() // Codables from JSON @State var dataIsLoaded : Bool = false func fetchData() async { await _ = WebService().downloadData(fromURL: "current") { currentData in DispatchQueue.main.async { self.appData = currentData self.dataIsLoaded = true } } } } The main view declares the model view: struct HomeTabView: View { @ObservedObject var viewModel = ViewModel() @Binding private var dataReceived: Bool ... } In the toplevel view, the REST call is triggered like this: .onAppear { if !viewModel.dataIsLoaded { Task { await viewModel.fetchData() DispatchQueue.main.async { self.dataReceived = true } } } } The viewModel gets passed down to subviews so they can update themselves with the returned data. That part all works fine. But it's the next step that break down. A subview needs to go back to the server and set up subscriptions to websockets, so it can do realtime updates from then on. It's this second step that is failing. The dataReceived binding is set to true when the REST call has completed. The viewModel and dataReceived flags are passed down to the subviews: SummaryView(viewModel: viewModel, dataIsLoaded: self.dataReceived) What needs to happen next is inside the subview to call a function to wire up the next websocket steps. I've tried setting up: struct SummaryView: View { @ObservedObject var viewModel: ViewModel @State var dataIsLoaded: Bool = false ... }.onChange(of: dataIsLoaded) { setupWebSocket() } Problem is, the onChange never gets called. I've tried various permutations of setting up a @State and a @Binding on the view model, and a separate @State on the main view. None of them get called and the subview's function that wires up the websockets never gets called. The basic question is: How do you trigger a cascading series of events through SwiftUI so external events (a network call) can cascade down to subviews and from there, their own series of events to do certain things. I haven't gone deep into Combine yet, so if that's the solution, I'll go there. But I thought I'd ask and see if there was a simpler solution. Any suggestions or pointers to best practices/code are most appreciated.
3
0
230
3w
TestFlight not working with In-app purchases
Environment react-native-iap: 12.12.2. react-native: 0.72.12. Platforms (physical & simulator): iPhone 11 - OS version 17.4 /// iOS Simulator iPhone 15 Pro Max - OS version 17.4 Description Hello, I am trying to test the purchase of a subscription and an in-app product within my react native app. I have setup the necessary Sandbox account in App Store Connect, created a Store kit file in Xcode that I also synced with the products I created in the App Store Connect dashboard. If I use Xcode to run the app on a physical device (after logging into the sandbox account), I am able to purchase a subscription/in-app product without any issues. If I purchased a subscription on the physical phone I can go into Settings > App Store > Sandbox Account Management and see the purchased subscription, change renewal rate, clear purchase history etc.. If I use the TestFlight build with a physical phone (logging in with the sandbox account) the in app purchases stop working correctly. After purchasing a subscription it is not shown in the Sandbox Account Management, so I am unable to cancel it. Upon trying to purchase another subscription the apple service keeps returning the same exact subscription that I "originally" purchased. How am I supposed to cancel that subscription if it not shown in the sandbox account subscription list? Adding a different sandbox account does not help either, trying to purchase another subscription returns the same subscription that I am unable to cancel. Is there a step in the TestFlight environment that I am missing on setup? Expected Behavior Upon purchasing a subscription in the TestFlight environment on a physical device I should be able to cancel that subscription. Here's an example of what function I am calling on purchasing a subscription: const product = { productId: 'example_monthly_subscription' }; subscribe(product.productId); Any help would be appreciated.
1
0
258
3w
Maximum Number of Bluetooth Pairings (not connections)
Hello, Our app is going to be used in an industrial setting where users will connect to many devices a day via Bluetooth to complete an installation process. They will only connect to one device at a time, so connection limit isn't an issue. What we're wondering about is the limit on number of pairings (found in Settings > Bluetooth > MY DEVICES). This is important because pairings can't be removed programatically. I seem to remember reading somewhere the limit was ~30 devices, but I can't find that document anymore. Does anyone know if this limit is correct, or where I could find a document regarding this?
1
0
209
3w
UITabBarController render glitch since iOS18 beta 1 & 2 when activating tabs.
We have a UITabBarController in our iPhone App which has 5 tabs with UITableViewControllers (constructed from the storyboard). Before iOS18 beta 1 (and 2) this was working fine without any problems (objective-C). Since iOS18 beta 1 (and beta 2 still has this problem) a strange render glitch occurs when activating a tab from the tab bar at the bottom. As soon as a tab is activated (by tapping on the icon at the bottom) the tab with the UITableViewController becomes visible and draws its content starting at the very top of the screen (pos 0,0) right through/over the Navigation bar which at that point is showing a title and a rightBarButtonItem. The tab with the UITableViewController seems not aware there is a navigation bar visible. Then after ~0.3 seconds the tab with the UITableViewContoller is automatically rendered again or moved down and now its content starts below the UINavigationBar as expected, this is 100% reproducible and occurs on every activation of a tab in the UITabBarController. Is anyone else also getting this behavior in their App since iOS18? I'm aware that UITabBarController is being renewed but I can't find any information on why this behavior might occur. I was hoping beta 2 would solve the problem but it doesn't. Constructing the UITabBarController in the code with the new UITab objects (instead of constructing them from the storyboard) also shows this problem.
3
0
277
3w
NFCTagReaderSession.PollingOption.pace fails with "Missing required entitlement" error
Hi, I'm developing an app that reads the NFC tags. So far so good, everything worked as expected, the app reads the passports and the IDs, until we encountered the french ID issued after March 2021. My app has the following entitlements: <dict> <key>com.apple.developer.nfc.readersession.formats</key> <array> <string>TAG</string> </array> </dict> And this additional entries in the .plist: <key>NFCReaderUsageDescription</key> <string>NFC usage to scan ID chip</string> ... <key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key> <array> <string>A0000002471001</string> <string>A0000002472001</string> <string>00000000000000</string> </array> According to an article which I cannot link on this forum because the domain is not permitted, iOS started supporting this specific ID from version 16. When I look at the docs, I can see the .pace polling mode was added. I tried specifying this additional polling mode in my app like so: var pollingOptions: NFCTagReaderSession.PollingOption = [.iso14443] if #available(iOS 16, *) { pollingOptions.insert(.pace) } self.session = NFCTagReaderSession(pollingOption: pollingOptions, delegate: self, queue: nil) But when I try to start the session it gets instantly invalidated with this message: Missing required entitlement. I'm pretty confident the message is misleading and something else is missing somewhere, my bet would be on the .plist entry com.apple.developer.nfc.readersession.iso7816.select-identifiers missing one of the cryptic numbers, but I have no idea where this can be taken from. How do I implement this .pace polling mode, can someone give me some guidance?
1
0
715
3w
Disable iOS Screen Mirroring for Apps
Hello Apple, I am concerned about the new iOS Screen Mirroring that is available on iOS. I have an app that is only meant to be viewed on iPhones (not Macs or Computers, due to security reasons. I am assuming that Screen Mirroring is using AirPlay underneath, otherwise is there an API being planned or coming that can disable this functionality or is there a way for my app to opt out out of iOS Screen Mirroring? Thanks.
1
0
336
3w
iPhone 11PM Bricked Overnight While Running iOS 18 Beta
So I left the phone on the counter overnight at around 50% and I didn't plug it in. The next day, the phone was dead and completely unresponsive to anything. I've already had this issue once, but without beta, and I managed to solve it by a hard reset. This time, however, the phone is completely bricked; I can't enter recovery mode, DFU mode, reset, charge, nothing. I suspect something broke when the phone was trying to update to the next beta overnight. I don't really know what to do. I want to get the phone working and off the beta, but I can't because nothing works right now.
2
0
380
3w
State Restoration: Deleting current state data
In the past, it seemed that if you used the app switcher and killed the app, that state restoration data would not persist, and starting the app again would not load any stored state data. But now (at lest in iOS 17) that is no longer the case. There are situations where the old state might cause issues, which we obviously need to fix, but users should be able to clear the state data. I am not using sessions and am using the older methods - application:shouldSaveApplicationState: and application:shouldRestoreApplicationState:. My question is, how can I tell my users to reset/clear state restoration data if needed?
0
0
156
3w
Can an automaker app and a Carplay app (when automaker is not possible) live in the same App?
Hi, I'm trying to investigate if there is any way to have an app that displays an automaker app when the Carplay environment has the automaker protocol string, and displays a Carplay App (Driving Task) when there isn't the automaker protocol string. I was able to start developing an automaker app, but with an iOS16.0 deprecated method (with UIScreen Notifications), I'm not able to do it via the scene delegate... There is any kind of documentation of how to do it? I think the clue may be in the scene delegate with the property Preferred Default Scene Session Role, where I think the automaker app is a Window Application Session Role, but the scene delegate is not triggered when I open the Carplay App in the simulator. So am I missing something? Is there a way to do it or have I to publish two apps in order to use the two kind of carplay apps... ? Thank you very much.
1
0
192
3w
Are several Proximity and Beacon related libraries methods and properties deprectaed and now unusable in iOS 18 beta?
Hi, Please let me know iOS 18 beta have deprecated/ stopped support for which of the following: proximityUUID CLBeaconRegion (instancetype)initWithProximityUUID:(NSUUID *)proximityUUID identifier:(NSString *)identifier (void)startRangingBeaconsInRegion:(CLBeaconRegion *)region -startRangingBeaconsSatisfyingConstraint: , is this also deprecated in iOS 18 beta, since: CLBeaconIdentityConstraint is deprecated right? CLBeaconIdentityCondition is not supported in XCode 15.3. What should I do for this? Should I install XCode 16 beta? locationManager:didRangeBeacons:satisfyingConstraint: can we use it in iOS 18 beta, since, CLBeaconIdentityConstraint is deprecated? what is alternative startMonitoring(for:) is also deprecated in iOS 18 beta right? Also, can someone specify or create a documentation on how beaconing shall be monitored, ranged and locationManager delegate methods pertaining to beaconing to be used in iOS 18 beta?
5
0
313
3w
IOS 18 Bata
I downloaded the iOS 18 and my iPhone 15 pro max has just been unusable. My dial pad keeps crashing my cameras don’t work, my iphone is overheating to the point my phone won’t charge, I’m not getting calls text nothing. I wish I never downloaded this Bata because now I’m forced to get a new phone and I’m sorry after this I willl NOT be getting any more iPhones!
0
0
170
3w
phone crashes, panics, and shuts down entirely after 5 minutes of use
i got the iOS 18 dev beta around a week ago (big mistake) and everything was good for a week, before it started acting up. it starts to lag immensely, then it crashes from whatever app it's currently using, panics, and then shuts down my phone. it's been going on for around a week, and i've tried everything. hard/forced reset (did the trick, now it doesn't.) tried connecting to itunes (doesn't recognise the device, either cause the cable is bad, or the version's bugged.) tried connecting to apple devices (same reason as the previous.) recovery mode (STILL doesn't recognise the device.) i'm going on a trip to norway in 2 days, so getting my phone fixed is essential. i do recall having a backup with iOS 17, yet i don't know if i can back up versions from 1-2 weeks ago. i might book a reservation at a genius bar to see what's going on. i'm on an iphone se (3rd gen), and have been using it for about 1 and a half years. this issue is most likely due to the iOS beta, and i don't have a clue on what else might be affecting this. can someone help me out here? it would be greatly, GREATLY appreciated.
0
0
141
3w
SwiftUI iOS 17 White screen when I return back with Navigation Stack
When using the Navigation Stack with paths, I've faced an issue where tapping the 'back' button on the custom navigation bar results in a blank screen. With light theme the screen is white, when using dark theme the screen is black. I've found a decision with using an environment value to dismiss a single screen when needed. However, the problem becomes more prominent when I want to pop back to the root view. This issue has become since updating to iOS 17.
2
3
1.1k
3w
navigationDestination + NavigationPath broken on iOS 17
Using the new navigationDestination and NavigationPath functions previously on iOS 16 everything has been working fine using a custom back button, which calls path.removeLast(). However, if we try this on iOS 17, the screen being removed flashes white. You can try this code as an example (NOTE THE WHITE FLASH ON REMOVE LAST): struct DetailView: View { @Binding var path: NavigationPath var body: some View { ZStack { Color.black VStack(alignment: .center) { Spacer() Button(action: { path.removeLast() }, label: { Text("BACK") }) Spacer() } } } } struct ParentView: View { @State var path: NavigationPath = .init() var body: some View { NavigationStack(path: $path) { ZStack { Color.red VStack(alignment: .center) { Spacer() Button(action: { path.append("TEST") }, label: { Text("FORWARD") }) Spacer() } } .navigationDestination(for: String.self) { _ in DetailView(path: $path) } } } } Any work arounds? Suggestions?
3
2
960
3w