@@ -21,12 +21,23 @@ import {
2121} from "react-native-health-connect" ;
2222import { 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
2637ReactNativeForegroundService . 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
4758const 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" ) ;
0 commit comments