sendFilesToAppGroups method
Send files to the app groups directory
Implementation
Future sendFilesToAppGroups(Map<String, dynamic> data) async {
if (_appGroupId == null) {
throw Exception('appGroupId is null. Please call init() first.');
}
for (String key in data.keys) {
final value = data[key];
if (value is! LiveActivityFile) {
continue;
}
Directory appGroupFiles = await _liveActivitiesFilesDirectory();
Directory tempDir = await getTemporaryDirectory();
// create directory if not exists
appGroupFiles.createSync();
final bytes = await value.loadFile();
File file = await File('${tempDir.path}/${value.fileName}').create()
..writeAsBytesSync(bytes);
if (value.imageOptions != null) {
await _processImageFileOperations(file, value.imageOptions!);
}
final finalDestination = '${appGroupFiles.path}/${value.fileName}';
file.copySync(finalDestination);
data[key] = finalDestination;
_assetsCopiedInAppGroups.add(finalDestination);
// remove file from temp directory
file.deleteSync();
}
}