feat(Android): setup background task#54616
Conversation
756438d to
33d2010
Compare
|
🚧 @mountiny has triggered a test build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
modules/background-task/expensify-react-native-background-task.podspec
Outdated
Show resolved
Hide resolved
99250b5 to
f3c9360
Compare
|
@szymonrybczak Can you fix the lint? |
|
🚧 @Beamanator has triggered a test build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
bdd2b44 to
2e8d5ba
Compare
|
@szymonrybczak can you please merge i'll try building again on my local, adhoc android build is still crashing for me |
2e8d5ba to
c863526
Compare
|
@ishpaul777 done ✅ let me know what are the results when you run app locally 🙏 |
luacmartins
left a comment
There was a problem hiding this comment.
Nice work so far. We just got the iOS PR merged, let's try to get this one merged soon too.
|
@szymonrybczak Local build is not crashing, but background task is not starting at all. Even if I force it. |
f441aa0 to
7472c60
Compare
Reviewer Checklist
Screenshots/VideosScreen.Recording.2025-01-17.at.2.39.44.PM.mov |
|
@szymonrybczak Can you fix your PR description? |
|
@ishpaul777 @shubham1206agra please keep in mind that it is c+ responsibility to make sure native changes and any podfile changes are also reflected in hybrid app when the contributor does not have access - we had to add the pod changes in this PR https://github.com/Expensify/Mobile-Expensify/pull/13365/files just for your interest. Please check if there is anything more to add from this PR too |
|
@mountiny, I did not reviewed the iOS PR for this feature. @mananjadhav reviewed that PR. |
|
@szymonrybczak Can you check if you need to do some config in HybridApp? |
@mountiny Can confirm it is working on HybridApp on latest main |
|
@shubham1206agra SWM has updated the Podfile for the ios part - just noting that if you need to make more changes here, dont forget about it. @szymonrybczak I believe you should have access to HybridApp now too |
|
@luacmartins looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
Failing action was just a GH comment. Not an emergency |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.0.88-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.0.88-7 🚀
|
| override fun onReceive(context: Context?, intent: Intent?) { | ||
| val taskName = intent?.getStringExtra("taskName") | ||
| Log.d("ReactNativeBackgroundTaskModule", "Received task: $taskName") | ||
| emitOnBackgroundTaskExecution(taskName) |

Explanation of Change
Warning
This Pull Request is rebased on top of the Upgrade to React Native 0.76 Pull Request because it's using a new type-safe way of creating EventEmitters available only in 0.76, and relevant PR for iOS because it shares the same JS specs
Adds an implementation of background task on Android. This implemenation leverages JobScheduler API for scheduling tasks.
From the more technical perspective it's a C++ TurboModule that was bootstrapped as a Local Library so it's linked inside
package.json.For now, we're scheduling new tasks in 15-minute intervals after the execution of the previous one.
How to test it?
You can view scheduled background task when running
adb shell dumpsys jobscheduler:To force execution of the background task can execute following command on attached device:
specified id is a hash code of the
FLUSH-SEQUENTIAL-QUEUE-BACKGROUND-FETCHstring.Here's a video presenting this behaviour:
CleanShot.2024-12-27.at.12.38.54.mp4
Fixed Issues
$ #50140
PROPOSAL: #50140
Tests
Offline tests
QA Steps
Note: take into account that could some time for the first time, this times will be improved and vary depending on the app usage on the device. We set the interval between tasks to 15 minutes but at the end of the day Android decides when to execute it.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop