Ensure processing of a REST call in flutter app in backgroundHow to prevent a background process from being stopped after closing SSH client in LinuxHow to get PID of background process?RESTful call in JavaHow to run Node.js as a background process and never die?How do I make calls to a REST api using C#?Call a REST API in PHPReducing memory size to ensure backgrounding in iOSRunning iOS App in background for more than 10 minutesiOS GPS Tracking app shutdown in backgroundrepetitive calls to beginBackgroundTaskWithExpirationHandler
Has there ever been a truly bilingual country prior to the contemporary period?
How to translate 脑袋短路 into English?
Why does my air conditioner still run, even when it is cooler outside than in?
Are there reliable, formulaic ways to form chords on the guitar?
What is the evidence on the danger of feeding whole blueberries and grapes to infants and toddlers?
Are there categories whose internal hom is somewhat 'exotic'?
Levenshtein Neighbours
Repurpose telephone line to ethernet
Land Registry Clause
Maximum number of pairwise linearly independent vectors
Why the color Red in Us, what is the significance?
Have only girls been born for a long time in this village?
IV curve on this solar panel datasheet
Sous vide chicken without an internal temperature of 165
How do you call it when two celestial bodies come as close to each other as they will in their current orbits?
Can a Beast Master ranger choose a swarm as an animal companion?
Is "stainless" a bulk or a surface property of stainless steel?
How can I pack my food so it doesn't smell?
How to decide whether an eshop is safe or compromised
In xXx, is Xander Cage's 10th vehicle a specific reference to another franchise?
90s(?) book series about two people transported to a parallel medieval world, she joins city watch, he becomes wizard
Does git delete empty folders?
Are required indicators necessary for radio buttons?
What fuel is J005311 burning?
Ensure processing of a REST call in flutter app in background
How to prevent a background process from being stopped after closing SSH client in LinuxHow to get PID of background process?RESTful call in JavaHow to run Node.js as a background process and never die?How do I make calls to a REST api using C#?Call a REST API in PHPReducing memory size to ensure backgrounding in iOSRunning iOS App in background for more than 10 minutesiOS GPS Tracking app shutdown in backgroundrepetitive calls to beginBackgroundTaskWithExpirationHandler
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I need to ensure that a certain HTTP request was send successfully. Therefore, I'm wondering if a simple way exists to move such a request into a background service task.
The background of my question is the following:
We're developing a survey application using flutter. Unfortunately, the app is intended to be used in an environment where no mobile internet connection can be guaranteed. Therefore, I’m not able to simply post the result of the survey one time but I have to retry it if it fails due to network problems. My current code looks like the following. The problem with my current solution is that it only works while the app is active all the time. If the user minimizes or closes the app, the data I want to upload is lost.
Therefore, I’m looking for a solution to wrap the upload process in a background service task so that it will be processed even when the user closes the app. I found several posts and plugins (namely https://medium.com/flutter-io/executing-dart-in-the-background-with-flutter-plugins-and-geofencing-2b3e40a1a124 and https://pub.dartlang.org/packages/background_fetch) but they don’t help in my particular use case. The first describes a way how the app could be notified when a certain event (namely the geofence occurred) and the second only works every 15 minutes and focuses a different scenario as well.
Does somebody knows a simple way how I can ensure that a request was processed even when there is a bad internet connection (or even none at the moment) while allowing the users to minimize or even close the app?
Future _processUploadQueue() async
int retryCounter = 0;
Future.doWhile(()
if(retryCounter == 10)
print('Abborted after 10 tries');
return false;
if (_request.uploaded)
print('Upload ready');
return false;
if(! _request.uploaded)
_networkService.sendRequest(request: _request.entry)
.then((id)
print(id);
setState(()
_request.uploaded = true;
);
).catchError((e)
retryCounter++;
print(e);
);
// e ^ retryCounter, min 0 Sec, max 10 minutes
int waitTime = min(max(0, exp(retryCounter)).round(), 600);
print('Waiting $waitTime seconds till next try');
return new Future.delayed(new Duration(seconds: waitTime), ()
print('waited $waitTime seconds');
return true;
);
)
.then(print)
.catchError(print);
rest flutter background-process
add a comment |
I need to ensure that a certain HTTP request was send successfully. Therefore, I'm wondering if a simple way exists to move such a request into a background service task.
The background of my question is the following:
We're developing a survey application using flutter. Unfortunately, the app is intended to be used in an environment where no mobile internet connection can be guaranteed. Therefore, I’m not able to simply post the result of the survey one time but I have to retry it if it fails due to network problems. My current code looks like the following. The problem with my current solution is that it only works while the app is active all the time. If the user minimizes or closes the app, the data I want to upload is lost.
Therefore, I’m looking for a solution to wrap the upload process in a background service task so that it will be processed even when the user closes the app. I found several posts and plugins (namely https://medium.com/flutter-io/executing-dart-in-the-background-with-flutter-plugins-and-geofencing-2b3e40a1a124 and https://pub.dartlang.org/packages/background_fetch) but they don’t help in my particular use case. The first describes a way how the app could be notified when a certain event (namely the geofence occurred) and the second only works every 15 minutes and focuses a different scenario as well.
Does somebody knows a simple way how I can ensure that a request was processed even when there is a bad internet connection (or even none at the moment) while allowing the users to minimize or even close the app?
Future _processUploadQueue() async
int retryCounter = 0;
Future.doWhile(()
if(retryCounter == 10)
print('Abborted after 10 tries');
return false;
if (_request.uploaded)
print('Upload ready');
return false;
if(! _request.uploaded)
_networkService.sendRequest(request: _request.entry)
.then((id)
print(id);
setState(()
_request.uploaded = true;
);
).catchError((e)
retryCounter++;
print(e);
);
// e ^ retryCounter, min 0 Sec, max 10 minutes
int waitTime = min(max(0, exp(retryCounter)).round(), 600);
print('Waiting $waitTime seconds till next try');
return new Future.delayed(new Duration(seconds: waitTime), ()
print('waited $waitTime seconds');
return true;
);
)
.then(print)
.catchError(print);
rest flutter background-process
add a comment |
I need to ensure that a certain HTTP request was send successfully. Therefore, I'm wondering if a simple way exists to move such a request into a background service task.
The background of my question is the following:
We're developing a survey application using flutter. Unfortunately, the app is intended to be used in an environment where no mobile internet connection can be guaranteed. Therefore, I’m not able to simply post the result of the survey one time but I have to retry it if it fails due to network problems. My current code looks like the following. The problem with my current solution is that it only works while the app is active all the time. If the user minimizes or closes the app, the data I want to upload is lost.
Therefore, I’m looking for a solution to wrap the upload process in a background service task so that it will be processed even when the user closes the app. I found several posts and plugins (namely https://medium.com/flutter-io/executing-dart-in-the-background-with-flutter-plugins-and-geofencing-2b3e40a1a124 and https://pub.dartlang.org/packages/background_fetch) but they don’t help in my particular use case. The first describes a way how the app could be notified when a certain event (namely the geofence occurred) and the second only works every 15 minutes and focuses a different scenario as well.
Does somebody knows a simple way how I can ensure that a request was processed even when there is a bad internet connection (or even none at the moment) while allowing the users to minimize or even close the app?
Future _processUploadQueue() async
int retryCounter = 0;
Future.doWhile(()
if(retryCounter == 10)
print('Abborted after 10 tries');
return false;
if (_request.uploaded)
print('Upload ready');
return false;
if(! _request.uploaded)
_networkService.sendRequest(request: _request.entry)
.then((id)
print(id);
setState(()
_request.uploaded = true;
);
).catchError((e)
retryCounter++;
print(e);
);
// e ^ retryCounter, min 0 Sec, max 10 minutes
int waitTime = min(max(0, exp(retryCounter)).round(), 600);
print('Waiting $waitTime seconds till next try');
return new Future.delayed(new Duration(seconds: waitTime), ()
print('waited $waitTime seconds');
return true;
);
)
.then(print)
.catchError(print);
rest flutter background-process
I need to ensure that a certain HTTP request was send successfully. Therefore, I'm wondering if a simple way exists to move such a request into a background service task.
The background of my question is the following:
We're developing a survey application using flutter. Unfortunately, the app is intended to be used in an environment where no mobile internet connection can be guaranteed. Therefore, I’m not able to simply post the result of the survey one time but I have to retry it if it fails due to network problems. My current code looks like the following. The problem with my current solution is that it only works while the app is active all the time. If the user minimizes or closes the app, the data I want to upload is lost.
Therefore, I’m looking for a solution to wrap the upload process in a background service task so that it will be processed even when the user closes the app. I found several posts and plugins (namely https://medium.com/flutter-io/executing-dart-in-the-background-with-flutter-plugins-and-geofencing-2b3e40a1a124 and https://pub.dartlang.org/packages/background_fetch) but they don’t help in my particular use case. The first describes a way how the app could be notified when a certain event (namely the geofence occurred) and the second only works every 15 minutes and focuses a different scenario as well.
Does somebody knows a simple way how I can ensure that a request was processed even when there is a bad internet connection (or even none at the moment) while allowing the users to minimize or even close the app?
Future _processUploadQueue() async
int retryCounter = 0;
Future.doWhile(()
if(retryCounter == 10)
print('Abborted after 10 tries');
return false;
if (_request.uploaded)
print('Upload ready');
return false;
if(! _request.uploaded)
_networkService.sendRequest(request: _request.entry)
.then((id)
print(id);
setState(()
_request.uploaded = true;
);
).catchError((e)
retryCounter++;
print(e);
);
// e ^ retryCounter, min 0 Sec, max 10 minutes
int waitTime = min(max(0, exp(retryCounter)).round(), 600);
print('Waiting $waitTime seconds till next try');
return new Future.delayed(new Duration(seconds: waitTime), ()
print('waited $waitTime seconds');
return true;
);
)
.then(print)
.catchError(print);
rest flutter background-process
rest flutter background-process
edited Mar 27 at 17:25
Sean Lintern
2,60714 silver badges25 bronze badges
2,60714 silver badges25 bronze badges
asked Mar 27 at 14:44
ehhcehhc
384 bronze badges
384 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can use the plugin shared_preferences
to save each HTTP response to the device until the upload completes successfully. Like this:
requests: [
id: 8eh1gc,
request: "..."
,
...
],
Then whenever the app is launched, check if any requests are in the list, retry them, and delete them if they complete. You could also use the background_fetch
to do this every 15 minutes.
I've done like you succested but i still think it's some kind of ugly and it would be cool to have an elegant solution. Thanks nonetheless.
– ehhc
Apr 16 at 7:23
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55380036%2fensure-processing-of-a-rest-call-in-flutter-app-in-background%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use the plugin shared_preferences
to save each HTTP response to the device until the upload completes successfully. Like this:
requests: [
id: 8eh1gc,
request: "..."
,
...
],
Then whenever the app is launched, check if any requests are in the list, retry them, and delete them if they complete. You could also use the background_fetch
to do this every 15 minutes.
I've done like you succested but i still think it's some kind of ugly and it would be cool to have an elegant solution. Thanks nonetheless.
– ehhc
Apr 16 at 7:23
add a comment |
You can use the plugin shared_preferences
to save each HTTP response to the device until the upload completes successfully. Like this:
requests: [
id: 8eh1gc,
request: "..."
,
...
],
Then whenever the app is launched, check if any requests are in the list, retry them, and delete them if they complete. You could also use the background_fetch
to do this every 15 minutes.
I've done like you succested but i still think it's some kind of ugly and it would be cool to have an elegant solution. Thanks nonetheless.
– ehhc
Apr 16 at 7:23
add a comment |
You can use the plugin shared_preferences
to save each HTTP response to the device until the upload completes successfully. Like this:
requests: [
id: 8eh1gc,
request: "..."
,
...
],
Then whenever the app is launched, check if any requests are in the list, retry them, and delete them if they complete. You could also use the background_fetch
to do this every 15 minutes.
You can use the plugin shared_preferences
to save each HTTP response to the device until the upload completes successfully. Like this:
requests: [
id: 8eh1gc,
request: "..."
,
...
],
Then whenever the app is launched, check if any requests are in the list, retry them, and delete them if they complete. You could also use the background_fetch
to do this every 15 minutes.
answered Mar 27 at 15:43
Tim TraversyTim Traversy
855 bronze badges
855 bronze badges
I've done like you succested but i still think it's some kind of ugly and it would be cool to have an elegant solution. Thanks nonetheless.
– ehhc
Apr 16 at 7:23
add a comment |
I've done like you succested but i still think it's some kind of ugly and it would be cool to have an elegant solution. Thanks nonetheless.
– ehhc
Apr 16 at 7:23
I've done like you succested but i still think it's some kind of ugly and it would be cool to have an elegant solution. Thanks nonetheless.
– ehhc
Apr 16 at 7:23
I've done like you succested but i still think it's some kind of ugly and it would be cool to have an elegant solution. Thanks nonetheless.
– ehhc
Apr 16 at 7:23
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55380036%2fensure-processing-of-a-rest-call-in-flutter-app-in-background%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown