我想从URL下载图像并保存到图库中。
这个代码在Android上运行良好,但在iOS上无效。
这个代码在Android上运行良好,但在iOS上无效。
import RNFetchBlob from "rn-fetch-blob";
let imgUrl = 'https://static.scientificamerican.com/sciam/cache/file/EAF12335-B807-4021-9AC95BBA8BEE7C8D_source.jpg'
let newImgUri = imgUrl.lastIndexOf('/');
let imageName = imgUrl.substring(newImgUri);
let dirs = RNFetchBlob.fs.dirs;
let path = Platform.OS === 'ios' ? dirs['MainBundleDir'] + imageName : dirs.PictureDir + imageName;
RNFetchBlob.config({
fileCache: true,
appendExt: 'png',
indicator: true,
IOSBackgroundTask: true,
path: path,
addAndroidDownloads: {
useDownloadManager: true,
notification: true,
path: path,
description: 'Image'
},
}).fetch("GET", imgUrl).then(res => {
console.log(res, 'end downloaded')
});
我需要哪些iOS权限才能将照片保存到相册中?