jamesisaac / react-native-background-task

Periodic background tasks for React Native apps, cross-platform (iOS and Android), which run even when the app is closed.
MIT License
1.1k stars 110 forks source link

iOS task did not run at all. #21

Closed j-mendez closed 5 years ago

j-mendez commented 6 years ago

Waited about 30 mins and the task defined only had a console.log and it did not fire. Tested on a physical device.

stefanlenoach commented 6 years ago

+1

dhuma1981 commented 6 years ago

+1

OFranke commented 6 years ago

+1

vah7id commented 6 years ago

+1

jamesisaac commented 6 years ago

Have you enabled the Background Fetch feature in Xcode for the project? https://github.com/transistorsoft/react-native-background-fetch/blob/master/docs/INSTALL-MANUAL-IOS.md#configure-background-capabilities

grantfwilkinson commented 6 years ago

Have done the setup and same issue on my side. Made sure the plist was correct and fully followed it

j-mendez commented 6 years ago

@jamesisaac yes. The only thing I can think of is that I was using a higher version for react-native-background-fetch. Is it required to use the specific version that you specified?

j-mendez commented 6 years ago

@jamesisaac actually you do not state a exact version nvm. Going to test this later on today to see if it works after the RN project upgrade to 0.53.0 .

cbrevik commented 6 years ago

I see this module uses react-native-background-fetch for iOS, and in its README it says:

iOS can take some hours or even days to start a consistently scheduling background-fetch events since iOS schedules fetch events based upon the user's patterns of activity. If Simulate Background Fetch works, your can be sure that everything is working fine. You just need to wait.

Might be a reason?

I haven't used this module myself, I'm just looking through options. But might be worth to check with Debug->Simulate Background Fetch

adcuz commented 6 years ago

I've been experimenting with background fetch in iOS in the past few weeks, my conclusion is you are not going to be able to reliably run background tasks on a regular basis. On an iPhone left idle and the app open in the background, it seems to run about twice a day with 1 hour between those. Presumably this is due to them using some kind of algo to decide when to run background fetch, as mentioned by @cbrevik.

react-native-background-fetch appears to (as of a few weeks ago) have Android support too.