feat: 集成expo-background-task和expo-task-manager,重构后台任务管理,添加健康提醒功能,优化任务执行逻辑

This commit is contained in:
2025-09-05 22:07:29 +08:00
parent 3c416545db
commit e6708e68c2
7 changed files with 225 additions and 200 deletions

View File

@@ -40,6 +40,8 @@ PODS:
- ExpoModulesCore
- ExpoAsset (11.1.7):
- ExpoModulesCore
- ExpoBackgroundTask (0.2.8):
- ExpoModulesCore
- ExpoBlur (14.1.5):
- ExpoModulesCore
- ExpoCamera (16.1.11):
@@ -102,6 +104,9 @@ PODS:
- ExpoModulesCore
- ExpoWebBrowser (14.2.0):
- ExpoModulesCore
- EXTaskManager (13.1.6):
- ExpoModulesCore
- UMAppLoader
- fast_float (6.1.4)
- FBLazyVector (0.79.5)
- fmt (11.0.2)
@@ -1741,8 +1746,6 @@ PODS:
- RevenueCat (5.34.0)
- RNAppleHealthKit (1.7.0):
- React
- RNBackgroundFetch (4.2.8):
- React-Core
- RNCAsyncStorage (2.2.0):
- React-Core
- RNCMaskedView (0.3.2):
@@ -1984,6 +1987,7 @@ PODS:
- SDWebImage/Core (~> 5.17)
- Sentry/HybridSDK (8.53.2)
- SocketRocket (0.7.1)
- UMAppLoader (5.1.3)
- Yoga (0.0.0)
- ZXingObjC/Core (3.6.9)
- ZXingObjC/OneD (3.6.9):
@@ -2001,6 +2005,7 @@ DEPENDENCIES:
- Expo (from `../node_modules/expo`)
- ExpoAppleAuthentication (from `../node_modules/expo-apple-authentication/ios`)
- ExpoAsset (from `../node_modules/expo-asset/ios`)
- ExpoBackgroundTask (from `../node_modules/expo-background-task/ios`)
- ExpoBlur (from `../node_modules/expo-blur/ios`)
- ExpoCamera (from `../node_modules/expo-camera/ios`)
- ExpoFileSystem (from `../node_modules/expo-file-system/ios`)
@@ -2018,6 +2023,7 @@ DEPENDENCIES:
- ExpoSymbols (from `../node_modules/expo-symbols/ios`)
- ExpoSystemUI (from `../node_modules/expo-system-ui/ios`)
- ExpoWebBrowser (from `../node_modules/expo-web-browser/ios`)
- EXTaskManager (from `../node_modules/expo-task-manager/ios`)
- fast_float (from `../node_modules/react-native/third-party-podspecs/fast_float.podspec`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`)
@@ -2091,7 +2097,6 @@ DEPENDENCIES:
- ReactCodegen (from `build/generated/ios`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- RNAppleHealthKit (from `../node_modules/react-native-health`)
- RNBackgroundFetch (from `../node_modules/react-native-background-fetch`)
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
- "RNCMaskedView (from `../node_modules/@react-native-masked-view/masked-view`)"
- "RNCPicker (from `../node_modules/@react-native-picker/picker`)"
@@ -2104,6 +2109,7 @@ DEPENDENCIES:
- RNScreens (from `../node_modules/react-native-screens`)
- "RNSentry (from `../node_modules/@sentry/react-native`)"
- RNSVG (from `../node_modules/react-native-svg`)
- UMAppLoader (from `../node_modules/unimodules-app-loader/ios`)
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
SPEC REPOS:
@@ -2144,6 +2150,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/expo-apple-authentication/ios"
ExpoAsset:
:path: "../node_modules/expo-asset/ios"
ExpoBackgroundTask:
:path: "../node_modules/expo-background-task/ios"
ExpoBlur:
:path: "../node_modules/expo-blur/ios"
ExpoCamera:
@@ -2178,6 +2186,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/expo-system-ui/ios"
ExpoWebBrowser:
:path: "../node_modules/expo-web-browser/ios"
EXTaskManager:
:path: "../node_modules/expo-task-manager/ios"
fast_float:
:podspec: "../node_modules/react-native/third-party-podspecs/fast_float.podspec"
FBLazyVector:
@@ -2320,8 +2330,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon"
RNAppleHealthKit:
:path: "../node_modules/react-native-health"
RNBackgroundFetch:
:path: "../node_modules/react-native-background-fetch"
RNCAsyncStorage:
:path: "../node_modules/@react-native-async-storage/async-storage"
RNCMaskedView:
@@ -2346,6 +2354,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/@sentry/react-native"
RNSVG:
:path: "../node_modules/react-native-svg"
UMAppLoader:
:path: "../node_modules/unimodules-app-loader/ios"
Yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"
@@ -2359,6 +2369,7 @@ SPEC CHECKSUMS:
Expo: c9e30ab79606b3800733594a961528bc4abb0ffe
ExpoAppleAuthentication: 4d2e0c88a4463229760f1fbb9a937a810efb6863
ExpoAsset: ef06e880126c375f580d4923fdd1cdf4ee6ee7d6
ExpoBackgroundTask: 6c1990438e45b5c4bbbc7d75aa6b688d53602fe8
ExpoBlur: 3c8885b9bf9eef4309041ec87adec48b5f1986a9
ExpoCamera: e1879906d41184e84b57d7643119f8509414e318
ExpoFileSystem: 7f92f7be2f5c5ed40a7c9efc8fa30821181d9d63
@@ -2376,6 +2387,7 @@ SPEC CHECKSUMS:
ExpoSymbols: c5612a90fb9179cdaebcd19bea9d8c69e5d3b859
ExpoSystemUI: 433a971503b99020318518ed30a58204288bab2d
ExpoWebBrowser: dc39a88485f007e61a3dff05d6a75f22ab4a2e92
EXTaskManager: 280143f6d8e596f28739d74bf34910300dcbd4ea
fast_float: 23278fd30b349f976d2014f4aec9e2d7bc1c3806
FBLazyVector: d2a9cd223302b6c9aa4aa34c1a775e9db609eb52
fmt: b85d977e8fe789fd71c77123f9f4920d88c4d170
@@ -2456,7 +2468,6 @@ SPEC CHECKSUMS:
ReactCommon: 7eb76fcd5133313d8c6a138a5c7dd89f80f189d5
RevenueCat: eb2aa042789d9c99ad5172bd96e28b96286d6ada
RNAppleHealthKit: 86ef7ab70f762b802f5c5289372de360cca701f9
RNBackgroundFetch: e44c9e85d7fb3122c37d8a806278f62c7682d7ea
RNCAsyncStorage: b44e8a4e798c3e1f56bffccd0f591f674fb9198f
RNCMaskedView: d4644e239e65383f96d2f32c40c297f09705ac96
RNCPicker: da0f1c9411208c1ca52bc98383db54a06e0a3862
@@ -2475,6 +2486,7 @@ SPEC CHECKSUMS:
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
Sentry: 59993bffde4a1ac297ba6d268dc4bbce068d7c1b
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
UMAppLoader: 55159b69750129faa7a51c493cb8ea55a7b64eb9
Yoga: adb397651e1c00672c12e9495babca70777e411e
ZXingObjC: 8898711ab495761b2dbbdec76d90164a6d7e14c5

View File

@@ -268,12 +268,12 @@
"${PODS_CONFIGURATION_BUILD_DIR}/EXConstants/EXConstants.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/EXConstants/ExpoConstants_privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/EXNotifications/ExpoNotifications_privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/EXTaskManager/ExpoTaskManager_privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/ExpoFileSystem/ExpoFileSystem_privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/ExpoSystemUI/ExpoSystemUI_privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/PurchasesHybridCommon/PurchasesHybridCommon.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/QCloudCOSXML/QCloudCOSXML.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RCT-Folly/RCT-Folly_privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RNBackgroundFetch/TSBackgroundFetchPrivacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RNCAsyncStorage/RNCAsyncStorage_resources.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RNDeviceInfo/RNDeviceInfoPrivacyInfo.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RNSVG/RNSVGFilters.bundle",
@@ -293,12 +293,12 @@
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/EXConstants.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ExpoConstants_privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ExpoNotifications_privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ExpoTaskManager_privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ExpoFileSystem_privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ExpoSystemUI_privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/PurchasesHybridCommon.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/QCloudCOSXML.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCT-Folly_privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/TSBackgroundFetchPrivacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RNCAsyncStorage_resources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RNDeviceInfoPrivacyInfo.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RNSVGFilters.bundle",

View File

@@ -1,7 +1,6 @@
import Expo
import React
import ReactAppDependencyProvider
import TSBackgroundFetch
@UIApplicationMain
public class AppDelegate: ExpoAppDelegate {
@@ -22,8 +21,6 @@ public class AppDelegate: ExpoAppDelegate {
reactNativeFactory = factory
bindReactNativeFactory(factory)
TSBackgroundFetch.sharedInstance().didFinishLaunching();
#if os(iOS) || os(tvOS)
window = UIWindow(frame: UIScreen.main.bounds)
factory.startReactNative(