From 312890ed6b974106ee7b3ae6728d16b0483b4824 Mon Sep 17 00:00:00 2001 From: Richard Leurs <7275740+NextNebula@users.noreply.github.com> Date: Sun, 6 Oct 2024 17:11:09 +0200 Subject: [PATCH 1/3] Default config repeat property to false --- packages/capacitor-plugin/ios/Plugin/RunnerConfig.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/capacitor-plugin/ios/Plugin/RunnerConfig.swift b/packages/capacitor-plugin/ios/Plugin/RunnerConfig.swift index fc440618..2c7ca114 100644 --- a/packages/capacitor-plugin/ios/Plugin/RunnerConfig.swift +++ b/packages/capacitor-plugin/ios/Plugin/RunnerConfig.swift @@ -6,7 +6,7 @@ public struct RunnerConfig { let src: String var autoSchedule: Bool var event: String - let repeats: Bool? + let repeats: Bool let enableWatchConnectivity: Bool let interval: Int? @@ -28,7 +28,7 @@ public struct RunnerConfig { self.label = label self.src = src self.event = event - self.repeats = repeats + self.repeats = repeats ?? false self.interval = interval self.autoSchedule = autoStart ?? false self.enableWatchConnectivity = jsObject["enableWatchConnectivity"] as? Bool ?? false From 83de66759bedf760a603e1e76014e4f6d56b2af2 Mon Sep 17 00:00:00 2001 From: Richard Leurs <7275740+NextNebula@users.noreply.github.com> Date: Sun, 6 Oct 2024 17:15:24 +0200 Subject: [PATCH 2/3] Reschedule iOS task if configured to repeat --- packages/capacitor-plugin/ios/Plugin/BackgroundRunner.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/capacitor-plugin/ios/Plugin/BackgroundRunner.swift b/packages/capacitor-plugin/ios/Plugin/BackgroundRunner.swift index 7fb2fd98..d2f7d1fe 100644 --- a/packages/capacitor-plugin/ios/Plugin/BackgroundRunner.swift +++ b/packages/capacitor-plugin/ios/Plugin/BackgroundRunner.swift @@ -52,6 +52,10 @@ public class BackgroundRunner { _ = try BackgroundRunner.shared.execute(config: config) task.setTaskCompleted(success: true) + + if config.repeats { + try self.scheduleBackgroundTasks() + } } catch { print("background task error: \(error)") task.setTaskCompleted(success: false) From 1b5c8b7632470a2a1fb875990b90a40ba9b8af65 Mon Sep 17 00:00:00 2001 From: Joseph Pender Date: Mon, 7 Oct 2024 14:49:22 -0500 Subject: [PATCH 3/3] Adding changeset --- .changeset/orange-vans-hide.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/orange-vans-hide.md diff --git a/.changeset/orange-vans-hide.md b/.changeset/orange-vans-hide.md new file mode 100644 index 00000000..e5259e6e --- /dev/null +++ b/.changeset/orange-vans-hide.md @@ -0,0 +1,5 @@ +--- +"@capacitor/background-runner": minor +--- + +(iOS) Fixing task repeat functionality