-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feature: Background updates on mobile #5953
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,8 @@ | |
| 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; | ||
| 8821A238A081483FA947BC4E /* GTAmericaExp-RgIt.otf in Resources */ = {isa = PBXBuildFile; fileRef = 918D7FEFF96242E6B5F5E14D /* GTAmericaExp-RgIt.otf */; }; | ||
| DB77016704074197AB6633BB /* GTAmericaExpMono-RgIt.otf in Resources */ = {isa = PBXBuildFile; fileRef = 5150E5D0D7F74DBA8D7C1914 /* GTAmericaExpMono-RgIt.otf */; }; | ||
| E8B0732B26EA56E8009FC59C /* RNBackgroundFetch+AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B0732A26EA56E8009FC59C /* RNBackgroundFetch+AppDelegate.m */; }; | ||
| E8B0732C26EA56E8009FC59C /* RNBackgroundFetch+AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B0732A26EA56E8009FC59C /* RNBackgroundFetch+AppDelegate.m */; }; | ||
| E9DF872D2525201700607FDC /* AirshipConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = E9DF872C2525201700607FDC /* AirshipConfig.plist */; }; | ||
| ED814D34526B415CAFA0451E /* GTAmericaExpMono-BdIt.otf in Resources */ = {isa = PBXBuildFile; fileRef = 3981452A2C7340EBBA2B9BD1 /* GTAmericaExpMono-BdIt.otf */; }; | ||
| F2C9290F276DB05EEF04D160 /* libPods-NewExpensify-NewExpensifyTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 820334EEB8DDED5217A15684 /* libPods-NewExpensify-NewExpensifyTests.a */; }; | ||
|
|
@@ -82,6 +84,7 @@ | |
| D314A6D536D2ADA797DCDAC9 /* Pods-NewExpensify-NewExpensifyTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.debug.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.debug.xcconfig"; sourceTree = "<group>"; }; | ||
| D3D8FA6E27ED5DD98F515230 /* Pods-NewExpensify.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.debug.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.debug.xcconfig"; sourceTree = "<group>"; }; | ||
| DB5A1365442D4419AF6F08E5 /* GTAmericaExp-MdIt.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "GTAmericaExp-MdIt.otf"; path = "../assets/fonts/GTAmericaExp-MdIt.otf"; sourceTree = "<group>"; }; | ||
| E8B0732A26EA56E8009FC59C /* RNBackgroundFetch+AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "RNBackgroundFetch+AppDelegate.m"; path = "../node_modules/react-native-background-fetch/ios/RNBackgroundFetch/RNBackgroundFetch+AppDelegate.m"; sourceTree = "<group>"; }; | ||
| E9DF872C2525201700607FDC /* AirshipConfig.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = AirshipConfig.plist; sourceTree = "<group>"; }; | ||
| EB3C4841B1DB1490EA09A324 /* Pods-NewExpensify.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.release.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.release.xcconfig"; sourceTree = "<group>"; }; | ||
| ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; | ||
|
|
@@ -128,6 +131,7 @@ | |
| 13B07FAE1A68108700A75B9A /* NewExpensify */ = { | ||
| isa = PBXGroup; | ||
| children = ( | ||
| E8B0732A26EA56E8009FC59C /* RNBackgroundFetch+AppDelegate.m */, | ||
| 0F5BE0CD252686320097D869 /* GoogleService-Info.plist */, | ||
| E9DF872C2525201700607FDC /* AirshipConfig.plist */, | ||
| 008F07F21AC5B25A0029DE68 /* main.jsbundle */, | ||
|
|
@@ -282,9 +286,9 @@ | |
| TestTargetID = 13B07F861A680F5B00A75B9A; | ||
| }; | ||
| 13B07F861A680F5B00A75B9A = { | ||
| DevelopmentTeam = 368M544MTT; | ||
| DevelopmentTeam = 72TRNPHV7D; | ||
| LastSwiftMigration = 1230; | ||
| ProvisioningStyle = Manual; | ||
| ProvisioningStyle = Automatic; | ||
|
Comment on lines
-285
to
+291
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be reverted |
||
| }; | ||
| }; | ||
| }; | ||
|
|
@@ -760,6 +764,7 @@ | |
| 00E356F31AD99517003FC87E /* ExpensifyCashTests.m in Sources */, | ||
| 0F5E5351263B73FD004CA14F /* EnvironmentChecker.m in Sources */, | ||
| 7041848626A8E47D00E09F4D /* RCTStartupTimer.m in Sources */, | ||
| E8B0732C26EA56E8009FC59C /* RNBackgroundFetch+AppDelegate.m in Sources */, | ||
| ); | ||
| runOnlyForDeploymentPostprocessing = 0; | ||
| }; | ||
|
|
@@ -770,6 +775,7 @@ | |
| 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, | ||
| 18D050E0262400AF000D658B /* BridgingFile.swift in Sources */, | ||
| 0F5E5350263B73FD004CA14F /* EnvironmentChecker.m in Sources */, | ||
| E8B0732B26EA56E8009FC59C /* RNBackgroundFetch+AppDelegate.m in Sources */, | ||
| 7041848526A8E47D00E09F4D /* RCTStartupTimer.m in Sources */, | ||
| 13B07FC11A68108700A75B9A /* main.m in Sources */, | ||
| ); | ||
|
|
@@ -841,10 +847,10 @@ | |
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| CLANG_ENABLE_MODULES = YES; | ||
| CODE_SIGN_ENTITLEMENTS = NewExpensify/Chat.entitlements; | ||
| CODE_SIGN_IDENTITY = "iPhone Distribution"; | ||
| CODE_SIGN_STYLE = Manual; | ||
| CODE_SIGN_IDENTITY = "Apple Development"; | ||
| CODE_SIGN_STYLE = Automatic; | ||
| CURRENT_PROJECT_VERSION = 3; | ||
| DEVELOPMENT_TEAM = 368M544MTT; | ||
| DEVELOPMENT_TEAM = 72TRNPHV7D; | ||
|
Comment on lines
-844
to
+853
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should definitely be reverted |
||
| ENABLE_BITCODE = NO; | ||
| "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; | ||
| INFOPLIST_FILE = "$(SRCROOT)/NewExpensify/Info.plist"; | ||
|
|
@@ -858,7 +864,7 @@ | |
| ); | ||
| PRODUCT_BUNDLE_IDENTIFIER = com.chat.expensify.chat; | ||
| PRODUCT_NAME = "New Expensify"; | ||
| PROVISIONING_PROFILE_SPECIFIER = chat_expensify_appstore; | ||
| PROVISIONING_PROFILE_SPECIFIER = ""; | ||
|
Comment on lines
-861
to
+867
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should definitely be reverted |
||
| SWIFT_OBJC_BRIDGING_HEADER = "ExpensifyCash-Bridging-Header.h"; | ||
| SWIFT_OPTIMIZATION_LEVEL = "-Onone"; | ||
| SWIFT_VERSION = 5.0; | ||
|
|
@@ -874,10 +880,10 @@ | |
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| CLANG_ENABLE_MODULES = YES; | ||
| CODE_SIGN_ENTITLEMENTS = NewExpensify/Chat.entitlements; | ||
| CODE_SIGN_IDENTITY = "iPhone Distribution"; | ||
| CODE_SIGN_STYLE = Manual; | ||
| CODE_SIGN_IDENTITY = "Apple Development"; | ||
| CODE_SIGN_STYLE = Automatic; | ||
| CURRENT_PROJECT_VERSION = 3; | ||
| DEVELOPMENT_TEAM = 368M544MTT; | ||
| DEVELOPMENT_TEAM = 72TRNPHV7D; | ||
|
Comment on lines
-877
to
+886
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should definitely be reverted |
||
| "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64; | ||
| INFOPLIST_FILE = NewExpensify/Info.plist; | ||
| IPHONEOS_DEPLOYMENT_TARGET = 11.0; | ||
|
|
@@ -890,7 +896,7 @@ | |
| ); | ||
| PRODUCT_BUNDLE_IDENTIFIER = com.chat.expensify.chat; | ||
| PRODUCT_NAME = "New Expensify"; | ||
| PROVISIONING_PROFILE_SPECIFIER = chat_expensify_appstore; | ||
| PROVISIONING_PROFILE_SPECIFIER = ""; | ||
|
Comment on lines
-893
to
+899
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should definitely be reverted |
||
| SWIFT_OBJC_BRIDGING_HEADER = "ExpensifyCash-Bridging-Header.h"; | ||
| SWIFT_VERSION = 5.0; | ||
| TARGETED_DEVICE_FAMILY = "1,2"; | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import BackgroundFetch from 'react-native-background-fetch'; | ||
|
|
||
| /** | ||
| * Initialize task to run background fetch | ||
| */ | ||
| export default async function initializeBackgroundFetch() { // eslint-disable-line | ||
| // Setup task config | ||
| const config = { | ||
| minimumFetchInterval: 15, // <-- minutes (15 is minimum allowed) | ||
| // Android options | ||
| stopOnTerminate: false, | ||
| startOnBoot: true, | ||
| requiredNetworkType: BackgroundFetch.NETWORK_TYPE_ANY, // Default | ||
| requiresCharging: false, // Default | ||
| requiresDeviceIdle: false, // Default | ||
| requiresBatteryNotLow: false, // Default | ||
| requiresStorageNotLow: false, // Default | ||
| enableHeadless: true, | ||
| }; | ||
|
|
||
| // Setup BackgroundFetch task | ||
| const onEvent = async (taskId) => { // eslint-disable-line | ||
| console.log('[BackgroundFetch] task: ', taskId); | ||
| console.log('Fetching Data via BG'); | ||
|
|
||
| // TODO: retrieve network data, persist to Onyx | ||
| const response = await fetch('http://5361-103-93-193-198.ngrok.io/'); | ||
| console.log('Hitting API ', response); | ||
|
|
||
| const responseJson = await response.json(); | ||
| console.log('Fetching Data via BG'); | ||
| console.log('[BackgroundFetch] response', responseJson); | ||
|
|
||
| // Signal to OS that task is complete. | ||
| BackgroundFetch.finish(taskId); | ||
| }; | ||
|
|
||
| // Invoked when task exceeds its allowed running-time | ||
| const onTimeout = async (taskId) => { // eslint-disable-line | ||
| console.warn('[BackgroundFetch] TIMEOUT task: ', taskId); | ||
| BackgroundFetch.finish(taskId); | ||
| }; | ||
|
|
||
| // Initialize BackgroundFetch only once when component mounts. | ||
| const status = await BackgroundFetch.configure(config, onEvent, onTimeout); | ||
| console.log('[BackgroundFetch] configure status: ', status); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The task should not be defined here in
index.jsIt should be defined in
libsand then registered duringsetupor inExpensify.jsdidMountphaseI see this is already done, and there's a lib about this, so the code here seems like a leftover that should be removed