Skip to content

Commit 317dbc6

Browse files
committed
added ReactNativeForegroundService config
1 parent d5b5550 commit 317dbc6

File tree

3 files changed

+26
-155
lines changed

3 files changed

+26
-155
lines changed
Loading

app/index.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,23 @@ import {
2121
} from "react-native-health-connect";
2222
import { Alert } from "react-native";
2323

24-
ReactNativeForegroundService.register();
24+
const config = {
25+
config: {
26+
alert: true,
27+
onServiceErrorCallBack: function () {
28+
console.warn(
29+
"[ReactNativeForegroundService] onServiceErrorCallBack",
30+
arguments
31+
);
32+
},
33+
},
34+
};
35+
ReactNativeForegroundService.register(config);
2536

2637
ReactNativeForegroundService.add_task(
2738
async () => {
2839
console.log(
29-
`Got background fetch call at date: ${new Date().toISOString()}`,
40+
`Got background fetch call at date: ${new Date().toISOString()}`
3041
);
3142
// Do your background work...
3243
await syncData({
@@ -41,7 +52,7 @@ ReactNativeForegroundService.add_task(
4152
onLoop: true,
4253
taskId: "background-sync-task",
4354
onError: (e) => console.log(`Error logging:`, e),
44-
},
55+
}
4556
);
4657

4758
const syncData = async ({
@@ -117,7 +128,7 @@ const syncData = async ({
117128
result.step.push(stepsResult.COUNT_TOTAL.toString());
118129
result.time.push(startTime.toISOString());
119130
result.energy.push(
120-
activeCaloriesBurnedResult.ACTIVE_CALORIES_TOTAL.inKilocalories.toString(),
131+
activeCaloriesBurnedResult.ACTIVE_CALORIES_TOTAL.inKilocalories.toString()
121132
);
122133
}
123134
console.log("time:", new Date().getTime() - now.getTime(), "ms");

package-lock.json

Lines changed: 11 additions & 151 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)