Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/691a5ca1-2b1c-8010-8cbd-8797f95aa8d9
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== User: How can this be approached ? === How can this be approached ? I was thinking a mix of core motion and gps speed for redundancy i believe it could a better approach with a small observable engine that can agrégate the data to decide when notifications should scheduled along bacgound task ? Background App updates on iOS – Looking for solutions I'm working on an iOS app built in Swift + SwiftUI, that tracks driving time for specific drivers and need to schedule local notifications based on accumulated driving time, all while the app runs in the background... I'm using CoreMotion to detect when a user is driving (via .automotive state). When driving starts, I capture the activity.startDate(The time at which the change in motion occurred.) from CMMotionActivity and store it in my data model. ( SwiftData ). The app accumulates driving time as the user transitions between "Driving" and "Stopped" states. Once they hit 4 hours of driving, I need to fire a local notification reminding them to take a mandatory break. '''The Problem:''' The app needs to update this accumulated time and check thresholds while in the background (screen locked). However, iOS heavily restricts background execution: * Timers don't run in the background * SwiftData updates don't trigger automatically * Live Activities don't update reliably without push notifications * Standard background modes don't fit this use case '''What I've tried...''' * CoreMotion does detect activity changes in the background and provides accurate timestamps * But my app code doesn't execute to process these updates until the user reopens the app from the background * Push notifications would work but feel like overkill for a small, offline first app '''My current workaround...''' I've pivoted to a manual approach, users tap "Start Driving" and "Stop Driving" buttons. This lets me schedule local notifications from a known start time, which works reliably when the phone is in the background. '''My question...''' Has anyone found a way to update app state and check conditions in the background based on CoreMotion activity changes, without relying on push notifications? Or is manual user input the only practical solution for this type of offline tracking app? CoreMotion: https://developer.apple.com/documentation/coremotion/cmmotionactivity<ref>{{cite web|title=https://developer.apple.com/documentation/coremotion/cmmotionactivity|url=https://developer.apple.com/documentation/coremotion/cmmotionactivity|publisher=developer.apple.com|access-date=2025-11-17}}</ref>
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)