更新依赖项版本,优化后台任务管理器,添加后台任务自动启动功能,调整后台获取配置,移除冗余代码
This commit is contained in:
@@ -10,7 +10,7 @@ PODS:
|
||||
- React-Core
|
||||
- EXNotifications (0.31.4):
|
||||
- ExpoModulesCore
|
||||
- Expo (53.0.20):
|
||||
- Expo (53.0.22):
|
||||
- DoubleConversion
|
||||
- ExpoModulesCore
|
||||
- glog
|
||||
@@ -36,7 +36,7 @@ PODS:
|
||||
- ReactCommon/turbomodule/bridging
|
||||
- ReactCommon/turbomodule/core
|
||||
- Yoga
|
||||
- ExpoAppleAuthentication (6.4.2):
|
||||
- ExpoAppleAuthentication (7.2.4):
|
||||
- ExpoModulesCore
|
||||
- ExpoAsset (11.1.7):
|
||||
- ExpoModulesCore
|
||||
@@ -52,7 +52,7 @@ PODS:
|
||||
- ExpoModulesCore
|
||||
- ExpoHaptics (14.1.4):
|
||||
- ExpoModulesCore
|
||||
- ExpoHead (5.1.4):
|
||||
- ExpoHead (5.1.5):
|
||||
- ExpoModulesCore
|
||||
- ExpoImage (2.4.0):
|
||||
- ExpoModulesCore
|
||||
@@ -96,7 +96,7 @@ PODS:
|
||||
- ExpoModulesCore
|
||||
- ExpoSymbols (0.4.5):
|
||||
- ExpoModulesCore
|
||||
- ExpoSystemUI (5.0.10):
|
||||
- ExpoSystemUI (5.0.11):
|
||||
- ExpoModulesCore
|
||||
- ExpoWebBrowser (14.2.0):
|
||||
- ExpoModulesCore
|
||||
@@ -1943,7 +1943,7 @@ PODS:
|
||||
- ReactCommon/turbomodule/bridging
|
||||
- ReactCommon/turbomodule/core
|
||||
- Yoga
|
||||
- RNSentry (6.20.0):
|
||||
- RNSentry (6.21.0):
|
||||
- DoubleConversion
|
||||
- glog
|
||||
- RCT-Folly (= 2024.11.18.00)
|
||||
@@ -2351,15 +2351,15 @@ SPEC CHECKSUMS:
|
||||
EXConstants: 98bcf0f22b820f9b28f9fee55ff2daededadd2f8
|
||||
EXImageLoader: 4d3d3284141f1a45006cc4d0844061c182daf7ee
|
||||
EXNotifications: be5e949edf1d60b70e77178b81aa505298fadd07
|
||||
Expo: 8685113c16058e8b3eb101dd52d6c8bca260bbea
|
||||
ExpoAppleAuthentication: 8a661b6f4936affafd830f983ac22463c936dad5
|
||||
Expo: c9e30ab79606b3800733594a961528bc4abb0ffe
|
||||
ExpoAppleAuthentication: 4d2e0c88a4463229760f1fbb9a937a810efb6863
|
||||
ExpoAsset: ef06e880126c375f580d4923fdd1cdf4ee6ee7d6
|
||||
ExpoBlur: 3c8885b9bf9eef4309041ec87adec48b5f1986a9
|
||||
ExpoCamera: e1879906d41184e84b57d7643119f8509414e318
|
||||
ExpoFileSystem: 7f92f7be2f5c5ed40a7c9efc8fa30821181d9d63
|
||||
ExpoFont: cf508bc2e6b70871e05386d71cab927c8524cc8e
|
||||
ExpoHaptics: 0ff6e0d83cd891178a306e548da1450249d54500
|
||||
ExpoHead: a7b66cbaeeb51f4a85338d335a0f5467e29a2c90
|
||||
ExpoHead: 54d7ce2efb9ecb9920b585051f5d0fbc96464234
|
||||
ExpoImage: e4102c93d1dbe99ff54b075452d1bc9d6ec21b7c
|
||||
ExpoImagePicker: 0963da31800c906e01c03e25d7c849f16ebf02a2
|
||||
ExpoKeepAwake: bf0811570c8da182bfb879169437d4de298376e7
|
||||
@@ -2368,7 +2368,7 @@ SPEC CHECKSUMS:
|
||||
ExpoModulesCore: 272bc6c06ddd9c4bee2048acc57891cab3700627
|
||||
ExpoSplashScreen: 1c22c5d37647106e42d4ae1582bb6d0dda3b2385
|
||||
ExpoSymbols: c5612a90fb9179cdaebcd19bea9d8c69e5d3b859
|
||||
ExpoSystemUI: c2724f9d5af6b1bb74e013efadf9c6a8fae547a2
|
||||
ExpoSystemUI: 433a971503b99020318518ed30a58204288bab2d
|
||||
ExpoWebBrowser: dc39a88485f007e61a3dff05d6a75f22ab4a2e92
|
||||
fast_float: 06eeec4fe712a76acc9376682e4808b05ce978b6
|
||||
FBLazyVector: d2a9cd223302b6c9aa4aa34c1a775e9db609eb52
|
||||
@@ -2461,7 +2461,7 @@ SPEC CHECKSUMS:
|
||||
RNPurchases: 7993b33416e67d5863140b5c62c682b34719f475
|
||||
RNReanimated: 34e90d19560aebd52a2ad583fdc2de2cf7651bbb
|
||||
RNScreens: 241cfe8fc82737f3e132dd45779f9512928075b8
|
||||
RNSentry: 7fbd30d392b5ac268cdebe085bfd7830c735a4d6
|
||||
RNSentry: 605b0108f57a8b921ca5ef7aa0b97d469a723c57
|
||||
RNSVG: 3544def7b3ddc43c7ba69dade91bacf99f10ec46
|
||||
SDWebImage: f29024626962457f3470184232766516dee8dfea
|
||||
SDWebImageAVIFCoder: 00310d246aab3232ce77f1d8f0076f8c4b021d90
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Expo
|
||||
import React
|
||||
import ReactAppDependencyProvider
|
||||
import TSBackgroundFetch
|
||||
|
||||
@UIApplicationMain
|
||||
public class AppDelegate: ExpoAppDelegate {
|
||||
@@ -21,6 +22,8 @@ public class AppDelegate: ExpoAppDelegate {
|
||||
reactNativeFactory = factory
|
||||
bindReactNativeFactory(factory)
|
||||
|
||||
TSBackgroundFetch.sharedInstance().didFinishLaunching();
|
||||
|
||||
#if os(iOS) || os(tvOS)
|
||||
window = UIWindow(frame: UIScreen.main.bounds)
|
||||
factory.startReactNative(
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
<dict>
|
||||
<key>BGTaskSchedulerPermittedIdentifiers</key>
|
||||
<array>
|
||||
<string>com.expo.modules.backgroundtask.processing</string>
|
||||
<string>com.anonymous.digitalpilates.backgroundfetch</string>
|
||||
</array>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
|
||||
896
package-lock.json
generated
896
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -25,8 +25,8 @@
|
||||
"@types/lodash": "^4.17.20",
|
||||
"cos-js-sdk-v5": "^1.6.0",
|
||||
"dayjs": "^1.11.13",
|
||||
"expo": "~53.0.20",
|
||||
"expo-apple-authentication": "6.4.2",
|
||||
"expo": "53.0.22",
|
||||
"expo-apple-authentication": "~7.2.4",
|
||||
"expo-blur": "~14.1.5",
|
||||
"expo-camera": "^16.1.11",
|
||||
"expo-constants": "~17.1.7",
|
||||
@@ -37,11 +37,11 @@
|
||||
"expo-linear-gradient": "^14.1.5",
|
||||
"expo-linking": "~7.1.7",
|
||||
"expo-notifications": "~0.31.4",
|
||||
"expo-router": "~5.1.4",
|
||||
"expo-router": "~5.1.5",
|
||||
"expo-splash-screen": "~0.30.10",
|
||||
"expo-status-bar": "~2.2.3",
|
||||
"expo-symbols": "~0.4.5",
|
||||
"expo-system-ui": "~5.0.10",
|
||||
"expo-system-ui": "~5.0.11",
|
||||
"expo-web-browser": "~14.2.0",
|
||||
"lodash": "^4.17.21",
|
||||
"lottie-react-native": "^7.3.4",
|
||||
|
||||
@@ -38,7 +38,7 @@ export class BackgroundTaskManager {
|
||||
try {
|
||||
// 配置后台获取
|
||||
const status = await BackgroundFetch.configure({
|
||||
minimumFetchInterval: 15, // 最小间隔15分钟(iOS 实际控制间隔)
|
||||
minimumFetchInterval: 15, // 最小间隔15分钟(单位:秒)
|
||||
}, async (taskId) => {
|
||||
console.log('[BackgroundFetch] 后台任务执行:', taskId);
|
||||
await this.executeBackgroundTasks();
|
||||
@@ -53,6 +53,10 @@ export class BackgroundTaskManager {
|
||||
this.isInitialized = true;
|
||||
console.log('后台任务管理器初始化完成');
|
||||
|
||||
// 初始化完成后自动启动后台任务
|
||||
await this.start();
|
||||
console.log('后台任务已自动启动');
|
||||
|
||||
} catch (error) {
|
||||
console.error('初始化后台任务管理器失败:', error);
|
||||
throw error;
|
||||
@@ -214,6 +218,11 @@ export class BackgroundTaskManager {
|
||||
*/
|
||||
async start(): Promise<void> {
|
||||
try {
|
||||
BackgroundFetch.scheduleTask({
|
||||
taskId: 'com.anonymous.digitalpilates.backgroundfetch',
|
||||
delay: 15 * 60 * 1000
|
||||
});
|
||||
|
||||
await BackgroundFetch.start();
|
||||
console.log('后台任务已启动');
|
||||
} catch (error) {
|
||||
@@ -410,31 +419,3 @@ export interface BackgroundTaskEvent {
|
||||
success: boolean;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台任务配置选项
|
||||
*/
|
||||
export interface BackgroundTaskConfig {
|
||||
minimumFetchInterval?: number;
|
||||
stopOnTerminate?: boolean;
|
||||
startOnBoot?: boolean;
|
||||
enableHeadless?: boolean;
|
||||
requiredNetworkType?: 'NONE' | 'ANY' | 'CELLULAR' | 'WIFI';
|
||||
requiresCharging?: boolean;
|
||||
requiresDeviceIdle?: boolean;
|
||||
requiresBatteryNotLow?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认后台任务配置
|
||||
*/
|
||||
export const DEFAULT_BACKGROUND_TASK_CONFIG: BackgroundTaskConfig = {
|
||||
minimumFetchInterval: 15000, // 15分钟
|
||||
stopOnTerminate: false,
|
||||
startOnBoot: true,
|
||||
enableHeadless: true,
|
||||
requiredNetworkType: 'ANY',
|
||||
requiresCharging: false,
|
||||
requiresDeviceIdle: false,
|
||||
requiresBatteryNotLow: false,
|
||||
};
|
||||
Reference in New Issue
Block a user