capawesome-team / capacitor-background-task Goto Github PK
View Code? Open in Web Editor NEW⚡️ Capacitor plugin for running background tasks.
Home Page: https://capawesome.io/plugins/background-task/
License: MIT License
⚡️ Capacitor plugin for running background tasks.
Home Page: https://capawesome.io/plugins/background-task/
License: MIT License
Hello, I was wondering when Android support for this plugin is expected to be implemented? Thanks.
Describe the solution you'd like:
Plugin to be added to the capacitor community plugins. Adding feature request to cross reference to the plugin propsal.
Additional context:
capacitor-community/proposals#108
The UIApplication
BG implementation of iOS seems to have a time execution of 30s, max. Does this plugin also adhere to the same limitations?
Plugin version:
1.0.1
Platform(s):
IOS and Android
Current behavior:
Keep calling the parent function hundreds of times
Expected behavior:
Should run once
Steps to reproduce:
I am placing the const taskId = await BackgroundTask.beforeExit(async () => {
inside useEffect()
.
I am expecting that the http request
and updateDB()
to be ran background. This is to prevent sudden termination from the user after sending http request
and before updating the database. It can cause problem because the data need to be synced. If the user terminate the app after sending http request
and not updating the database after that, the next time the user launch the application, the application will try to send the http request
to the server, this cause duplicate data being sent.
However this code behaves incredibly weird, the const syncingOut = async () => {
is called hundreds of times causing hundreds of http request
and updateDB()
being called simultaneously. It should be called once.
Related code:
export const useSynchronizer = () => {
.....
.....
useEffect(() => {
if (syncOut.length > 0) syncingOut()
}, [syncOut, isSyncingOut]);
const syncingOut = async () => {
if (!isSyncingOut) {
dispatch(setIsSyncingOut(true));
if (syncOut.length > 0) {
let job = syncOut[0];
switch (job.type) {
case 'POST': {
const taskId = await BackgroundTask.beforeExit(async () => {
let r = await Http.post(nav, job.url, job.params, job.model, job.syncToken);
await updateDB(r, job);
BackgroundTask.finish({ taskId });
});
break;
}
case 'PUT': {
const taskId = await BackgroundTask.beforeExit(async () => {
let r = await Http.put(nav, job.url, job.params, job.model, job.syncToken);
await updateDB(r, job);
BackgroundTask.finish({ taskId });
});
break;
}
case 'DELETE': {
if (!isWeb()) {
const taskId = await BackgroundTask.beforeExit(async () => {
let r = await Http.delete(nav, job.url, job.params, job.syncToken);
await updateDB(r, job);
BackgroundTask.finish({ taskId });
});
break;
}
}
dispatch(setIsSyncingOut(false));
} else {
dispatch(setIsSyncingOut(false));
}
}
}
Other information:
None
Capacitor doctor:
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 3.6.0
@capacitor/core: 3.6.0
@capacitor/android: 3.6.0
@capacitor/ios: 3.6.0
Installed Dependencies:
@capacitor/cli: 3.4.0
@capacitor/core: 3.5.1
@capacitor/android: 3.4.0
@capacitor/ios: 3.4.0
[success] iOS looking great! 👌
[success] Android looking great! 👌```
Is your feature request related to a problem? Please describe:
If i start a progress, let's say an upload function already before the on exit event. How would the logic be to continue this function?
I have an issue with the app and background working. Can anybody help me?
I made an app for the clinic and all works well while they are in-app but when for example pick up the phone or want to reply to a message looks the state of the app lose and they can't navigate through the application (the back button dissipated) and need to kill the app and start it again. Is there any solution to it?
I made a "hack" in the app.component.ts file:
App.addListener('appStateChange', ({isActive}) => {
if (!isActive) {
// App went to background
} else {
// App went to foreground
this.navCtrl.navigateRoot(['./']);
}
});
but when I add that user can't take a picture of the patient or change his avatar, it always backs him on the homepage :( I use a capacitor to build apps. Is there any solution to save the state to not lose on which page the user exists and where he can go back?
I hope that this plugin can help me but I didn't know how to make that part of the code instead of navigating to root :( Please help me.
Is your feature request related to a problem? Please describe:
There is currently no ready implementation on Android.
Describe the solution you'd like:
Add an implementation for Android.
Is your feature request related to a problem? Please describe:
I have a scenario where i have bluetooth sensor connected to my application. I am receiving continues data from bluetooth. My issue is when application go to background i want to keep listen to that data on both platforms android / ios.
Describe the solution you'd like:
keep my bluetooth listener active in background mode to receive data.
Describe alternatives you've considered:
as per this Plugin cordova-plugin-background-mode it says "perform infinite background execution"
Additional context:
I am using cordova-pluign-media-capture to record videos. but when i open camera application goes into background so i want to listen to Bluetooth data in background.
Hello,
Following Capacitor v4 realease.
Do you plan to support this version?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.