Open DisruptLive opened 1 year ago
App.addListener
isn't needed here, I explained more in detail here:
https://github.com/ionic-team/capacitor-background-runner/issues/20
There are some techniques and tools to better debug / manually trigger background tasks on iOS and Android, I'll work on adding those steps to the documentation.
Regarding the error, it could be crashing due to the fact that you have not requested permissions for accessing the Geolocation APIs, though your runner function isn't using geolocation. I'll look closer into this and work on getting a fix out.
I was able to get the exact implementation i noted above to work without any errors by enabling "Location Updates" in "Signing & Capabilities" in xCode, but obviously this is not ideal for anyone that has no need for accessing Geo Location data from a user's device.
To fix the "Invalid parameter not satisfying: !stayUp" error I also had to add the label of the task to the iOS info.plist like this:
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.capacitor.background.check</string>
</array>
Any news on this issue? My app crashes if I don't enable Location Updates
. If I do enable the capability the plugin will ask for Location permission without the possibility to prevent it. I don't need to use location in my application :)
I fixed it temporarily by patching the dependency and commenting out this line
Where to place the file background.js in ionic react app?
@theproducer I got the same error and i got it working after enabling geolocation. When will it be resolved to work without geolocation?
@Coder-gunjan, place the file inside the public folder instead of src folder for react applications.
Resolved the error mentioned by following the solution mentioned in this thread https://github.com/mauron85/react-native-background-geolocation/issues/60
But ideally, it should not throw errors related to location if we are not using it.
In my
background.js
file i have 1 event listener defined:In my
capacitor.config.ts
i have Background Runner configured as follows:In my React App i am using the
@capacitor/app
plugin to monitorappStateChange
and am triggeringmyEvent
based on theisActive
status as follows:Results in the following errors when running the app on an actual iOS device running iOS v16.5.1(c) after putting the app into the background:
What am i missing?