Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tasks for new user first workspace #55017

Closed
wants to merge 102 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
ba863a3
add tasks for new user first workspace
ishpaul777 Jan 9, 2025
32dc809
prettier
ishpaul777 Jan 9, 2025
bb1374b
Merge branch 'Expensify:main' into onboarding-tasks-workspace
ishpaul777 Jan 10, 2025
ace0d1e
replace meetSetupSpecialist task with meetGuideTask and fix guidedSet…
ishpaul777 Jan 10, 2025
3225931
Merge branch 'Expensify:main' into onboarding-tasks-workspace
ishpaul777 Jan 10, 2025
431e606
Merge branch 'main' into onboarding-tasks-workspace
ishpaul777 Jan 14, 2025
5dddf45
Merge branch 'Expensify:main' into onboarding-tasks-workspace
ishpaul777 Jan 14, 2025
46eaa10
fix upgrade workspace case
ishpaul777 Jan 14, 2025
6926f45
feat: Update the invitation process to include the role
truph01 Jan 14, 2025
d0b1cc1
fix: add marginBottom 24px to role
truph01 Jan 14, 2025
1a414b0
fix: type
truph01 Jan 14, 2025
a253588
fix: update margin bottom role to mb3
truph01 Jan 14, 2025
bcadec3
fix: lint
truph01 Jan 14, 2025
062b01d
fix: remove trans inviteMessageTitle
truph01 Jan 14, 2025
d93f793
Update version to 9.0.85-4
OSBotify Jan 14, 2025
a8d37ad
Update Mobile-Expensify to 9.0.85-4
OSBotify Jan 14, 2025
955ca13
reset transaction on page refresh for IOU distance page
FitseTLT Dec 23, 2024
eff3e36
lint fix
FitseTLT Jan 14, 2025
881dcd2
Update CONST.ts
jamesdeanexpensify Jan 14, 2025
0640a91
Add TRIP_SUPPORT constant and update link in TripDetailsPage
blazejkustra Jan 8, 2025
122ffba
fix: first item is highlighted in contact list and confirmation page
daledah Jan 13, 2025
20f00fd
feat: init local library
szymonrybczak Nov 20, 2024
483f55c
feat: add `defineTask` method
szymonrybczak Nov 20, 2024
2e5d8a9
feat: use BGTaskScheduler api
szymonrybczak Nov 20, 2024
18d01f6
fix: remove useless condition
szymonrybczak Nov 26, 2024
cdb7ec0
feat: properly register & add basic handler
szymonrybczak Nov 27, 2024
5f6ea86
feat: execute js function from native
szymonrybczak Nov 27, 2024
852bf92
chore: clean up usage on JS side
szymonrybczak Nov 27, 2024
ac0336b
fix: replace `BGProcessingTaskRequest` with `BGProcessingTaskRequest`
szymonrybczak Nov 27, 2024
6163ab6
chore: small code cleaning
szymonrybczak Dec 3, 2024
71e46b7
fix: remove android related stuff for now
szymonrybczak Dec 4, 2024
c96a025
fix: replace hardcoded identifier
szymonrybczak Dec 9, 2024
2b6cdbb
chore: code cleanup
szymonrybczak Dec 9, 2024
295136b
chore: one line impl in `AppDelegate.mm`
szymonrybczak Dec 9, 2024
7110449
chore: remove header comments
szymonrybczak Dec 9, 2024
0a477c1
feat: implement sequential task scheduling
szymonrybczak Dec 9, 2024
45f8a4d
chore: remove useless observer
szymonrybczak Dec 9, 2024
c6e365c
fix: properly order packages in `package.json`
szymonrybczak Dec 10, 2024
2692235
feat!: use new EventEmitter API
szymonrybczak Dec 10, 2024
3459183
fix: make 0 warnings
szymonrybczak Dec 10, 2024
3959933
fix: add proper bundle id
szymonrybczak Dec 10, 2024
2b54acd
fix: add release bundle id
szymonrybczak Dec 10, 2024
4b08896
fix: include all bundle identifiers
szymonrybczak Dec 11, 2024
e639f40
fix: replace `BGProcessingTaskRequest` with `BGAppRefreshTaskRequest`
szymonrybczak Dec 17, 2024
ca79968
fix: call `resolve()` only once when there's multiple identifiers
szymonrybczak Dec 17, 2024
5af0e0b
fix: use bg task specific id
szymonrybczak Dec 20, 2024
70165bc
fix: remove oudated condition in `Podfile`
szymonrybczak Dec 30, 2024
795ad3d
chore: update lock
szymonrybczak Jan 7, 2025
9e023fc
fix: eslint warnings
szymonrybczak Jan 7, 2025
39eed38
fix: mock module
szymonrybczak Jan 8, 2025
3bd5984
feat: add a log when executing background task
szymonrybczak Jan 8, 2025
367f95c
fix: move mocks to one file
szymonrybczak Jan 13, 2025
be655b9
feat: pass error to JS
szymonrybczak Jan 13, 2025
93d215d
fix: eslint error
szymonrybczak Jan 14, 2025
fdad6af
Remove custom report welcome message pressable functionality
ikevin127 Jan 13, 2025
cbc2f46
fixed eslint no-restricted-syntax
ikevin127 Jan 14, 2025
b472975
renamed imported methods according to naming convention
ikevin127 Jan 14, 2025
d6b1e7b
applied changes for #rooms and invoice rooms
ikevin127 Jan 14, 2025
a62763c
don't unpause focus trap when deactivated
bernhardoj Dec 27, 2024
05b6cec
don't unpause focus trap when deactivated
bernhardoj Dec 27, 2024
4757a15
fix flushing
perunt Jan 9, 2025
ad313fa
fix: App does not trigger required field validation when no state is …
truph01 Jan 14, 2025
f82383e
fix: remove redundant comment
truph01 Jan 14, 2025
ea713cb
Update version to 9.0.86-0
OSBotify Jan 15, 2025
fc3f816
Update Mobile-Expensify to 9.0.86-0
OSBotify Jan 15, 2025
e373500
pass the personal details
bernhardoj Jan 11, 2025
476bb9c
add test
bernhardoj Jan 13, 2025
752b327
use translate key
bernhardoj Jan 13, 2025
49923e2
lint
bernhardoj Jan 13, 2025
7cdc6cc
add unit test for getSubmitToAccountID and getApprovalChain
nkdengineer Jan 10, 2025
125de4a
use async
nkdengineer Jan 13, 2025
1cb66df
fix lint
nkdengineer Jan 13, 2025
f08a3a1
fix lint error
nkdengineer Jan 14, 2025
b01b26f
Update tests/unit/PolicyUtilsTest.ts
nkdengineer Jan 15, 2025
dd7c3b7
Update tests/unit/ReportUtilsTest.ts
nkdengineer Jan 15, 2025
3b3c95d
refactor test
nkdengineer Jan 15, 2025
5b3efaa
rename test
nkdengineer Jan 15, 2025
1042d50
update policy type
nkdengineer Jan 15, 2025
d4726fe
use fetch instead of simply window.location
NikkiWines Nov 16, 2024
86a0b13
update to use withOnyx, updated props
NikkiWines Nov 16, 2024
1357cde
minor style
NikkiWines Nov 21, 2024
5552aa9
introduce post for SAML native
NikkiWines Nov 21, 2024
67dc592
style
NikkiWines Nov 21, 2024
4f14c04
dry up saml url logic
NikkiWines Nov 22, 2024
987f466
style
NikkiWines Nov 22, 2024
3c8ab4b
update SAML native logic to handle errors
NikkiWines Nov 28, 2024
afc6432
fix error handling for signing in with short lived authtoken
NikkiWines Nov 28, 2024
6b6cf09
minor style
NikkiWines Nov 28, 2024
b3a7320
return early with clean session if no login
NikkiWines Nov 29, 2024
d14631c
prettier
NikkiWines Nov 29, 2024
707fd77
add copy
NikkiWines Nov 30, 2024
bcc43cf
add handleError function
NikkiWines Nov 30, 2024
42f7842
style
NikkiWines Nov 30, 2024
a7df60c
linting changes
NikkiWines Dec 2, 2024
912cc70
error handling
NikkiWines Dec 2, 2024
f05e8a6
remove unneeded url clean
NikkiWines Dec 11, 2024
f246529
dry handle error functionality and rename function
NikkiWines Dec 19, 2024
9158723
remove noop
NikkiWines Dec 20, 2024
d23ad26
fix imports
NikkiWines Dec 20, 2024
ac3825d
add back navigation import
NikkiWines Dec 20, 2024
bc15302
fix import and show loading screen
NikkiWines Dec 21, 2024
fc0f89f
fix double negation
NikkiWines Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Mobile-Expensify
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1009008503
versionName "9.0.85-3"
versionCode 1009008600
versionName "9.0.86-0"
// Supported language variants must be declared here to avoid from being removed during the compilation.
// This also helps us to not include unnecessary language variants in the APK.
resConfigs "en", "es"
Expand Down
4 changes: 4 additions & 0 deletions ios/NewExpensify.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
7FD73CA22B23CE9500420AF3 /* NotificationServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 7FD73C9B2B23CE9500420AF3 /* NotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
8744C5400E24E379441C04A4 /* libPods-NewExpensify.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 59A21B2405370FDDD847C813 /* libPods-NewExpensify.a */; };
9E17CB36A6B22BDD4BE53561 /* libPods-NotificationServiceExtension.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9196A72C11B91A52A43D6E8A /* libPods-NotificationServiceExtension.a */; };
AC131FBB2CF634F20010CE80 /* BackgroundTasks.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AC131FBA2CF634F20010CE80 /* BackgroundTasks.framework */; };
ACA597C323AA39404655647F /* libPods-NewExpensify-NewExpensifyTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EF33B19FC6A7FE676839430D /* libPods-NewExpensify-NewExpensifyTests.a */; };
BDB853621F354EBB84E619C2 /* ExpensifyNewKansas-MediumItalic.otf in Resources */ = {isa = PBXBuildFile; fileRef = D2AFB39EC1D44BF9B91D3227 /* ExpensifyNewKansas-MediumItalic.otf */; };
D27CE6B77196EF3EF450EEAC /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 0D3F9E814828D91464DF9D35 /* PrivacyInfo.xcprivacy */; };
Expand Down Expand Up @@ -141,6 +142,7 @@
8B28D84EF339436DBD42A203 /* ExpensifyNeue-BoldItalic.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ExpensifyNeue-BoldItalic.otf"; path = "../assets/fonts/native/ExpensifyNeue-BoldItalic.otf"; sourceTree = "<group>"; };
8EFE0319D586C1078DB926FD /* Pods-NewExpensify.releaseadhoc.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.releaseadhoc.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.releaseadhoc.xcconfig"; sourceTree = "<group>"; };
9196A72C11B91A52A43D6E8A /* libPods-NotificationServiceExtension.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NotificationServiceExtension.a"; sourceTree = BUILT_PRODUCTS_DIR; };
AC131FBA2CF634F20010CE80 /* BackgroundTasks.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = BackgroundTasks.framework; path = System/Library/Frameworks/BackgroundTasks.framework; sourceTree = SDKROOT; };
BBE493797E97F2995E627244 /* Pods-NotificationServiceExtension.debugadhoc.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationServiceExtension.debugadhoc.xcconfig"; path = "Target Support Files/Pods-NotificationServiceExtension/Pods-NotificationServiceExtension.debugadhoc.xcconfig"; sourceTree = "<group>"; };
BCD444BEDDB0AF1745B39049 /* ExpoModulesProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpoModulesProvider.swift; path = "Pods/Target Support Files/Pods-NewExpensify-NewExpensifyTests/ExpoModulesProvider.swift"; sourceTree = "<group>"; };
BF6A4C5167244B9FB8E4D4E3 /* ExpensifyNeue-Italic.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ExpensifyNeue-Italic.otf"; path = "../assets/fonts/native/ExpensifyNeue-Italic.otf"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -180,6 +182,7 @@
383643682B6D4AE2005BB9AE /* DeviceCheck.framework in Frameworks */,
E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */,
E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */,
AC131FBB2CF634F20010CE80 /* BackgroundTasks.framework in Frameworks */,
8744C5400E24E379441C04A4 /* libPods-NewExpensify.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -239,6 +242,7 @@
2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
isa = PBXGroup;
children = (
AC131FBA2CF634F20010CE80 /* BackgroundTasks.framework */,
383643672B6D4AE2005BB9AE /* DeviceCheck.framework */,
ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
ED2971642150620600B7C4FE /* JavaScriptCore.framework */,
Expand Down
4 changes: 4 additions & 0 deletions ios/NewExpensify/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#import "RCTBootSplash.h"
#import "RCTStartupTimer.h"
#import <HardwareShortcuts.h>
#import <BackgroundTasks/BackgroundTasks.h>
#import <expensify-react-native-background-task/RNBackgroundTaskManager.h>

@interface AppDelegate () <UNUserNotificationCenterDelegate>

Expand Down Expand Up @@ -49,6 +51,8 @@ - (BOOL)application:(UIApplication *)application
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"isFirstRunComplete"];
}

[RNBackgroundTaskManager setup];

return YES;
}
Expand Down
10 changes: 8 additions & 2 deletions ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.chat.expensify.backgroundTaskSync</string>
</array>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
Expand All @@ -19,7 +23,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>9.0.85</string>
<string>9.0.86</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -40,7 +44,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>9.0.85.3</string>
<string>9.0.86.0</string>
<key>FullStory</key>
<dict>
<key>OrgId</key>
Expand Down Expand Up @@ -97,6 +101,8 @@
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
<string>fetch</string>
<string>processing</string>
</array>
<key>UIFileSharingEnabled</key>
<true/>
Expand Down
4 changes: 2 additions & 2 deletions ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>9.0.85</string>
<string>9.0.86</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>9.0.85.3</string>
<string>9.0.86.0</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions ios/NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleShortVersionString</key>
<string>9.0.85</string>
<string>9.0.86</string>
<key>CFBundleVersion</key>
<string>9.0.85.3</string>
<string>9.0.86.0</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
25 changes: 25 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ PODS:
- EXImageLoader (5.0.0):
- ExpoModulesCore
- React-Core
- expensify-react-native-background-task (0.0.0):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- Expo (52.0.14):
- ExpoModulesCore
- ExpoAsset (11.0.1):
Expand Down Expand Up @@ -2813,6 +2834,7 @@ DEPENDENCIES:
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- EXAV (from `../node_modules/expo-av/ios`)
- EXImageLoader (from `../node_modules/expo-image-loader/ios`)
- "expensify-react-native-background-task (from `../node_modules/@expensify/react-native-background-task`)"
- Expo (from `../node_modules/expo`)
- ExpoAsset (from `../node_modules/expo-asset/ios`)
- ExpoFont (from `../node_modules/expo-font/ios`)
Expand Down Expand Up @@ -2982,6 +3004,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/expo-av/ios"
EXImageLoader:
:path: "../node_modules/expo-image-loader/ios"
expensify-react-native-background-task:
:path: "../node_modules/@expensify/react-native-background-task"
Expo:
:path: "../node_modules/expo"
ExpoAsset:
Expand Down Expand Up @@ -3228,6 +3252,7 @@ SPEC CHECKSUMS:
DoubleConversion: f16ae600a246532c4020132d54af21d0ddb2a385
EXAV: 9773c9799767c9925547b05e41a26a0240bb8ef2
EXImageLoader: 759063a65ab016b836f73972d3bb25404888713d
expensify-react-native-background-task: 6f797cf470b627912c246514b1631a205794775d
Expo: 0e7b52be71a24a38d5e919e3040d8f51a8739cd0
ExpoAsset: 8138f2a9ec55ae1ad7c3871448379f7d97692d15
ExpoFont: 7522d869d84ee2ee8093ee997fef5b86f85d856b
Expand Down
12 changes: 12 additions & 0 deletions ios/tmp.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
NEW_EXPENSIFY_URL=https:/$()/new.expensify.com/
SECURE_EXPENSIFY_URL=https:/$()/secure.expensify.com/
EXPENSIFY_URL=https:/$()/www.expensify.com/
EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
PUSHER_APP_KEY=268df511a204fbb60884
USE_WEB_PROXY=false
ENVIRONMENT=production
SEND_CRASH_REPORTS=true
FB_API_KEY=AIzaSyBrLKgCuo6Vem6Xi5RPokdumssW8HaWBow
FB_APP_ID=1:1008697809946:web:08de4ecb7656b7235445a3
FB_PROJECT_ID=expensify-mobile-app
5 changes: 5 additions & 0 deletions jest/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ jest.mock('@src/libs/actions/Timing', () => ({
end: jest.fn(),
}));

jest.mock('../modules/background-task/src/NativeReactNativeBackgroundTask', () => ({
defineTask: jest.fn(),
onBackgroundTaskExecution: jest.fn(),
}));

// This makes FlatList render synchronously for easier testing.
jest.mock(
'@react-native/virtualized-lists/Interaction/Batchinator',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'

Pod::Spec.new do |s|
s.name = "expensify-react-native-background-task"
s.version = package["version"]
s.summary = package["description"]
s.homepage = package["homepage"]
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => ".git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm,cpp}"

install_modules_dependencies(s)
end
15 changes: 15 additions & 0 deletions modules/background-task/ios/RNBackgroundTaskManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#import <Foundation/Foundation.h>
#import <BackgroundTasks/BackgroundTasks.h>
#import <React/RCTBridgeModule.h>

@interface RNBackgroundTaskManager : NSObject

@property (nonatomic, copy) void (^ _Nullable taskHandler)(BGTask * _Nonnull);

+ (instancetype _Nullable )shared;
+ (void)setup;
- (void)setHandlerForIdentifier:(NSString *_Nullable)identifier
completion:(void (^_Nullable)(BGTask * _Nonnull))handler;
- (void (^_Nullable)(BGTask * _Nonnull))handlerForIdentifier:(NSString *_Nullable)identifier;

@end
52 changes: 52 additions & 0 deletions modules/background-task/ios/RNBackgroundTaskManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#import <BackgroundTasks/BackgroundTasks.h>

@implementation RNBackgroundTaskManager : NSObject {
NSMutableDictionary<NSString *, void (^)(BGTask * _Nonnull)> *_handlers;
}

+ (instancetype)shared {
static RNBackgroundTaskManager *instance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[RNBackgroundTaskManager alloc] init];
});
return instance;
}

- (instancetype)init {
if (self = [super init]) {
_handlers = [NSMutableDictionary new];
}
return self;
}

- (void)setHandlerForIdentifier:(NSString *)identifier
completion:(void (^)(BGTask * _Nonnull))handler {
_handlers[identifier] = handler;
}

- (void (^)(BGTask * _Nonnull))handlerForIdentifier:(NSString *)identifier {
return _handlers[identifier];
}

+ (void)setup {
NSArray *backgroundIdentifiers = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"BGTaskSchedulerPermittedIdentifiers"];

if (!backgroundIdentifiers || ![backgroundIdentifiers isKindOfClass:[NSArray class]]) {
NSLog(@"[ReactNativeBackgroundTask] No background identifiers found or invalid format");
} else {
for (NSString *identifier in backgroundIdentifiers) {
[[BGTaskScheduler sharedScheduler] registerForTaskWithIdentifier:identifier
usingQueue:nil
launchHandler:^(BGTask * _Nonnull task) {
NSLog(@"[ReactNativeBackgroundTask] Executing background task: %@", task.identifier);
void (^handler)(BGTask * _Nonnull) = [[RNBackgroundTaskManager shared] handlerForIdentifier:task.identifier];
if (handler) {
handler(task);
}
}];
}
}
}

@end
18 changes: 18 additions & 0 deletions modules/background-task/ios/ReactNativeBackgroundTask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifdef RCT_NEW_ARCH_ENABLED
#import "RNReactNativeBackgroundTaskSpec.h"
#import <BackgroundTasks/BackgroundTasks.h>

@interface ReactNativeBackgroundTask : NativeReactNativeBackgroundTaskSpecBase <NativeReactNativeBackgroundTaskSpec>
#else
#import <React/RCTBridgeModule.h>
#import <BackgroundTasks/BackgroundTasks.h>

@interface ReactNativeBackgroundTask : NSObject <RCTBridgeModule>
#endif

- (void)defineTask:(NSString *)taskName
taskExecutor:(RCTResponseSenderBlock)taskExecutor
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;

@end
Loading
Loading