From 896dcac471b879df2b1e890ee0da747a53b3eb4a Mon Sep 17 00:00:00 2001 From: Kenneth Date: Thu, 3 Oct 2024 19:08:13 +0100 Subject: [PATCH] fix: use saveToLibraryAsync to add photos --- app/wallpaper.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/wallpaper.tsx b/app/wallpaper.tsx index 08ae1b6..9fff4bc 100644 --- a/app/wallpaper.tsx +++ b/app/wallpaper.tsx @@ -21,8 +21,6 @@ export default function WallpaperPage() { return null; } - const imageName = selectedWallpaper.display_name; - async function downloadWallpaper() { if (!selectedWallpaper) { return; @@ -31,9 +29,7 @@ export default function WallpaperPage() { setIsDownloading(true); try { - const permStatus = await MediaLibrary.requestPermissionsAsync(true, [ - "photo", - ]); + const permStatus = await MediaLibrary.requestPermissionsAsync(true); if (permStatus.status != MediaLibrary.PermissionStatus.GRANTED) { Alert.alert( "Media library access required", @@ -46,7 +42,7 @@ export default function WallpaperPage() { selectedWallpaper.secure_url, `${FileSystem.documentDirectory}${selectedWallpaper.asset_id}.${selectedWallpaper.format}`, ); - await MediaLibrary.createAssetAsync(result.uri); + await MediaLibrary.saveToLibraryAsync(result.uri); Alert.alert( "Wallpaper saved successfully", "You can change the wallpaper in Settings.",