- [Android] Implement support for new "Bridgeless Architecture".
- [iOS] Code-sign
TSBackgroundFetch.xcframework
with new Apple Organization (9224-2932 Quebec Inc) certificate.
- [iOS] codesign
TSBackgroundFetch
- [iOS] Add PrivacyInfo -> TSBackgroundFetch.xcframework
- [iOS] Implement new iOS Privacy Manifest
- [Expo] Fix bug for Expo v50 "Invalid regular expression".
- [iOS] Only allow registration of
BGProcessingTasks
(Permitted background task scheduler identifiers) inInfo.plist
which are prefixed withcom.transistorsoft
. Any other task identifier will be ignored.
- [Android] Detect and dispose of duplicate events. Android
JobService
has a bug for devices running <= Android M where multiplebackgrou nd-fetch
events could fire within the same second.
- [Android] Android 14 (SDK 34) support.
- [Android] Android 14 (SDK 34) support: When using
forceAlarmManager: true
, you must now optionally add the permissionandroid.permission.USE_EXACT_ALARM
to yourAndroidManifest
to schedule exact alarms. OtherwiseAlarmManager
will use in-exact alarms. NOTE You must include the permission exactly as-shown withandroid:minSdkVersion="34"
.
📂 AndroidManifest
<manifest>
<!-- [background-fetch] OPTIONAL: allows forceAlarmManager: true to use exact alarms -->
<uses-permission android:name="android.permission.USE_EXACT_ALARM" android:minSdkVersion="34" />
.
.
.
</manifest>
- [Android] Gradle v8 now requires
namespace
attribute in gradle files.
- [Android] Fix expo plugin failing on Expo SDK >= 48. Regular expressions failed because Expo changed lines in the build.gradle files that the Expo plugin was using for anchors for where to inject new src. Changed to use more fundamental anchor elements for regular expressions that must exist.
- [Android] Fix expo plugin failing on Expo SDK >= 48. Regular expressions failed because Expo changed lines in the build.gradle files that the Expo plugin was using for anchors for where to inject new src c
- [Android] Log JobScheduler jobId to facilitate simulating scheduleTask events with
adb shell
:
// from adb logcat *:S TSBackgroundFetch
TSBackgroundFetch: - registerTask: com.transistorsoft.customtask (jobId: -359368280) <--
Now copy that jobId
from logcat and insert into the adb shell
command to simulate a task:
$ adb shell cmd jobscheduler run -f com.your.package.name -359368280
- Fix typo in previous release.
TaskConfig.requiresNetworkConnectivity
was missing from typescript API.
- Remove
peerDependencies
.
- [Expo] The plugin now implements an Expo
ConfigPlugin
for automated Setup.
- [Android] Use
LifecycleManager
for modern headless-detection instead of legacy mechanism requiring permissionGET_TASKS
.
- [Android] Implement gradle ext variable getter
minSdkVersion
instead of hard-coded16
.
- Fix issue for react-native 0.69: They made a breaking change with the old, unused react-native.config.js, causing builds to fail. Simply delete the file
react-native.config.js
.
- [Android] Add new permission required for Android 12: android.permission.SCHEDULE_EXACT_ALARM
- [Fixed][iOS] Remove obsolete
__has_include("RCTEventEmitter.h")
code which was breaking Expo apps.
- [Fixed] EventEmitter warning about
addListener
/removeListeners
- [Changed] Re-generate /example app with
react-native init
. Complete re-factor to use React Hooks.
- [Changed][Android] Allow multiple calls to .configure to allow re-configuring the fetch task. Existing task will be cancelled and a new periodic fetch task re-scheduled according to new config.
- [Changed][Android] Ignore initial fetch task fired immediately.
- [Changed][Android]
android:exported="false"
onBootReceiver
to resolve reported security analysis.
- [Fixed] Typescript definition for interface
HeadlessEvent
was missingtimeout: boolean
attribute. Thanks @mikehardy.
- [Fixed][Android] Fix
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.transistorsoft.tsbackgroundfetch.BGTask.getTaskId()' on a null object reference
- [Fixed][iOS] Mistake implementing timeout callback for TSBackgroundFetch addListener. Provided old signature.
-
[Added][iOS] Implement two new iOS options for
BackgroundFetch.scheduleTask
:bool requiresNetworkConnectivity
bool requiresCharging
(previously Android-only).
-
[Changed][iOS] Migrate
TSBackgroundFetch.framework
to new.xcframework
for MacCatalyst support with new Apple silcon.
iOS' new .xcframework
requires cocoapods >= 1.10+:
$ pod --version
// if < 1.10.0
$ sudo gem install cocoapods
- [Added] task-timeout callback.
BackgroundFetch.configure
now accepts the 3rd callback argument asonTimeout
callback. This callback will be executed when the operating system has signalled your background-time is about to expire. You must stop what your task is doing and executeBackgroundFetch.finish(taskId)
immediately.
let status = await BackgroundFetch.configure({ // <-- NEW: returns Promise
minimumFetchInterval: 15
}, async (taskId) => { // <-- task callback.
console.log("[BackgroundFetch] taskId:", taskId);
BackgroundFetch.finish(taskId);
}, async (taskId) => { // <-- NEW: task-timeout callback.
// This task has exceeded its allowed running-time.
// You must stop what you're doing immediately finish(taskId)
//
console.log("[BackgroundFetch] TIMEOUT taskId", taskId);
BackgroundFetch.finish(taskId);
});
- Headless task event-object now includes a new attribute
event.timeout
when the OS signals your allowed background-time is about to expire. You must immediately finish what you're doing and callBackgroundFetch.finish(taskId)
immediately.
let myBackgroundFetchHeadlessTask = async (event) => {
let taskId = event.taskId;
let isTimeout = event.timeout; // <-- NEW: true if this task has timed-out.
if (isTimeout) {
// This task has exceeded its allowed running-time.
// You must stop what you're doing immediately BackgroundFetch.finish(taskId)
console.log("[BackgroundFetch] Headless TIMEOUT", taskId);
BackgroundFetch.finish(taskId);
return;
}
console.log("[BackgroundFetch] Headless task:", taskId);
BackgroundFetch.finish(taskId);
}
BackgroundFetch.registerHeadlessTask(myBackgroundFetchHeadlessTask);
- [Changed] API for
BackgroundGeolocation.configure
now returns aPromise<BackgroundFetchStatus>
OLD:
When BackgroundFetch
failed to start (eg: user disabled "Background Fetch" permission in your app settings), the 3rd argument failureCallback
would fire with the current BackgroundFetchStatus
.
BackgroundFetch.configure(options, eventCallback, failureCallback);
NEW:
The current BackgroundFetchStatus
is now returned as a Promise
when calling .configure()
. The 3rd argument is now timeoutCallback
, executed when OS has signalled your allowed background time is about to expire:
// BackgroundFetch event handler.
const onEvent = async (taskId) => { // <-- task callback.
console.log('[BackgroundFetch] task: ', taskId);
// Do your background work...
BackgroundFetch.finish(taskId);
}
// NEW: Timeout callback is executed when your Task has exceeded its allowed running-time.
// You must stop what you're doing immediately BackgorundFetch.finish(taskId)
const onTimeout = async (taskId) => {
console.warn('[BackgroundFetch] TIMEOUT task: ', taskId);
BackgroundFetch.finish(taskId);
}
// Initialize BackgroundFetch only once when component mounts.
let status = await BackgroundFetch.configure({minimumFetchInterval: 15}, onEvent, onTimeout);
console.log('[BackgroundFetch] configure status: ', status);
- [Fixed][Android]
com.android.tools.build:gradle:4.0.0
no longer allows "direct local aar dependencies". The Android Setup now requires a custommaven url
to be added to your app's rootandroid/build.gradle
:
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")
}
+ maven {
+ // react-native-background-fetch
+ url("${project(':react-native-background-fetch').projectDir}/libs")
+ }
}
}
- [Fixed] Android check
wakeLock.isHeld()
before executingwakeLock.release()
.
- [Fixed] Remove an unnecessary reference to
androidx
to allow the plugin to work with non-androidX for those using RN<=0.59
. - [Added] Update Android Setup with new required
proguard-rules.pro
for those building release withminifyEnabled true
. Fixes #261.
- Edit
android/app/proguard-rules.pro
. - Add the following rule:
# [react-native-background-fetch]
-keep class com.transistorsoft.rnbackgroundfetch.HeadlessTask { *; }
- [Fixed] [iOS] Fixed bug calling
start
after executingstop
.
- [Fixed] [Android]
stopOnTerminate: false
not cancelling scheduled job / Alarm when fired task fired after terminate.
- [Android] Fix Android NPE on
hasTaskId
when launched first time after upgrading to v3
- [iOS] It's no longer necessary to
registerAppRefreshTask
andregisterBGProcessingTask
inAppDelegate.m
The SDK now reads the App.plist
and automatically registers those tasks found in "Permitted background task scheduler identifiers", offering one simple setup methoddidFinishLaunching
: Make the following change to yourAppDelegate.m
:
#import <TSBackgroundFetch/TSBackgroundFetch.h>
@implementation AppDelegate
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
.
.
.
// [react-native-background-fetch Setup] -- One easy step now:
+ [[TSBackgroundFetch sharedInstance] didFinishLaunching];
- TSBackgroundFetch *fetch = [TSBackgroundFetch sharedInstance];
- // [REQUIRED] Register for usual periodic background refresh events here:
- [fetch registerAppRefreshTask];
- // [OPTIONAL] IF you've registered custom "Background Processing Task(s)" in your Info.plist above,
- // for use with #scheduleTask method, register each of those taskId(s) here as well.
- [fetch registerBGProcessingTask:@"com.foo.customtask"];
return YES;
}
-
[Fixed] Android - Incorrect event signature for method stop (not receiving success, failure callbacks)
-
[Fixed] iOS - Missing native implementation for method scheduleTask.
-
[Changed] Bumped 2.8.0 to 3.0.0 to better flag this version for breaking changes.
-
[Added] [Android] New option
forceAlarmManager
for bypassingJobScheduler
mechanism in favour ofAlarmManager
for more precise scheduling task execution. -
[Changed] Migrate iOS deprecated "background-fetch" API to new BGTaskScheduler. See new required steps in iOS Setup.
-
[Added] Added new
BackgroundFetch.scheduleTask
method for scheduling custom "onehot" and periodic tasks in addition to the default fetch-task.
BackgroundFetch.configure({
minimumFetchInterval: 15,
stopOnTerminate: false
}, (taskId) => { // <-- [NEW] taskId provided to Callback
console.log("[BackgroundFetch] taskId: ", taskId);
switch(taskId) {
case 'foo':
// Handle scheduleTask 'foo'
break;
default:
// Handle default fetch event.
break;
}
BackgroundFetch.finish(taskId); // <-- [NEW] Provided taskId to #finish method.
});
// This event will end up in Callback provided to #configure above.
BackgroundFetch.scheduleTask({
taskId: 'foo', //<-- required
delay: 60000,
periodic: false
});
- With the introduction of ability to execute custom tasks via
#scheduleTask
, all tasks are executed in the Callback provided to#configure
. As a result, this Callback is now provided an argumentString taskId
. ThistaskId
must now be provided to the#finish
method, so that the SDK knows which task is being#finish
ed.
BackgroundFetch.configure({
minimumFetchInterval: 15,
stopOnTerminate: false
), (taskId) => { // <-- [NEW] taskId provided to Callback
console.log("[BackgroundFetch] taskId: ", taskId);
BackgroundFetch.finish(taskId); // <-- [NEW] Provided taskId to #finish method.
});
And with the Headless Task, as well:
let backgroundFetchHeadlessTask = async (event) => { // <-- 1. Headless task receives {}
// Get taskId from event {}:
let taskId = event.taskId;
console.log("[BackgroundFetch] Headless event received: ", taskId);
BackgroundFetch.finish(taskId); // <-- 2. #finish with taskId here as well.
}
BackgroundFetch.registerHeadlessTask(backgroundFetchHeadlessTask);
- [Fixed] Resolve StrictMode violations; typically from accessing SharedPreferences on main-thread.
- [Added] Auto-linking support for
react-native >= 0.60
. See the Auto-linking setup in the README for more information.
react-native-background-fetch < 2.7.0
installed into react-native >= 0.60
, you should first unlink
your previous version as react-native link
is no longer required.
$ react-native unlink react-native-background-fetch
- [Added] New
react-native.config.js
wanted byreact-native > 0.60.0
. https://github.com/react-native-community/cli/blob/master/docs/dependencies.md
- [Added] Added extra Android
JobInfo
constraintsrequiredNetworkType
,requiresCharing
,requiresBatteryNotLow
,requiresStorageNotLow
,requiresDeviceIdle
. - [Fixed] Merge PR transistor-background-fetch
- [Fixed] Merge PR transistor-background-fetch
- [Fixed] Monkey patch xcode npm module to ignore case in
findPBXGroupKeyAndType
. Some projects physical folder name might be "foo" but the XCode group-name might be "Foo".
- [Fixed] react-native link script failed for Expo apps. Failed to find projectGroup by name. Finds it by path or name now.
- [Fixed] Windows issue in new react-native link script for Android
- [Added] Added android implementation for
react-native link
script to automatically add the requiredmaven url
. No more extras steps required — simply:react-native link react-native-background-fetch
.
- [Fixed] Fixed
react-native link
scripts to detect when installing into an app already configured for Cocoapods.
- [Changed] Remove unnecessary gradle directive
buildToolsVersion
.
- [Changed] Use updated gradle method
implementation
instead of deprecatedcompile
.
- [Added] Android: Double check that app isn't in foreground before executing headless task (thanks to @macgregorT).
- [Fixed] Wrap Android HeadlessTask executor in try/catch to swallow errors if run while app is in foreground.
- [Fixed] react-native link scripts for Windows (PR #114)
- [Added] Typescript definitions.
- [Fixed] Fix link error when iOS and npm project name are diferent
- [Fixed] Clear event-listeners when
#configure
is called. When used withreact-native-background-geolocation
in "Headless Mode", this plugin could accumulate event-listeners with each reboot after terminate. - [Added] Add convenience method
BackgroundGeolocation#registerHeadlessTask
, to be used instead ofAppRegistry#registerHeadlessTask
.
- [Added] Implement ability to provide
UIBackgroundFetchResult
to#finish
rather than hard-codedUIBackgroundFetchResultNewData
- [Fixed] react-native link was broken for iOS due to unused aggregate target. Remove unused targets.
- [Changed] The Android library
tsbackgroundfetch.aar
has be composed as a Maven repository. The installation procedure has changed slightly now andflatDirs
has been replaced with amaven url
. See the corresponding installation docs for more information. - [Changed] Android will check for application-wide configuration properties
buildSdkVersion
,buildToolsVersion
,targetSdkVersion
. See the Wiki "Solving Android Gradle Conflicts" for more information.
- [Added] Android implementation using
JobScheduler
/AlarmManager