react-native-background-task | Periodic background tasks for React Native apps | iOS library

 by   jamesisaac Java Version: 0.2.1 License: MIT

kandi X-RAY | react-native-background-task Summary

kandi X-RAY | react-native-background-task Summary

react-native-background-task is a Java library typically used in Mobile, iOS, React Native, React applications. react-native-background-task has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. However react-native-background-task build file is not available. You can install using 'npm i react-native-background-task' or download it from GitHub, npm.

Periodic background tasks for React Native apps, cross-platform (iOS and Android), which run even when the app is closed.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              react-native-background-task has a medium active ecosystem.
              It has 1037 star(s) with 110 fork(s). There are 14 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 59 open issues and 19 have been closed. On average issues are closed in 162 days. There are 8 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of react-native-background-task is 0.2.1

            kandi-Quality Quality

              react-native-background-task has no bugs reported.

            kandi-Security Security

              react-native-background-task has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              react-native-background-task is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              react-native-background-task releases are available to install and integrate.
              Deployable package is available in npm.
              react-native-background-task has no build file. You will be need to create the build yourself to build the component from source.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed react-native-background-task and discovered the below as its top functions. This is intended to give you an instant insight into react-native-background-task implemented functionality, and help decide if they suit your requirements.
            • Schedules a background task
            • Commit the scheduled job
            • This is called when a pause occurs
            • Sets the foreground
            • Invoked when a job is running
            • Initializes the ReactApplicationContext
            • Returns the task config for the task
            • Cancels the currently scheduled task
            • Creates the native modules
            • Resume all the active jobs
            • Create the modules
            • Create view managers
            • Sets up the native job creator
            Get all kandi verified functions for this library.

            react-native-background-task Key Features

            No Key Features are available at this moment for react-native-background-task.

            react-native-background-task Examples and Code Snippets

            Is there a way to make api calls and save data to asyncstorage in react native when the app is closed?
            JavaScriptdot img1Lines of Code : 19dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import React from 'react'
            import { Text } from 'react-native'
            import BackgroundTask from 'react-native-background-task'
            
            BackgroundTask.define(() => {
              console.log('Hello from a background task')
              BackgroundTask.finish()
            })
            
            class MyA
            Local Schedule Notification react native
            JavaScriptdot img2Lines of Code : 130dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import React from 'react'
            import { Text } from 'react-native'
            import BackgroundTask from 'react-native-background-task'
            import { Notifications, Permissions, Constants } from 'expo';
            
            BackgroundTask.define(async () => {
            
             // if time is 1
            copy iconCopy
            import React from 'react'
            import { Text } from 'react-native'
            import BackgroundTask from 'react-native-background-task'
            
            BackgroundTask.define(() => {
              console.log('Hello from a background task')
              BackgroundTask.finish()
            })
            
            class MyA

            Community Discussions

            QUESTION

            How to implement code with long execution time in React Native?
            Asked 2020-Mar-03 at 13:16

            I'm building a new app with React Native and Expo. The main function of this app is to generate plans for user. The generating algorithm will take estimated around 300-500 seconds to execute. (It contains maximum 2,100,000 times of random generating.)

            Currently I am facing two problems:

            Q1. during testing, this piece of code is put in the App.js - App class - render function directly. however, it seems that if the execution time exceeds 32 seconds the app will just fail to render and stay no response forever.

            So the question is:

            1.1 what's the reason of the maximum 32 seconds otherwise no response?

            1.2 are there better ways to do testing?

            Current testing method:

            ...

            ANSWER

            Answered 2020-Mar-03 at 13:16

            Well, I don't think there is one definite answer for your question, But here is what i think:

            • I'm not sure about any 32 seconds render limit but blocking the UI for even 1 second is not practical and bad for user experience.
            • It is not a good practice to to perform anything inside the render() method. This method is called frequently whenever a piece of the state is updated or the component is re-rendered. So it should be as light as possible and should only contain the returned components, Also to avoid any unexpected behaviors the render() method should be a pure method.
            • What i would do in this case is re-writing the calculation algorithm in C++ then create a bridge between React Native and Android/iOS where i can run the code on a thread beside the UI thread then return the value to the JavaScript part of the app.
              • Using C++ in heavy calculations should give you a boost in performance and will help you keep your algorithm in one place (For easier maintenance and debugging).
              • You can also write the algorithm twice using Java/Kotlin for Android and Objective-C for iOS, This method is useful to avoid any C++ code complications but again you're writing the same code twice in different languages (So you'll face other complications).
              • Check out this article to learn more about Native Modules/Bridges.
              • Also check out this article to get information about C++ for Android.
            • Another way to solve this problem is to move the algorithm to a centralized server where you calculate the values and store it on the server then retrieve it using some kind of web api.
            • Now if you want (for some reason) to keep your algorithm in JavaScript, You'll have to break the calculation process into tiny and lightweight pieces then requestAnimationFrame for every piece, For example if your algorithm generates a random number then does some calculation on it and repeats this process for 2 million times, You'll need to requestAnimationFrame for every calculation, store the current result somewhere and request another frame for the next calculation.
              • We've to do this because by contract JavaScript has only one thread and all JS code including rending frames on the screen happens on this thread so we break our code into small pieces to allow for new frames to be rendered in between.
              • Check out this article to learn more about dividing workloads and animation frames.

            Good Luck

            Source https://stackoverflow.com/questions/57602537

            QUESTION

            Is there any way to do background tasks in React Native other than react-native-background-task?
            Asked 2020-Feb-01 at 22:28

            I'm trying to do in my React Native App that each X min the app fetch some data of my application included if the app is closed. Or more similar, each X min I want to save a value in the AsyncStorage.

            It suppose that the react-native-background-task does that but, unfortunately, the project is abandoned with a lot of errors and bugs that make using it unviable.

            Is there any other way to do it?

            ...

            ANSWER

            Answered 2020-Feb-01 at 22:28

            Have you tried react-native-queue.I think it will suit your requirement.

            Click here For complete guide.

            You can try react-native-background-jobtoo.

            Click Here for Complete Guide

            Source https://stackoverflow.com/questions/55725679

            QUESTION

            How to properly work with redux saga and background event in react native?
            Asked 2019-Aug-23 at 19:34

            I am using react-native, redux-saga, react-native-background-task.

            First, when my app goes from the foreground to the background (on both IOS and Android), saga continues. I would have expected it to stop, but I guess because saga is on another thread it continues. Is this going to cause issues for battery management or prevent IOS from allowing to app to execute background fetch events?

            Second, when a background task starts, on the Android app my main saga starts like normal (not expected behavior, I would have thought only the background task code to run. On IOS, only the background task code runs as I would have expected. Why does the Android app start the whole saga again?

            Third, when I use xcode to 'simulate background fetch' it was working for a little bit, but now it is closing whatever other app is open and not running the task code. Why is this?

            Here is where I define my background task:

            ...

            ANSWER

            Answered 2019-Aug-23 at 19:34

            When a react native app is backgrounded on android it doesn't mean the activity is necessarily destroyed so your js code may continue to run for an indeterminate amount of time. Eventually it's likely your activity will be stopped if the user doesn't open it again but you can't know exactly when. You could use react native's AppState (https://facebook.github.io/react-native/docs/appstate) to cancel sagas that you wish cancelled when the app goes into the background.

            For the background task question, the implementation on android for BackgroundTask uses react native's headless js (https://facebook.github.io/react-native/docs/headless-js-android.html) which starts your entire app in the background. On ios there is no headless js so the implementation is different.

            Source https://stackoverflow.com/questions/57631422

            QUESTION

            Using of Set Interval in React Native Android and iOS
            Asked 2019-Jul-02 at 02:16

            Both React Native Video and timer (used setInterval) are worked on foreground and timer is stopped when app is in the background. But still video plays in the background.

            It means, when the application pauses, so do all setInterval's running and (and setTimeouts pending).

            headlessJs api is available only for android to run the task in background.

            If I use headlessJs, Isn't product pain for react native to run a timer?

            There are some desired libraries,

            react-native-background-job - Use headlessJs and work only in android.

            react-native-background-task - Use headlessJs in android and ios uses a proxy around react-native-background-fetch library (Support only for a single task,The exact timings of task execution are unpredictable)

            react-native-background-fetch

            Can I use setInterval in the background service if I use those libraries?

            Why only music player is working in the background?

            ...

            ANSWER

            Answered 2019-Jul-02 at 02:16

            I found a solution from react-native-background-timer library.

            In iOS, we can start the timer or do any react native stuff in the background after execute the following code.

            Background timer works even we use other apps in the device. (Ex: itune, whatsup)

            Source https://stackoverflow.com/questions/55039857

            QUESTION

            React Native: Best approach to run a background task on iOS when the app is closed?
            Asked 2019-Apr-04 at 12:35

            I need to send HealthKit data to a server periodically. I'm using React Native and rn-apple-healthkit. I tried react-native-background-task, but it won't work while the application is closed (not background mode). I read in Apple developer docs that it happens by design.

            I found some solutions online such as geolocation services, running a socket and "playing" silent sounds, piggybacking on push notifications but they all seem like workarounds.

            Is there a good way to do this in 2019?

            ...

            ANSWER

            Answered 2019-Apr-04 at 12:35

            Using silent notifications is the correct way of achieving this. However it wont work when the phone is locked:

            For security, the HealthKit store is encrypted when the device is locked, and the HealthKit store can only be accessed by an authorized app. As a result, you may not be able to read data from the store when your app is launched in the background; however, apps can still write data to the store, even when the phone is locked.

            Taken from https://developer.apple.com/documentation/healthkit/protecting_user_privacy

            Source https://stackoverflow.com/questions/55515675

            QUESTION

            Error: more than one library with package name 'com.reactnativecomponent.splashscreen'
            Asked 2018-Jun-13 at 10:04

            I'm getting following error while running app for android

            ...

            ANSWER

            Answered 2018-Jun-13 at 09:57

            Here you are using same dependencies two times in 1st line and in 4th last line remove one from here. don't use same dependencies for multiple times

            Source https://stackoverflow.com/questions/50833735

            QUESTION

            React native cannot read index.android.delta
            Asked 2018-May-16 at 13:57

            I have already tried a lot but could not get it fix. Everything was working good before I added react-native-easy-gridview in my packages.json and then I checked out my changes after that I got this.

            Here is my build.gradle

            ...

            ANSWER

            Answered 2018-May-15 at 09:03

            Edit android/app/build.gradle

            use this

            compile ("com.facebook.react:react-native:0.44.0") { force = true }

            and write version of app you use instead of 0.44.0 and delete something like this compile "com.facebook.react:react-native:+" or this compile "com.facebook.react:react-native:0.44.0"

            Source https://stackoverflow.com/questions/50344830

            QUESTION

            react-native-background-task Expected to run on UI thread
            Asked 2018-Apr-25 at 20:32

            I am trying to sync data capture offline with an online api, I periodically run an background task using react-native-background-task to retrieve offline data and sync the data with an online api.

            react-native-background-task error

            ...

            ANSWER

            Answered 2018-Apr-25 at 20:32

            I fixed it, it turned out react-native-background-task version wasn't compatible with my react-native version, i upgraded from 0.48.1 to 0.51.0 which requires react 16.0.0

            Source https://stackoverflow.com/questions/50000868

            QUESTION

            Background fetch, testing problems
            Asked 2017-Oct-15 at 12:53

            I have a react-native application which includes react-native-background-task which uses react-native-background-fetch. I configured a job to console.log a simple message when it runs. I understand that the background fetch is not working on simulator, but you can test it by going into Debug -> Simulate background fetch. When I hit this, the app goes to background. I did not get any output. I have enabled background fetch in Info.plis and also the code returns status.available when I check with the library function. How do you actually test this?

            ...

            ANSWER

            Answered 2017-Sep-22 at 07:13

            Since you've mentioned that you've tried writing to storage also - which is not working - my updated answer would be: while you are running background fetch, you can at the same time hit a server on which you can see the logs. That way, you can tell, if the background fetch was successfully working.

            I've created a hackable localTestingServer that you can fork and get started immediately.

            Source https://stackoverflow.com/questions/46358664

            QUESTION

            Background job with period lower than 15 minutes on ios
            Asked 2017-Jun-18 at 03:34

            I am building an app for ios in react native.

            Using the react-native-background-task I am running a task that fetches data from a server.
            On IOS the default and lowest period is 15 minutes, which is too high for what I need.
            Is there a way to create a background task on IOS with a lower period?

            ...

            ANSWER

            Answered 2017-Jun-17 at 22:22

            The short answer is you can't.

            iOS does not support frequently polling in the background as it is not battery or network friendly.

            That module uses the iOS background fetch service which is the only supported background fetch facility on iOS.

            With background fetch, iOS invokes you background fetch handler when it determines. This may be even less frequently than 15 minutes; the time interval you supply is a requested interval only and will be modified based on how often and when you server returns new data and other factors.

            The preferred approach is to use a push notification when your server has new data.

            Source https://stackoverflow.com/questions/44608289

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install react-native-background-task

            You can install using 'npm i react-native-background-task' or download it from GitHub, npm.
            You can use react-native-background-task like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the react-native-background-task component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • npm

            npm i react-native-background-task

          • CLONE
          • HTTPS

            https://github.com/jamesisaac/react-native-background-task.git

          • CLI

            gh repo clone jamesisaac/react-native-background-task

          • sshUrl

            git@github.com:jamesisaac/react-native-background-task.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular iOS Libraries

            swift

            by apple

            ionic-framework

            by ionic-team

            awesome-ios

            by vsouza

            fastlane

            by fastlane

            glide

            by bumptech

            Try Top Libraries by jamesisaac

            JamesiHttpCacheBundle

            by jamesisaacPHP

            redirect

            by jamesisaacPHP

            nach-toolkit

            by jamesisaacPython

            JamesiNotificationBundle

            by jamesisaacPHP

            api-platform-nested-filter

            by jamesisaacJavaScript