Post

Replies

Boosts

Views

Activity

Reply to About the problem that DeviceActivityMonitorExtension does not work
On February 9, I encountered the situation where the monitoring process was killed again. The monitoring processes of my two different applications were all killed, and I don’t know why. The only difference is that on February 8, I updated the system. However, on February 8, the monitoring still existed. In order to reduce memory, I used static methods in monitoring. And they were all looped at 0:00.
Topic: App & System Services SubTopic: General Tags:
Feb ’25
Reply to About the problem that DeviceActivityMonitorExtension does not work
After it expired on February 9, it also expired on February 14. The failure codes are as follows: let deviceActivityCenter = DeviceActivityCenter() let deviceActivityName = DeviceActivityName( "GoalHabit-" + habit.id.uuidString ) let startInterval = DateComponents(hour : 0, minute : 0) let endInterval = DateComponents(hour : 23, minute : 59) let schedule = DeviceActivitySchedule( intervalStart: startInterval, intervalEnd: endInterval, repeats: true ) do{ try deviceActivityCenter.startMonitoring( deviceActivityName, during: schedule, events: [deviceActivityEventName : deviceActivityEvent] ) return true }catch { return false } deviceActivityEvent is an action to be performed after reaching the threshold override func eventDidReachThreshold(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName) { super.eventDidReachThreshold(event, activity: activity) let viewContext = PersistenceController.shared.container.viewContext let (year, month, day) = getYearMonthDay(.now) let newHabitRecord = HabitRecord(context: viewContext) newHabitRecord.id = UUID() newHabitRecord.habitId = id newHabitRecord.year = Int16(year) newHabitRecord.month = Int16(month) newHabitRecord.day = Int16(day) newHabitRecord.duration = middleValue * 60 // 当前思考的秒 newHabitRecord.type = 0 newHabitRecord.createDate = .now do { try viewContext.save() WidgetCenter.shared.reloadAllTimelines() }catch { } } I wish I knew why it failed。 My system has been upgraded to 18.3。
Topic: App & System Services SubTopic: General Tags:
Feb ’25
Reply to Summary of issues encountered with the Screen Time interface
private func buildEvents(with tokens: Set<ApplicationToken>, prefix: String) -> [DeviceActivityEvent.Name: DeviceActivityEvent] { var events: [DeviceActivityEvent.Name: DeviceActivityEvent] = [:] for index in 0..<30 { // Set time threshold: first 29 events every 2 minutes, last event in 1 hour let threshold = (index == 29) ? DateComponents(hour: 1) : DateComponents(minute: (index + 1) * 2) let name = DeviceActivityEvent.Name("\(prefix)|\(index)") if #available(iOS 17.4, *) { events[name] = DeviceActivityEvent( applications: tokens, threshold: threshold, includesPastActivity: false ) }else { events[name] = DeviceActivityEvent( applications: tokens, threshold: threshold ) } } return events } This is my DeviceActivityEvent generation code. I hope the app is used to remind me every two minutes.
Topic: Community SubTopic: Apple Developers Tags:
Jun ’25
Reply to ScreenTime API app rejection 2.5.1
HI I meet the same rejection about ScreenTime API app rejection 2.5.1 Did you sovle it ?
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Apr ’24
Reply to About the problem that DeviceActivityMonitorExtension does not work
On February 9, I encountered the situation where the monitoring process was killed again. The monitoring processes of my two different applications were all killed, and I don’t know why. The only difference is that on February 8, I updated the system. However, on February 8, the monitoring still existed. In order to reduce memory, I used static methods in monitoring. And they were all looped at 0:00.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Feb ’25
Reply to About the problem that DeviceActivityMonitorExtension does not work
After it expired on February 9, it also expired on February 14. The failure codes are as follows: let deviceActivityCenter = DeviceActivityCenter() let deviceActivityName = DeviceActivityName( "GoalHabit-" + habit.id.uuidString ) let startInterval = DateComponents(hour : 0, minute : 0) let endInterval = DateComponents(hour : 23, minute : 59) let schedule = DeviceActivitySchedule( intervalStart: startInterval, intervalEnd: endInterval, repeats: true ) do{ try deviceActivityCenter.startMonitoring( deviceActivityName, during: schedule, events: [deviceActivityEventName : deviceActivityEvent] ) return true }catch { return false } deviceActivityEvent is an action to be performed after reaching the threshold override func eventDidReachThreshold(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName) { super.eventDidReachThreshold(event, activity: activity) let viewContext = PersistenceController.shared.container.viewContext let (year, month, day) = getYearMonthDay(.now) let newHabitRecord = HabitRecord(context: viewContext) newHabitRecord.id = UUID() newHabitRecord.habitId = id newHabitRecord.year = Int16(year) newHabitRecord.month = Int16(month) newHabitRecord.day = Int16(day) newHabitRecord.duration = middleValue * 60 // 当前思考的秒 newHabitRecord.type = 0 newHabitRecord.createDate = .now do { try viewContext.save() WidgetCenter.shared.reloadAllTimelines() }catch { } } I wish I knew why it failed。 My system has been upgraded to 18.3。
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Feb ’25
Reply to About the problem that DeviceActivityMonitorExtension does not work
After upgrading the system last night, it failed again
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Feb ’25
Reply to Color picker not working
After updating xcode to Version 16.2 (16C5032a), the color picker is no longer working. The application that was originally working is also no longer working after being compiled by xcode.
Replies
Boosts
Views
Activity
Feb ’25
Reply to Summary of issues encountered with the Screen Time interface
After repeated testing, on the iOS 18.5 version, the listening event will be triggered even if the threshold is not reached.
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Jun ’25
Reply to Summary of issues encountered with the Screen Time interface
private func buildEvents(with tokens: Set<ApplicationToken>, prefix: String) -> [DeviceActivityEvent.Name: DeviceActivityEvent] { var events: [DeviceActivityEvent.Name: DeviceActivityEvent] = [:] for index in 0..<30 { // Set time threshold: first 29 events every 2 minutes, last event in 1 hour let threshold = (index == 29) ? DateComponents(hour: 1) : DateComponents(minute: (index + 1) * 2) let name = DeviceActivityEvent.Name("\(prefix)|\(index)") if #available(iOS 17.4, *) { events[name] = DeviceActivityEvent( applications: tokens, threshold: threshold, includesPastActivity: false ) }else { events[name] = DeviceActivityEvent( applications: tokens, threshold: threshold ) } } return events } This is my DeviceActivityEvent generation code. I hope the app is used to remind me every two minutes.
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Jun ’25
Reply to Summary of issues encountered with the Screen Time interface
I found that the same event was triggered twice.
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Jun ’25
Reply to Summary of issues encountered with the Screen Time interface
I experimented with other apps and my own app and found that the eventDidReachThreshold method is automatically triggered under the iOS 18.5 system version.
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Jun ’25
Reply to DeviceActivityCenter startMonitoring Error
I hope to get an operation guide that can make this phenomenon disappear temporarily so that I can inform my users
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jun ’25
Reply to Live Activity (Dynamic Island) suddenly stopped working without code changes
"I have already registered the widget in the WidgetBundle."
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’25
Reply to Live Activity (Dynamic Island) suddenly stopped working without code changes
I’ve already solved the issue. The problem was that I had two widgets, and one of them was sharing the other widget’s AppIntent, which caused the Dynamic Island UI to not display. After separating the shared code, everything worked correctly. But does this mean widgets aren’t allowed to share code?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’25