Nativescript how to make http requests in the backgroundHow do save an Android Activity state using save instance state?How do I center text horizontally and vertically in a TextView?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I make links in a TextView clickable?Make an HTTP request with androidHow do I fix android.os.NetworkOnMainThreadException?How to make a background 20% transparent on AndroidIntegrate Android Service on NativeScript AppAndroid 8.0: java.lang.IllegalStateException: Not allowed to start service Intent

How much cash can I safely carry into the USA and avoid civil forfeiture?

How come there are so many candidates for the 2020 Democratic party presidential nomination?

Which big number is bigger?

Why does nature favour the Laplacian?

Extension of 2-adic valuation to the real numbers

How did Captain America manage to do this?

What makes accurate emulation of old systems a difficult task?

What does ゆーか mean?

Phrase for the opposite of "foolproof"

Don’t seats that recline flat defeat the purpose of having seatbelts?

Why do games have consumables?

Is there really no use for MD5 anymore?

How to write a column outside the braces in a matrix?

Can SQL Server create collisions in system generated constraint names?

Implications of cigar-shaped bodies having rings?

Aliens crash on Earth and go into stasis to wait for technology to fix their ship

Is it idiomatic to construct against `this`

Can an Area of Effect spell cast outside a Prismatic Wall extend inside it?

bldc motor, esc and battery draw, nominal vs peak

How to denote matrix elements succinctly?

How could Tony Stark make this in Endgame?

How to limit Drive Letters Windows assigns to new removable USB drives

Function pointer with named arguments?

a sore throat vs a strep throat vs strep throat



Nativescript how to make http requests in the background


How do save an Android Activity state using save instance state?How do I center text horizontally and vertically in a TextView?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I make links in a TextView clickable?Make an HTTP request with androidHow do I fix android.os.NetworkOnMainThreadException?How to make a background 20% transparent on AndroidIntegrate Android Service on NativeScript AppAndroid 8.0: java.lang.IllegalStateException: Not allowed to start service Intent






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















hi as I would like to be able to run some code when the app is closed
(for closed I mean closed by the task manager).
my app must be able to make http requests via axios in the background on both android and ios (must send notifications using the local-notification plugin that reminds that one or more events in an external calendar will start in an hour), I searched in network and I saw the documentation but it is not clear how I should do, I also read that the way to run background code on android 8 changes radically.
Can someone explain to me what I have to do? what permissions should I request from the system? or if there is any example of code on the net.










share|improve this question






























    0















    hi as I would like to be able to run some code when the app is closed
    (for closed I mean closed by the task manager).
    my app must be able to make http requests via axios in the background on both android and ios (must send notifications using the local-notification plugin that reminds that one or more events in an external calendar will start in an hour), I searched in network and I saw the documentation but it is not clear how I should do, I also read that the way to run background code on android 8 changes radically.
    Can someone explain to me what I have to do? what permissions should I request from the system? or if there is any example of code on the net.










    share|improve this question


























      0












      0








      0








      hi as I would like to be able to run some code when the app is closed
      (for closed I mean closed by the task manager).
      my app must be able to make http requests via axios in the background on both android and ios (must send notifications using the local-notification plugin that reminds that one or more events in an external calendar will start in an hour), I searched in network and I saw the documentation but it is not clear how I should do, I also read that the way to run background code on android 8 changes radically.
      Can someone explain to me what I have to do? what permissions should I request from the system? or if there is any example of code on the net.










      share|improve this question
















      hi as I would like to be able to run some code when the app is closed
      (for closed I mean closed by the task manager).
      my app must be able to make http requests via axios in the background on both android and ios (must send notifications using the local-notification plugin that reminds that one or more events in an external calendar will start in an hour), I searched in network and I saw the documentation but it is not clear how I should do, I also read that the way to run background code on android 8 changes radically.
      Can someone explain to me what I have to do? what permissions should I request from the system? or if there is any example of code on the net.







      android axios nativescript nativescript-vue vue-nativescript






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 9 at 9:30







      Christopher Civitale

















      asked Mar 9 at 9:06









      Christopher CivitaleChristopher Civitale

      12




      12






















          2 Answers
          2






          active

          oldest

          votes


















          1














          Okay you should use a service in android.It's a simple class makes it happen in the background and after you're done you can stop the service.It works for android up to 26 api.(26 not included)



          https://developer.android.com/guide/components/services


          for 26 and higher you can use Managers there's a downloadManager already:



          https://developer.android.com/reference/android/app/DownloadManager


          You don't have to use it,you can also make yours in a Job Scheduler (above lollipop)



          There's a nice tutorial about it here:



          https://android.jlelse.eu/schedule-tasks-and-jobs-intelligently-in-android-e0b0d9201777


          Using Android Background Services in NativeScript:



          https://www.nativescript.org/blog/using-android-background-services-in-nativescript





          share|improve this answer

























          • Hi, this tutorial work on NativeScript Apps ?

            – Christopher Civitale
            Mar 9 at 9:37











          • @ChristopherCivitale No it's for android I added a new link for nativeScript at the end right now.

            – steve moretz
            Mar 9 at 9:42











          • hello I saw the documentation but it is not clear to me one thing. The example uses the tap event to start running in the background, how do I start the background service automatically without having to press the button?

            – Christopher Civitale
            Mar 9 at 15:01











          • You don't have to use a button.Start it whenever you want.on the start of the app.On server reply.On push notification.The limit is your imaginations.

            – steve moretz
            Mar 9 at 20:47


















          1














          Here are the samples for implementing background services for iOS & Android.



          There is also a plugin nativescript-background-fetch which might work for you.



          tns plugin add nativescript-background-fetch


          Invokes your callback function roughly every 15 mins while the app is not alive, so you could finish your background activities like downloading your content etc.,






          share|improve this answer























          • Hi, yes, this is what I was looking for. But I have a problem, I installed the plugin but when the amount using import BackgroundFetch from "nativescript-background-fetch" gives me this error: Cannot read property 'CompletitionHandler' of undefined

            – Christopher Civitale
            Mar 11 at 8:45











          • Is it a runtime exception or compile one?

            – Manoj
            Mar 11 at 8:49











          • runtime java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:

            – Christopher Civitale
            Mar 11 at 8:54











          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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55075710%2fnativescript-how-to-make-http-requests-in-the-background%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Okay you should use a service in android.It's a simple class makes it happen in the background and after you're done you can stop the service.It works for android up to 26 api.(26 not included)



          https://developer.android.com/guide/components/services


          for 26 and higher you can use Managers there's a downloadManager already:



          https://developer.android.com/reference/android/app/DownloadManager


          You don't have to use it,you can also make yours in a Job Scheduler (above lollipop)



          There's a nice tutorial about it here:



          https://android.jlelse.eu/schedule-tasks-and-jobs-intelligently-in-android-e0b0d9201777


          Using Android Background Services in NativeScript:



          https://www.nativescript.org/blog/using-android-background-services-in-nativescript





          share|improve this answer

























          • Hi, this tutorial work on NativeScript Apps ?

            – Christopher Civitale
            Mar 9 at 9:37











          • @ChristopherCivitale No it's for android I added a new link for nativeScript at the end right now.

            – steve moretz
            Mar 9 at 9:42











          • hello I saw the documentation but it is not clear to me one thing. The example uses the tap event to start running in the background, how do I start the background service automatically without having to press the button?

            – Christopher Civitale
            Mar 9 at 15:01











          • You don't have to use a button.Start it whenever you want.on the start of the app.On server reply.On push notification.The limit is your imaginations.

            – steve moretz
            Mar 9 at 20:47















          1














          Okay you should use a service in android.It's a simple class makes it happen in the background and after you're done you can stop the service.It works for android up to 26 api.(26 not included)



          https://developer.android.com/guide/components/services


          for 26 and higher you can use Managers there's a downloadManager already:



          https://developer.android.com/reference/android/app/DownloadManager


          You don't have to use it,you can also make yours in a Job Scheduler (above lollipop)



          There's a nice tutorial about it here:



          https://android.jlelse.eu/schedule-tasks-and-jobs-intelligently-in-android-e0b0d9201777


          Using Android Background Services in NativeScript:



          https://www.nativescript.org/blog/using-android-background-services-in-nativescript





          share|improve this answer

























          • Hi, this tutorial work on NativeScript Apps ?

            – Christopher Civitale
            Mar 9 at 9:37











          • @ChristopherCivitale No it's for android I added a new link for nativeScript at the end right now.

            – steve moretz
            Mar 9 at 9:42











          • hello I saw the documentation but it is not clear to me one thing. The example uses the tap event to start running in the background, how do I start the background service automatically without having to press the button?

            – Christopher Civitale
            Mar 9 at 15:01











          • You don't have to use a button.Start it whenever you want.on the start of the app.On server reply.On push notification.The limit is your imaginations.

            – steve moretz
            Mar 9 at 20:47













          1












          1








          1







          Okay you should use a service in android.It's a simple class makes it happen in the background and after you're done you can stop the service.It works for android up to 26 api.(26 not included)



          https://developer.android.com/guide/components/services


          for 26 and higher you can use Managers there's a downloadManager already:



          https://developer.android.com/reference/android/app/DownloadManager


          You don't have to use it,you can also make yours in a Job Scheduler (above lollipop)



          There's a nice tutorial about it here:



          https://android.jlelse.eu/schedule-tasks-and-jobs-intelligently-in-android-e0b0d9201777


          Using Android Background Services in NativeScript:



          https://www.nativescript.org/blog/using-android-background-services-in-nativescript





          share|improve this answer















          Okay you should use a service in android.It's a simple class makes it happen in the background and after you're done you can stop the service.It works for android up to 26 api.(26 not included)



          https://developer.android.com/guide/components/services


          for 26 and higher you can use Managers there's a downloadManager already:



          https://developer.android.com/reference/android/app/DownloadManager


          You don't have to use it,you can also make yours in a Job Scheduler (above lollipop)



          There's a nice tutorial about it here:



          https://android.jlelse.eu/schedule-tasks-and-jobs-intelligently-in-android-e0b0d9201777


          Using Android Background Services in NativeScript:



          https://www.nativescript.org/blog/using-android-background-services-in-nativescript






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 9 at 9:43

























          answered Mar 9 at 9:26









          steve moretzsteve moretz

          605112




          605112












          • Hi, this tutorial work on NativeScript Apps ?

            – Christopher Civitale
            Mar 9 at 9:37











          • @ChristopherCivitale No it's for android I added a new link for nativeScript at the end right now.

            – steve moretz
            Mar 9 at 9:42











          • hello I saw the documentation but it is not clear to me one thing. The example uses the tap event to start running in the background, how do I start the background service automatically without having to press the button?

            – Christopher Civitale
            Mar 9 at 15:01











          • You don't have to use a button.Start it whenever you want.on the start of the app.On server reply.On push notification.The limit is your imaginations.

            – steve moretz
            Mar 9 at 20:47

















          • Hi, this tutorial work on NativeScript Apps ?

            – Christopher Civitale
            Mar 9 at 9:37











          • @ChristopherCivitale No it's for android I added a new link for nativeScript at the end right now.

            – steve moretz
            Mar 9 at 9:42











          • hello I saw the documentation but it is not clear to me one thing. The example uses the tap event to start running in the background, how do I start the background service automatically without having to press the button?

            – Christopher Civitale
            Mar 9 at 15:01











          • You don't have to use a button.Start it whenever you want.on the start of the app.On server reply.On push notification.The limit is your imaginations.

            – steve moretz
            Mar 9 at 20:47
















          Hi, this tutorial work on NativeScript Apps ?

          – Christopher Civitale
          Mar 9 at 9:37





          Hi, this tutorial work on NativeScript Apps ?

          – Christopher Civitale
          Mar 9 at 9:37













          @ChristopherCivitale No it's for android I added a new link for nativeScript at the end right now.

          – steve moretz
          Mar 9 at 9:42





          @ChristopherCivitale No it's for android I added a new link for nativeScript at the end right now.

          – steve moretz
          Mar 9 at 9:42













          hello I saw the documentation but it is not clear to me one thing. The example uses the tap event to start running in the background, how do I start the background service automatically without having to press the button?

          – Christopher Civitale
          Mar 9 at 15:01





          hello I saw the documentation but it is not clear to me one thing. The example uses the tap event to start running in the background, how do I start the background service automatically without having to press the button?

          – Christopher Civitale
          Mar 9 at 15:01













          You don't have to use a button.Start it whenever you want.on the start of the app.On server reply.On push notification.The limit is your imaginations.

          – steve moretz
          Mar 9 at 20:47





          You don't have to use a button.Start it whenever you want.on the start of the app.On server reply.On push notification.The limit is your imaginations.

          – steve moretz
          Mar 9 at 20:47













          1














          Here are the samples for implementing background services for iOS & Android.



          There is also a plugin nativescript-background-fetch which might work for you.



          tns plugin add nativescript-background-fetch


          Invokes your callback function roughly every 15 mins while the app is not alive, so you could finish your background activities like downloading your content etc.,






          share|improve this answer























          • Hi, yes, this is what I was looking for. But I have a problem, I installed the plugin but when the amount using import BackgroundFetch from "nativescript-background-fetch" gives me this error: Cannot read property 'CompletitionHandler' of undefined

            – Christopher Civitale
            Mar 11 at 8:45











          • Is it a runtime exception or compile one?

            – Manoj
            Mar 11 at 8:49











          • runtime java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:

            – Christopher Civitale
            Mar 11 at 8:54















          1














          Here are the samples for implementing background services for iOS & Android.



          There is also a plugin nativescript-background-fetch which might work for you.



          tns plugin add nativescript-background-fetch


          Invokes your callback function roughly every 15 mins while the app is not alive, so you could finish your background activities like downloading your content etc.,






          share|improve this answer























          • Hi, yes, this is what I was looking for. But I have a problem, I installed the plugin but when the amount using import BackgroundFetch from "nativescript-background-fetch" gives me this error: Cannot read property 'CompletitionHandler' of undefined

            – Christopher Civitale
            Mar 11 at 8:45











          • Is it a runtime exception or compile one?

            – Manoj
            Mar 11 at 8:49











          • runtime java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:

            – Christopher Civitale
            Mar 11 at 8:54













          1












          1








          1







          Here are the samples for implementing background services for iOS & Android.



          There is also a plugin nativescript-background-fetch which might work for you.



          tns plugin add nativescript-background-fetch


          Invokes your callback function roughly every 15 mins while the app is not alive, so you could finish your background activities like downloading your content etc.,






          share|improve this answer













          Here are the samples for implementing background services for iOS & Android.



          There is also a plugin nativescript-background-fetch which might work for you.



          tns plugin add nativescript-background-fetch


          Invokes your callback function roughly every 15 mins while the app is not alive, so you could finish your background activities like downloading your content etc.,







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 9 at 13:32









          ManojManoj

          8,45921024




          8,45921024












          • Hi, yes, this is what I was looking for. But I have a problem, I installed the plugin but when the amount using import BackgroundFetch from "nativescript-background-fetch" gives me this error: Cannot read property 'CompletitionHandler' of undefined

            – Christopher Civitale
            Mar 11 at 8:45











          • Is it a runtime exception or compile one?

            – Manoj
            Mar 11 at 8:49











          • runtime java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:

            – Christopher Civitale
            Mar 11 at 8:54

















          • Hi, yes, this is what I was looking for. But I have a problem, I installed the plugin but when the amount using import BackgroundFetch from "nativescript-background-fetch" gives me this error: Cannot read property 'CompletitionHandler' of undefined

            – Christopher Civitale
            Mar 11 at 8:45











          • Is it a runtime exception or compile one?

            – Manoj
            Mar 11 at 8:49











          • runtime java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:

            – Christopher Civitale
            Mar 11 at 8:54
















          Hi, yes, this is what I was looking for. But I have a problem, I installed the plugin but when the amount using import BackgroundFetch from "nativescript-background-fetch" gives me this error: Cannot read property 'CompletitionHandler' of undefined

          – Christopher Civitale
          Mar 11 at 8:45





          Hi, yes, this is what I was looking for. But I have a problem, I installed the plugin but when the amount using import BackgroundFetch from "nativescript-background-fetch" gives me this error: Cannot read property 'CompletitionHandler' of undefined

          – Christopher Civitale
          Mar 11 at 8:45













          Is it a runtime exception or compile one?

          – Manoj
          Mar 11 at 8:49





          Is it a runtime exception or compile one?

          – Manoj
          Mar 11 at 8:49













          runtime java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:

          – Christopher Civitale
          Mar 11 at 8:54





          runtime java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException:

          – Christopher Civitale
          Mar 11 at 8:54

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55075710%2fnativescript-how-to-make-http-requests-in-the-background%23new-answer', 'question_page');

          );

          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







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved