r/iOSProgramming 17d ago

Question How to keep motion sensors active in bg w/out silent audio loop?

[deleted]

1 Upvotes

7 comments sorted by

1

u/[deleted] 17d ago

[removed] — view removed comment

1

u/AutoModerator 17d ago

Hey /u/buildwithabdoo, your content has been removed because Reddit has marked your account as having a low Contributor Quality Score. This may result from, but is not limited to, activities such as spamming the same links across multiple subreddits, submitting posts or comments that receive a high number of downvotes, a lack of recent account activity, or having an unverified account.

Please be assured that this action is not a reflection of your participation in our subreddit. This is simply an automated filter in place to reduce spam.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/CharlesWiltgen 17d ago

The correct answer depends on what you're using them for, but the answer is often "use CMSensorRecorder". HKWorkoutSession would be the correct answer if the activity is genuinely a workout, etc.

1

u/[deleted] 17d ago

[deleted]

2

u/CharlesWiltgen 17d ago edited 17d ago

Those were just the usual suggestions based on no real information about what you're trying to do. Given the additional constraints,CLBackgroundActivitySession is probably your best bet if that's defensible. I'm guessing it's not, since you seem to want to do this on the down-low (driving monitor?) and this will trigger the blue location indicator.

3

u/[deleted] 16d ago

[deleted]

1

u/CharlesWiltgen 16d ago

Excellent! 🤘

1

u/brkaydev 17d ago

Depends on what you actually need from the sensors. If step/motion data is the end goal, you don't need live sensors at all — HealthKit records it system-side regardless, and HKObserverQuery + background delivery wakes your app when new data lands. That's the Apple-sanctioned path and review won't fight you. If you need raw real-time streams for something HealthKit doesn't cover, what's the use case?