Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sensors][iOS] Fix pedometer sensors when app goes to background then foreground #29957

Conversation

rlods
Copy link
Contributor

@rlods rlods commented Jun 23, 2024

Why

On iOS, Pedometer sensor is currently broken if app goes to background then comes back in foreground.

It's very easy to reproduce:

  • subscribe to Pedometer.watchStepCount
  • confirm steps are received
  • put app in background
  • put app in foreground
  • no more steps are received even if Pedometer.watchStepCount is subscribed again

How

The issue is that sensor reference values watchStartDate and watchHandler are reset in stopUpdates

While they should only be reset in OnStopObserving, which is also cleaner since both values are set in the opposite function OnStartObserving

Test Plan

Manually tested

Checklist

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Jun 23, 2024
rlods and others added 2 commits June 23, 2024 14:16
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@rlods rlods requested a review from expo-bot June 23, 2024 12:32
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Jun 23, 2024
Copy link
Contributor

@lukmccall lukmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
Thanks for your contribution!

packages/expo-sensors/CHANGELOG.md Outdated Show resolved Hide resolved
@lukmccall lukmccall merged commit 60ccfbf into expo:main Jun 24, 2024
1 check passed
@expo-bot
Copy link
Collaborator

Hi there! 👋 I'm a bot whose goal is to ensure your contributions meet our guidelines.

I've found some issues in your pull request that should be addressed (click on them for more details) 👇

⚠️ Suggestion: Missing links in changelog entries


I've added some suggestions below, you can just apply and commit them 😉


Generated by ExpoBot 🤖 against c75dc43

@@ -13,6 +13,7 @@
- Fix incorrect event emitting tests. ([#28953](https://github.com/expo/expo/pull/28953) by [@aleqsio](https://github.com/aleqsio))
- Removed redundant usage of `EventEmitter` instance. ([#28946](https://github.com/expo/expo/pull/28946) by [@tsapeta](https://github.com/tsapeta))
- [Android] Remove usage of deprecated internal modules API. ([#28715](https://github.com/expo/expo/pull/28715) by [@lukmccall](https://github.com/lukmccall))
- [iOS] Fix pedometer sensor when app goes to background then foreground. ([#29957]https://github.com/expo/expo/pull/29957) by [@rlods](https://github.com/rlods))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [iOS] Fix pedometer sensor when app goes to background then foreground. ([#29957]https://github.com/expo/expo/pull/29957) by [@rlods](https://github.com/rlods))
- [iOS] Fix pedometer sensor when app goes to background then foreground. ([#29957]https://github.com/expo/expo/pull/29957) by [@rlods](https://github.com/rlods)) ([#29957](https://github.com/expo/expo/pull/29957) by [@rlods](https://github.com/rlods))

@expo-bot expo-bot added bot: suggestions ExpoBot has some suggestions and removed bot: passed checks ExpoBot has nothing to complain about labels Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: suggestions ExpoBot has some suggestions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants