Closed SchallerStefan closed 1 year ago
On IOS I tried using backgroundTasks: "https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/using_background_tasks_to_update_your_app" I expected this to work independently from the background-fetch-plugin.
This is the same API implemented by background-fetch
(including the .scheduleTask
method).
There is no need to implement the iOS BGTaskScheduler
API manually.
Everything about the iOS BGTaskScheduler
API is implemented by background-fetch
.
If I configure the background-fetch to be 2 a weeks-interval, will it interfere with the Background-Fetch used by the Background-Geolocation-Plugin? Are both instances independent?
An app is only allowed to register one iOS "background refresh" task.
There is only one instance of the BackgroundFetch
instance. It is shared by both background-fetch
and background-geolocation
.
Thank you for the quick responses!
Last Question:
Why does .scheduleTask
behave differently to the normal fetch Task of the plugin? (Mentioned in "https://transistorsoft.github.io/capacitor-background-fetch/classes/backgroundfetch.html" e.g. "scheduleTask seems only to fire when the device is plugged into power")
Is that because scheduleTask is a BGProcessingTask instead of a BGAppRefreshTask?
Is that because scheduleTask is a BGProcessingTask instead of a BGAppRefreshTask?
Yes. It doesn't matter if you implement BGProcessingTask
with your own native code vs using background-fetch
.
iOS simply doesn't seem to run BGProcessingTask
unless the device is plugged-in to power. Apple may change this behaviour with future iOS updates. That's up to Apple.
Ok, thank you again!
Your Environment
npx cap doctor
) @capacitor/android: 4.7.1 @capacitor/core: 4.7.1 @capacitor/ios: 4.7.1 @capacitor/cli: 4.7.1BackgroundFetch.configure
:Expected Behavior
In our Capacitor-App we need to refresh our refresh-Token every 2 weeks. In Android I used a "PeriodicWorkRequest" which worked just fine. On IOS I tried using backgroundTasks: "https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/using_background_tasks_to_update_your_app" I expected this to work independently from the background-fetch-plugin.
Actual Behavior
Upon putting our own taskId in "Permitted background task scheduler identifiers" and registering it in "didFinishLaunchingWithOptions" using
BGTaskScheduler.shared.register
it clashes with the "capacitor-background-fetch"-Plugin. (Error is "task launcher for task with com... has already been registered")Steps to Reproduce
BGTaskScheduler.shared.register
Context
The plugin probably registers all strings in "Permitted background task scheduler identifiers" because of
BackgroundFetch.scheduleTask
. I would use scheduleTask if it was a simple Background-Fetch and not use Background-processing (because it needs the phone to be connected and has more restrictions than fetch). The Background-Fetch-Plugin asks periodically, but I would like to control when the Background-Task is submitted myself.My questions concerning this are: