You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
My NativeEventEmitter is not firing when I know there should be new background data for steps. It fires only when I check the updated data in Apple Health first.
To Reproduce
Steps to reproduce the behavior:
Scenario 1
walk around with iPhone, thereby logging more step data
open my app
NativeEventEmitter does not fire
Scenario 2
walk around with iPhone, thereby logging more step data
open the Apple Health app, seeing the step count has increased
open my app
NativeEventEmitter does fire and new data is set/visible
Expected behavior
The NativeEventEmitter should fire when opening my app, without me having to see the new data in the Apple Health app first.
Users of my app expect their steps data to be accurate inside my app, without having to use Apple Health.
Smartphone (please complete the following information):
Device: iPhone 12 mini
OS: iOS 15.5.1
Version 21F90
Additional context
Implementation of event listener:
const [hkStepCount, setHkStepCount] = useState(0);
// listeners for AppleHealth data changes
useEffect(() => {
const options = {
startDate: dayjs().startOf("D").toISOString()
};
new NativeEventEmitter(NativeModules.AppleHealthKit).addListener("healthKit:StepCount:new", async () => {
AppleHealthKit.getStepCount(options, (err: string, results: HealthValue) => {
// this doesn't log when it should
console.log("*** getStepCount: ");
if (err) console.log("err: ", JSON.stringify(err, null, 1));
// `title` here is related to my component logic
if (results && title === "Steps") {
console.log("listener results: ", JSON.stringify(results, null, 1));
setHkStepCount(results.value);
}
});
});
});
Describe the bug
My
NativeEventEmitter
is not firing when I know there should be new background data for steps. It fires only when I check the updated data in Apple Health first.To Reproduce
Steps to reproduce the behavior:
Scenario 1
NativeEventEmitter
does not fireScenario 2
NativeEventEmitter
does fire and new data is set/visibleExpected behavior
The
NativeEventEmitter
should fire when opening my app, without me having to see the new data in the Apple Health app first.Users of my app expect their steps data to be accurate inside my app, without having to use Apple Health.
Smartphone (please complete the following information):
Additional context
Implementation of event listener:
Permissions that have been granted:
From
AppDelegate.mm
:The text was updated successfully, but these errors were encountered: