react-native-background-timer
react-native-background-timer copied to clipboard
How it works?
Hi,
I was using react-ntive-background-geo-location to keep my application alive in the background.
But iOS 13 not letting it work anymore. Can I use it with iOS 13? I need it to send a post request every minute to a server is it possible using this component?
Please advise. Thank you
I'm using it with mauron85/react-native-background-geolocation It works good now. Tested on Pixel 2 and Samsung S8
I'm using it with mauron85/react-native-background-geolocation It works good now. Tested on Pixel 2 and Samsung S8
well. Android is always good for the developer I am talking about iOS
Very funny. I had issue only on Android background mod. On iOS I have no issue with background. Anyway on iOS it works good too.
const id = BackgroundTimer.setInterval(tick, delay);
return () => BackgroundTimer.clearInterval(id);
are you using in combination with react-native-background-geolocation?
I do not want to use geolocation right now.
Can I use only a timer?
I don't reason why you should not.
mauron85/react-native-background-geolocation
is needed about 300$ for release building android .
not exact. This package is free.
But there are transistorsoft/react-native-background-geolocation
that is paid one.
I don't reason why you should not.
Hello,
sorry for getting back to you late, I just create a test app
componentDidMount() { BackgroundTimer.runBackgroundTimer(() => { console.log('testing'); }, 3000);
}
and even running in the simulator it stops printing after about 20-30 sec.
also tried this:
BackgroundTimer.start(); var time = 0; BackgroundTimer.setInterval(() => { time ++; console.log(time) }, 1000)
same result.
can you please guide me what I am missing?
TIA
runBackgroundTimer
BackgroundTimer.setInterval(tick, delay)
runBackgroundTimer
BackgroundTimer.setInterval(tick, delay)
If you look at my code I did try that too.
Can you please quickly test on your side?
Very strange I'm using BackgroundTimer.setInterval
and it's work as is should.
I have component that returns null
https://reactjs.org/docs/conditional-rendering.html#preventing-component-from-rendering.
function useInterval(callback, delay) {
const savedCallback = useRef();
// Remember the latest function.
useEffect(() => {
savedCallback.current = callback;
}, [callback]);
useEffect(() => {
function tick() {
savedCallback.current();
}
if (delay !== null) {
if (IS_IOS) {
BackgroundTimer.start();
}
const id = BackgroundTimer.setInterval(tick, delay);
return () => BackgroundTimer.clearInterval(id);
}
return () => {};
}, [delay]);
}
And starting it in component
useInterval(
() => { /* your code here */ },
run ? delay : null,
);
would you like to connect to look together what we can do to fix it? right now I am stuck and not sure what else needs to be done.
TIA
still no success.
I think this module should be IOS setting more. IOS 13 kill background service, right? like this: https://stackoverflow.com/questions/57197958/xcode-11-what-is-the-new-background-processing-background-mode
I think this module should be IOS setting more. IOS 13 kill background service, right? like this: https://stackoverflow.com/questions/57197958/xcode-11-what-is-the-new-background-processing-background-mode
for now, I have no success with working app in the background in a simulator without debugger too and in build, version it's not working too, but if we have debugger mode, it works perfectly.
I suggest that we need to use runBackgroundTimer
it consoles every second some info so Iv need to try
it not work!!!!!!!!!!!!!!!!!!!!!!!!!!!!! at all
no, it does not. and no help at all.