Giter Site home page Giter Site logo

joaolss / react-native-background-worker Goto Github PK

View Code? Open in Web Editor NEW
51.0 51.0 10.0 3.98 MB

Perform tasks in background using Android's WorkManager

Home Page: https://www.npmjs.com/package/react-native-background-worker

License: MIT License

Java 65.05% TypeScript 30.03% Objective-C 1.87% Ruby 3.05%

react-native-background-worker's People

Contributors

dependabot[bot] avatar joaolss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-background-worker's Issues

compileSdkVersion is not specified: react-native-background-worker

How to solve these problems?

  • What went wrong:
    A problem occurred evaluating project ':react-native-background-worker'.> Plugin with id 'maven' not found.

  • What went wrong:
    A problem occurred configuring project ':react-native-background-worker'.> compileSdkVersion is not specified. Please add it to build.gradle

  • Build file 'C:\Projects\Project1\node_modules\react-native-background-worker\android\build.gradle' line: 20

android/build.gradle

buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33

    // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
    ndkVersion = "23.1.7779620"
    kotlin_version = '1.7.20'
}
repositories {
    google()
    mavenCentral()
}
dependencies {
    classpath("com.android.tools.build:gradle")
    classpath("com.facebook.react:react-native-gradle-plugin")
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
}

}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}

    google()
    jcenter()
    maven { url 'https://jitpack.io' }
}

}

android/app/build.gradle

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"

/**

  • This is the configuration block to customize your React Native Android app.

  • By default you don't need to apply any configuration, just uncomment the lines you need.
    /
    react {
    /
    Folders */
    // The root of your project, i.e. where "package.json" lives. Default is '..'
    // root = file("../")
    // The folder where the react-native NPM package is. Default is ../node_modules/react-native
    // reactNativeDir = file("../node_modules/react-native")
    // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
    // codegenDir = file("../node_modules/@react-native/codegen")
    // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
    // cliFile = file("../node_modules/react-native/cli.js")

    /* Variants */
    // The list of variants to that are debuggable. For those we're going to
    // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
    // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
    // debuggableVariants = ["liteDebug", "prodDebug"]

    /* Bundling */
    // A list containing the node command and its flags. Default is just 'node'.
    // nodeExecutableAndArgs = ["node"]
    //
    // The command to run when bundling. By default is 'bundle'
    // bundleCommand = "ram-bundle"
    //
    // The path to the CLI configuration file. Default is empty.
    // bundleConfig = file(../rn-cli.config.js)
    //
    // The name of the generated asset file containing your JS bundle
    // bundleAssetName = "MyApplication.android.bundle"
    //
    // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
    // entryFile = file("../js/MyApplication.android.js")
    //
    // A list of extra flags to pass to the 'bundle' commands.
    // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
    // extraPackagerArgs = []

    /* Hermes Commands */
    // The hermes compiler command to run. By default it is 'hermesc'
    // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
    //
    // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
    // hermesFlags = ["-O", "-output-source-map"]
    }

/**

  • Set this to true to Run Proguard on Release builds to minify the Java bytecode.
    */
    def enableProguardInReleaseBuilds = false

/**

  • The preferred build flavor of JavaScriptCore (JSC)
  • For example, to use the international variant, you can use:
  • def jscFlavor = 'org.webkit:android-jsc-intl:+'
  • The international variant includes ICU i18n library and necessary data
  • allowing to use e.g. Date.toLocaleString and String.localeCompare that
  • give correct results when using with locales other than en-US. Note that
  • this variant is about 6MiB larger per architecture than default.
    */
    def jscFlavor = 'org.webkit:android-jsc:+'

android {
ndkVersion rootProject.ext.ndkVersion

compileSdkVersion rootProject.ext.compileSdkVersion

namespace "com.youtubelive"
defaultConfig {
    applicationId "com.youtubelive"
    minSdkVersion rootProject.ext.minSdkVersion
    compileSdkVersion rootProject.ext.compileSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
}
signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://reactnative.dev/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

}

dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.squareup.okhttp3', module:'okhttp'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
    implementation("com.facebook.react:hermes-android")
} else {
    implementation jscFlavor
}

}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

Is it support Android 5?

Is your feature request related to a problem? Please describe.
Is this library supports Android 5?

android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground

Describe the bug
foregroundServices not allowed exception is coming only in android12 devices. here iam using react-native-background-worker to fetch foreground service(iam calling one api to notify something to user) when my app is in background.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'foreground service api calling screen'
  2. put app in background
  3. app is crashing by displaying above error

Expected behavior
it is working fine in other os version mobiles except android 12 and api level > 31

Smartphone (please complete the following information):

  • Device: Any Mobile device with android os 12
  • OS: android os should be 12

Tasks are not processed in a closed application

Tell me, please, how to achieve the work of tasks with the application closed, is this generally available?

The WorkManager documentation says that it is available:
image

If this is unrealistic, why?

Reuest on writing more examples

Hello,
would it be possible to include an example app with the examples from the readme?
I am very interested in using this library.
If you can provide me with some extra details i can build it myself and pull request it.
Thank you.

Ordered queue

Now there is no execution order, that is, if a task is created with the queue type with data:
1
2
3
4

then their call will be done in the reverse order in blocking mode when the device is locked, or even in which it is not clear.

Can this be fixed? Do not execute the second until success in the first is returned?

Jobs not getting persisted

I have noticed that the jobs enqueued are not being persisted upon closing and reopening the App.

To Reproduce
Steps to reproduce the behavior:

  1. Try registering long duration jobs such as uploading a bunch of images and persisting it's progress on a realm database.
  2. Kill app and reopen it.
  3. The worker will no longer start up and continue processing

Smartphone (please complete the following information):

  • Device: Galaxy S10
  • OS: Android 10

Auto remove worker when creating another worker with the same key

I would suggest make an solution on case when I need to dynamic change of reapeatInterval in worker.
For instance.

I need to create worker with 15 minutes reapet time for the first workflow occurs but later when workflow end I need to manipulete repaet interval to Increase or decrease its time. Ofcourse not less than 15 minutes.

Right now to do that I need to create helper consts that will take care of new interval values and when this value (baseInterval, newInterval) are not equals I have cancel actual worker and start new one with new interval. That cause warning on rn 63.4 -> "registerHeadelessTask or registerCancellableHeadlessTask called multiple times for same key"

Maybe you guys have better solution for that right now. Maybe ingeration in package will be unnecessary.

Regards

The queue does not work without payload

In the documentation, payload is marked as an optional parameter, but without it, workflow does not start. If you transfer an empty object to payload then everything is ok.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.