mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-17 13:53:41 +00:00
feat(ios): add iOS 26+ continued processing and Live Activities (#1514)
This commit is contained in:
1 parent
cee5f3336e
commit
e47a20a1bd
18 files changed
+2983
-3
No files matched your search
@@ -23,6 +23,7 @@ import '../../util/util.dart';
|
||||
import '../rpc/webview_rpc_service.dart';
|
||||
import 'android_foreground_service.dart';
|
||||
import 'location_keep_alive.dart';
|
||||
import 'continued_processing.dart';
|
||||
|
||||
const unixSocketPath = 'gopeed.sock';
|
||||
|
||||
@@ -105,8 +106,14 @@ class AppRuntimeController extends AsyncNotifier<AppRuntimeState> {
|
||||
),
|
||||
);
|
||||
unawaited(LocationKeepAliveCoordinator.instance.reconcile(enabled: config.extra.backgroundLocationKeepAlive));
|
||||
unawaited(
|
||||
ContinuedProcessing.setEnabled(
|
||||
config.extra.backgroundContinuedProcessing,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Future<AppRuntimeState> _init() async {
|
||||
await AppInitializer.ensureStorageInitialized();
|
||||
try {
|
||||
@@ -180,6 +187,13 @@ class AppRuntimeController extends AsyncNotifier<AppRuntimeState> {
|
||||
startupError: startupError,
|
||||
);
|
||||
if (Util.isIOS()) {
|
||||
// Make sure the native Continued Processing manager has the
|
||||
// persisted setting before app initialization completes. This
|
||||
// avoids the first download racing ahead of setEnabled(true).
|
||||
await ContinuedProcessing.setEnabled(
|
||||
config.extra.backgroundContinuedProcessing,
|
||||
);
|
||||
|
||||
LocationKeepAliveCoordinator.instance.start(
|
||||
() =>
|
||||
state.value?.downloaderConfig.extra.backgroundLocationKeepAlive ?? config.extra.backgroundLocationKeepAlive,
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class ContinuedProcessing {
|
||||
const ContinuedProcessing._();
|
||||
|
||||
static const _channel =
|
||||
MethodChannel('gopeed/continued_processing');
|
||||
|
||||
static Future<bool> isSupported() async {
|
||||
if (!Platform.isIOS) return false;
|
||||
|
||||
try {
|
||||
return await _channel.invokeMethod<bool>(
|
||||
'isSupported',
|
||||
) ??
|
||||
false;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> setEnabled(
|
||||
bool enabled,
|
||||
) async {
|
||||
if (!Platform.isIOS) return false;
|
||||
|
||||
try {
|
||||
return await _channel.invokeMethod<bool>(
|
||||
'setEnabled',
|
||||
{'enabled': enabled},
|
||||
) ??
|
||||
false;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user