Skip to content

Commit

Permalink
fix(android): registering WorkRequest on handleOnPause (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
theproducer authored Apr 4, 2024
1 parent 174f2fe commit d6511b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-stingrays-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@capacitor/background-runner": minor
---

(Android): Fixing issue that disabled `appStateChange` events
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ class BackgroundRunnerPlugin: Plugin() {
const val NOTIFICATIONS = "notifications"
}

override fun handleOnPause() {
super.handleOnPause()
Log.d("Background Runner", "registering runner workers")
impl?.scheduleBackgroundTask(this.context)
}

override fun load() {
super.load()
impl = BackgroundRunner.getInstance(this.context)

bridge.app.setStatusChangeListener {
if (!it) {
Log.d("Background Runner", "registering runner workers")
impl?.scheduleBackgroundTask(this.context)
}
}
}

@PluginMethod
Expand Down
2 changes: 1 addition & 1 deletion packages/capacitor-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"docgen-api": "docgen --api CapacitorAPI --output-readme API.md --output-json dist/docs-api.json && node ./scripts/combine_docs.js",
"build-sdk": "./scripts/build-native-sdks.sh",
"build": "npm run clean && npm run docgen && npm run docgen-api && tsc && rollup -c rollup.config.js && npm run build-sdk && ./scripts/copy-native-sdks.sh && npm pack && mv ./capacitor-background-runner-*.tgz ../../ && ./scripts/copy-readme.sh",
"pack": "npm run build && && ./scripts/copy-native-sdks.sh && npm pack && mv ./capacitor-background-runner-*.tgz ../../",
"pack": "npm run build && ./scripts/copy-native-sdks.sh && npm pack && mv ./capacitor-background-runner-*.tgz ../../",
"clean": "rimraf ./dist",
"watch": "tsc --watch",
"prepublishOnly": "npm run build",
Expand Down

0 comments on commit d6511b2

Please sign in to comment.