Fix iOS crash, storage, and printing issues; setup apk build

This commit is contained in:
2026-05-30 23:09:36 +02:00
parent eee684a3c9
commit 54666b077a
19 changed files with 1821 additions and 149 deletions
+7 -8
View File
@@ -1,4 +1,4 @@
import { Asset, Album, getPermissionsAsync, requestPermissionsAsync } from 'expo-media-library';
import { getPermissionsAsync, requestPermissionsAsync, createAssetAsync, getAlbumAsync, createAlbumAsync, addAssetsToAlbumAsync } from 'expo-media-library';
const ALBUM_NAME = 'Schnappix';
@@ -33,28 +33,27 @@ export async function saveToGallery(localUri: string): Promise<string> {
}
// 1. Create a media asset from the local file
const asset = await Asset.create(localUri);
const asset = await createAssetAsync(localUri);
try {
// 2. Check if the "Schnappix" album already exists
const album = await Album.get(ALBUM_NAME);
const album = await getAlbumAsync(ALBUM_NAME);
if (!album) {
// 3. If it doesn't exist, create it with our asset
await Album.create(ALBUM_NAME, [asset], false);
await createAlbumAsync(ALBUM_NAME, asset, false);
console.log(`Created new album "${ALBUM_NAME}" and saved photo.`);
} else {
// 4. If it exists, add our asset to it
await album.add(asset);
await addAssetsToAlbumAsync([asset], album, false);
console.log(`Saved photo to existing album "${ALBUM_NAME}".`);
}
const assetUri = await asset.getUri();
return assetUri;
return asset.uri;
} catch (e: any) {
console.error('Error saving asset to album, returning fallback asset URI:', e);
try {
return await asset.getUri();
return asset.uri;
} catch {
return asset.id;
}