fix: use saveToLibraryAsync to add photos
This commit is contained in:
@@ -21,8 +21,6 @@ export default function WallpaperPage() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const imageName = selectedWallpaper.display_name;
|
|
||||||
|
|
||||||
async function downloadWallpaper() {
|
async function downloadWallpaper() {
|
||||||
if (!selectedWallpaper) {
|
if (!selectedWallpaper) {
|
||||||
return;
|
return;
|
||||||
@@ -31,9 +29,7 @@ export default function WallpaperPage() {
|
|||||||
setIsDownloading(true);
|
setIsDownloading(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const permStatus = await MediaLibrary.requestPermissionsAsync(true, [
|
const permStatus = await MediaLibrary.requestPermissionsAsync(true);
|
||||||
"photo",
|
|
||||||
]);
|
|
||||||
if (permStatus.status != MediaLibrary.PermissionStatus.GRANTED) {
|
if (permStatus.status != MediaLibrary.PermissionStatus.GRANTED) {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
"Media library access required",
|
"Media library access required",
|
||||||
@@ -46,7 +42,7 @@ export default function WallpaperPage() {
|
|||||||
selectedWallpaper.secure_url,
|
selectedWallpaper.secure_url,
|
||||||
`${FileSystem.documentDirectory}${selectedWallpaper.asset_id}.${selectedWallpaper.format}`,
|
`${FileSystem.documentDirectory}${selectedWallpaper.asset_id}.${selectedWallpaper.format}`,
|
||||||
);
|
);
|
||||||
await MediaLibrary.createAssetAsync(result.uri);
|
await MediaLibrary.saveToLibraryAsync(result.uri);
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
"Wallpaper saved successfully",
|
"Wallpaper saved successfully",
|
||||||
"You can change the wallpaper in Settings.",
|
"You can change the wallpaper in Settings.",
|
||||||
|
Reference in New Issue
Block a user