Adjust your app’s behavior and filter incoming notifications based on the user's Focus settings.

Posts under Focus tag

18 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Focus more evolved
This message only to know your feeling on my project. Not to discuss what is feasible or not. Just on the interest of the functionality. I use 5 Focus profiles, Do Not Disturb, Holiday, Work, Personal and Sleep. I find that the native solutions for changing modes are not powerful enough. I'd like an app to configure automatically when each Focus profile should be activated. Eg : -Holiday : when holiday is found in my calendar -Work : when I'm not on holiday, when we are not on the weekend, and after 7ham but before 7pm. Personal : when I'm not on holiday when we are on the weekend of after 7pm -Dot Not Disturb: When I'm not in holiday, only on the working week when I have an event in my agenda with the status accepted". These are just some examples. the idea is that everything will be configurable. (my app is almost finished.) What do you think?
0
0
143
Nov ’24
$FocusState and Lists with rows containing TextFields
While I've seen examples of using $FocusState with Lists containing "raw" TextFields, in my use case, the List rows are more complex than that and contain multiiple elements, including TextFields. I obviously don't understand something fundamental here, because I am completely unable to get TextField-to-TextField tabbing to work. Can someone set me straight? Sample code demonstrating the issues: // // ContentView.swift // ListElementFocus // // Created by Richard Aurbach on 10/12/24. // import SwiftUI /// NOTE: in my actual app, the data model is actually a set of SwiftData /// PresistentModel objects. Here, I'm simulating them with an Observable. @Observable final class TestModel: Identifiable { public var id: UUID public var checked: Bool = false public var title: String = "Test" public var subtitle: String = "Subtitle" init(checked: Bool = false, title: String, subtitle: String) { self.id = UUID() self.checked = checked self.title = title self.subtitle = subtitle } } struct ContentView: View { /// Instead of a @Query... @State var records: [TestModel] = [ TestModel(title: "First title", subtitle: "blah, blah, blah"), TestModel(title: "Second title", subtitle: "more nonsense"), TestModel(title: "Third title", subtitle: "even more nonsense"), ] @FocusState var focus: UUID? var body: some View { Form { Section { HStack(alignment: .top) { Text("Goal:").font(.headline) Text( "If a user taps in the TextField in any row, they should be able to tab from row to row using any keyboard which supports a tab key." ) } HStack(alignment: .top) { Text("#1:").font(.headline) Text( "While I will admit that this code is probaby total garbage, I haven't been able to find any way to make tabbing from row to row to work at all." ) } HStack(alignment: .top) { Text("#2:").font(.headline) Text( "Tapping the checkbox button causes the row to flash with the current accent color, and I can't find any way to turn that off." ) } } header: { Text("Problems").font(.title3).bold() }.headerProminence(.increased) Section { List(records) { record in ListRow(record: record, focus: focus) .onKeyPress(.tab) { focus = next(record) return .handled } } } header: { Text("Example: Selector of Editable Items").font(.title3).bold() }.headerProminence(.increased) } .padding() } private func next(_ record: TestModel) -> UUID { guard !records.isEmpty else { return UUID() } if record.id == records.last!.id { return records.first!.id } if let index = records.firstIndex(where: { $0.id == record.id }) { return records[index + 1].id } return UUID() } } struct ListRow: View { @Bindable var record: TestModel var focus: UUID? @FocusState var focusState: Bool init(record: TestModel, focus: UUID?) { self.record = record self.focus = focus self.focusState = focus == record.id } var body: some View { HStack(alignment: .top) { Button { record.checked.toggle() } label: { record.checked ? Image(systemName: "checkmark.square.fill") : Image(systemName: "square") }.font(.title2).focusable(false) VStack(alignment: .leading) { TextField("title", text: $record.title).font(.headline) .focused($focusState) Text("subtitle").italic() } } } } #Preview { ContentView() }
0
0
192
Oct ’24
Focus fails when TextField includes axis: .vertical
I've found another interesting issue with the Focus system. My text case is SwiftUI in Preview or Simulator (using an iPad mini case) -- I haven't tried this on other environments, so your mileage may vary. I have a Form including several TextFields. Adding the usual @FocusState logic, I observe that if I type a TAB key, then (a) If the TextFields are specified using TextField(“label”, text: $text), typing the tab key switches focus from field to field as expected, BUT (b) If the TextFields are specified using TextField(“label”, text: $text, axis: .vertical), typing the tab key adds whitespace to the field and does NOT change focus. In the latter case, I need to use an .onKeyPress(.tab) {….} modifier to achieve the desired result. Reported as FB15432840
0
0
243
Oct ’24
10162: The SwiftUI cookbook for focus - does not work as expected with iOS 18
I try to create a sheet that shows a textfield and the textfield should gain the focus immediately after the sheet is presented. This use case is explained in Session 10162 at 11:21 and at 13:31 my desired behavior is shown. I could not get this to work in my own code and downloaded the sample code from here: https://developer.apple.com/documentation/swiftui/focus-cookbook-sample Then I opened the sample code and run it in the simulator. It does not focus when the sheet appears in a iOS 18 simulator using Xcode 16 installed via the AppStore. It does gain focus if I use the "add" Button. No changes made on the sample code. Just adjusted the Team setting to get a clean build. The behavior I get locally under iOS 18 is not what is shown in the session and I can't understand why. I tried the following Simulators (and platforms) iPhone 16, iPad Pro (M4, 11inch) and my Mac. On none of those the last item got focus just by presenting the sheet. Is it not possible to test this in a simulator? Could I have a configuration error? Given all the information I found yet, this seems like a Bug. It would be very helpful if someone could replicate my problem. Thank you for your help. Programm Versions: Xcode: Version 16.0 (16A242d) MacOS: 15.0 (24A335)
0
0
252
Sep ’24
Apps cannot be on multiple screens in iOS 18
Since using the iOS 18 beta in July I am unable to add apps to multiple screens at a time. For example, I have a screen for my work focus and I cannot add the calculator app to this screen while it is on another screen. If I try to add it to a screen it is removed from the other screen. Has anyone else noticed this? Is this expected to be fixed in iOS 18 or could it be a retrogressive feature?
0
0
344
Sep ’24
focusedSceneValue doesn't work with Window
My observations: Passing a FocusState.Binding using focusedSceneValue seems to work only when the app uses a WindowGroup. When the app uses a Window (single window) passing the FocusState.Binding in focusedSceneValue doesn't seem to work. When app uses Window passing FocusState.Binding using focusedValue and receiving it in @FocusedValue seems to work. Question: Is this expected behaviour? (should focusedSceneValue only work for WindowGroup and not for Window?)
0
0
325
Aug ’24
FocusState not working on ipad
I created this simple view to test focus in preview mode and I have no idea why it works absolutely fine on iphone, but not at all on ipad? import SwiftUI struct SimpleFocusTestView: View { @FocusState private var isFocused: Bool var body: some View { Text("Test Focus") .focusable() .focused($isFocused) .onTapGesture { isFocused.toggle() print("Tapped to toggle focus: \(isFocused)") } .onAppear { isFocused = true } .onChange(of: isFocused) { oldValue, newValue in print("Focus changed: \(newValue)") } .background { if isFocused { Capsule() .fill(.indigo) .opacity(0.3) } } } } #Preview { SimpleFocusTestView() } The printouts I get are: if I click on ipad I get this: Tapped to toggle focus: false Tapped to toggle focus: false Tapped to toggle focus: false why is it impossible to change the value of isFocused on ipad? it all works fine on iphone: Tapped to toggle focus: true Focus changed: false Tapped to toggle focus: false Focus changed: true
3
0
488
Aug ’24
Auto reply" Does not work while Focus Mode "Driving" Mode is ON
Dear Apple Support Team and Community Members, Despite the recent updates on the iOS 18.5 Beta version, several users, including myself, are experiencing issues with the Driving Focus mode. Specifically, when this mode is enabled with all the recommended settings, the iPhone fails to send auto-reply text messages to incoming callers, a critical feature meant to minimize distractions while driving. Key Issues Reported: Driving Focus Not Sending Auto-Reply Messages: Many users have meticulously configured the Driving Focus settings, ensuring that auto-reply is enabled and contacts are correctly set, but the feature still does not function as expected. Beta Updates Not Resolving the Issue: Even after installing the latest iOS 18.5 Beta updates, this problem persists, indicating that the bug has not been addressed in the current beta release. Request for Escalation and Resolution: We kindly request that this issue be escalated to the Apple development team for further investigation. Driving Focus is a crucial safety feature, and its malfunctioning could have serious implications. We hope for a prompt and concrete solution in the upcoming updates to ensure that this feature works reliably for all users. Thank you for your attention to this matter. Best regards, Tejas Desai A Concerned iOS User
1
1
329
Aug ’24
SetFocusFilterIntent `perform()` method is not called on iOS 18 beta
I’ve set up a focus filter, but the perform() method in SetFocusFilterIntent isn't called when the focus mode is toggled on or off on my iPhone since I updated to iOS 18 beta (22A5326f). I can reproduce the issue for my app, but focus filters are also broken for any third-party apps installed on my phone, so I guess it's not specific to how I've implemented my filter intent. This used to work perfectly on iOS 17. I didn't change a single line of code, and it broke completely on the latest iOS 18 beta. I've filed a bug report including a sysdiagnose (FB14715113). To the developers out there, is this something you are also observing in your apps?
0
0
397
Aug ’24
Unable to observe Focus status changes from an Intents app extension
I am writing a communication app that relies on the INShareFocusStatusIntentHandling protocol. However, it appears this API is not functional, even with the proper permissions and entitlements. Given the example code here, I am unable to trigger the logs in the INShareFocusStatusIntentHandling extension. In this code, when enabling or disabling focus, line 33 of IntentHandler.swift never gets logged, even though FocusStatusCenter is authorized for parent app, UserNotifications authorized for parent app (target), and Communication Notifications entitlement has been added to the parent app. I am also unable to hit any breakpoints in the extension. It seems as if the extension is simply never triggered -- maybe even broken at the OS-level. I have tried both iOS 17 and the latest 18 beta. Other users have reported similar difficulties in these forums. To replicate, Install the example app. Give the app UserNotifications and FocusStatus permissions. Background the app. Change focus status. Check console. Notice that the extension handler is never triggered/logged.
1
0
551
Jul ’24
SwiftUI app runs differently on hardware platforms
I have a simple SwiftUI app that has a picker, textfield and several buttons. It is using a Enum as a focus state for the various controls. When I compile and run it on Mac Studio desktop it works as expected: Picker has initial focus, Selection in Picker changes focus to TextField, Tab key moves through buttons; last button resets to Picker However when I run the exact same app on MacBook Pro (same version of MacOS, 14.5) it does not work at all as expected. Instead: Initial focus is set to TextField, Tab does not change the focus, Clicking on last button resets focus to TextField rather than Picker The content view code: enum FFocus: Hashable { case pkNames case btnAssign case tfValue case btn1 case btn2 case noFocus } struct PZParm: Identifiable { var id = 0 var name = "" } struct ContentView: View { @State var psel:Int = 0 @State var tfVal = "Testing" @FocusState var hwFocus:FFocus? var body: some View { VStack { Text("Hardware Test").font(.title2) PPDefView(bSel: $psel) .focused($hwFocus, equals: .pkNames) TextField("testing", text:$tfVal) .frame(width: 400) .focused($hwFocus, equals: .tfValue) HStack { Button("Button1", action: {}) .frame(width: 150) .focused($hwFocus, equals: .btn1) Button("Button2", action: { tfVal = "" hwFocus = .tfValue }) .frame(width: 150) .focused($hwFocus, equals: .btn2) Button("New", action: { tfVal = "" hwFocus = .pkNames }) .frame(width: 150) .focused($hwFocus, equals: .btnAssign) } } .padding() // handle picker change .onChange(of: psel, { if psel > 0 {hwFocus = .tfValue} }) .onAppear(perform: {hwFocus = .pkNames}) } } #Preview { ContentView() } struct PPDefView: View { @Binding var bSel:Int // test defs let pzparms:[PZParm] = [ PZParm.init(id:1, name:"Name1"), PZParm.init(id:2, name:"Name2") ] // var body:some View { Picker(selection: $bSel, label: Text("Puzzle Type")) { ForEach(pzparms) {Text($0.name)} }.frame(width: 250) } }
3
0
850
Jun ’24
Cannot add Focus Filter
I added a SetFocusFilterIntent to my project, but when I try to add the Focus Filter, the "add" button is disabled. I want to know why I cannot add a Focus Filter. I tried the same implementation of SetFocusFilterIntent in an empty project, and it works as expected.
0
0
407
Apr ’24
Focus Modes on Watch
I have had issue with sleep focus on my watch 8 since late in the iOS 16/ WatchOS 9 betas. I opened a feedback in Oct 2023 when 10.1 betas. When sleep focus is on the watch shows it's active and did not alert but it still works like normal. It used to go dark and I could tap the screen to see the time and press the crown to exit from that mode to use it. I wish this would be fixed. I'm tried of having to use theater mode with I go do bed. The light of the watch is
1
0
621
Feb ’24
Watch OS Sleep Focus
I have noticed since later 9.x betas that sleep focus no long switches the watch to just a clock. In the past, when sleep focus is turned on, my screen would go blank and if I tapped the screen the time would appear. if I held the crown in, it would "unlock" from time display only and allow me to use my watch. Since this has started I have posted in the feedback app starting in 10.1. Now I have to set my watch into Theater mode every night so that the screen is off and not lighting up the room. After each new beta release I update my feedback. Any idea if anyone has seen my feedback?
2
0
902
Jan ’24
Enhancing 3rd Party Alarm Clock Apps on iOS: A Call for More Flexibility and User Control
Hello Apple Community, I am writing to discuss a limitation I’ve encountered with third-party alarm clock apps on iOS. As it stands, these apps are unable to function like the native Clock app, primarily due to the restrictions imposed by the operating system. Currently, third-party alarm apps rely on standard local notifications, which fire once and then cease. This means that if a user misses the initial notification, there’s no backup mechanism to ensure they are alerted. This is a significant drawback for users who rely on these apps to manage their time effectively. Moreover, some apps have found a workaround by playing a silent sound in the background to keep the app active. However, this method is not only against Apple’s guidelines but also drains the device’s battery life. I propose that Apple consider allowing third-party apps to push notifications from the background in an alarm style, with clear permissions granted by the user. This would enable users to clearly define acceptable notifications and specify an alarm-like display, providing a more personalized and effective alarm experience. By implementing this change, Apple could greatly enhance the functionality and user-friendliness of third-party alarm clock apps, ultimately benefiting the end-users and developers alike. Because this alarm feature is so important for productivity and quick responses to critical events or triggers I'm trying to see how some concepts could be reimagined if we had a little more flexibility. Apple iOS has a feature called StandBy mode that activates when an iPhone is charging and positioned on its side. This feature can be thought of as a kind of smart display for your iPhone that offers fast access to different screens of glanceable information. Always-On Display: StandBy mode can keep the display on even when the phone is locked, which is useful for an alarm app. Users can glance at the time without having to unlock their phone w/ Low-Light Adaptation Customizable Screens: StandBy mode consists of screens that can be accessed by swiping horizontally on your iPhone’s display. This could allow an alarm app to display additional information, such as route, or weather warnings. Interactive Widgets: The widget screen in StandBy mode is interactive and customizable. I look forward to hearing your thoughts on this matter. Best regards, Phil Cutting
2
6
1.2k
Jan ’24
AVCaptureDevice.FocusMode cannot be set in iPhone15
We are developing an app which uses AVCaptureSession. Here is a part of my code: if context.config.basic_settings.auto_focus == 1 { // 自動フォーカス device.focusMode = AVCaptureDevice.FocusMode.continuousAutoFocus completion() } else { device.focusMode = AVCaptureDevice.FocusMode.locked var _lenspos = Float(context.config.basic_settings.lens_position) ?? 0.5 if _lenspos > 1.0 { _lenspos = 1.0 } if _lenspos < 0.0 { _lenspos = 0.0 } device.setFocusModeLocked(lensPosition: _lenspos, completionHandler: { (time) in completion() }) } This code can successfully set focus mode to autofoucs or manual focus and also can set lens position perfectly if we use iPhone13 or iPhone14. But If we use iPhone15, this code cannot set the focus mode or lensposition. We also tried with different iPhone15 devices, but the result is always the same(fails to set focus). And also used different iPhone13 and iPhone14 devices. But these iPhones can set the focus correctly everytime. Is it a bug of iPhone15? Or is there anything that I can do about the issue?
2
0
826
Jan ’24