【发布时间】:2021-09-22 17:37:30
【问题描述】:
对于我正在构建的 web 应用程序,我需要集成文件共享功能。自 IOS 15 发布以来,这现在终于成为可能。但是,我只让它部分工作。当我通过电子邮件或消息共享文件时,它工作正常。但是当我尝试与whatsapp、signal 或threema 共享时,它只会共享标题,而不是实际文件。我没有在控制台中看到任何错误或任何失败的网络请求。
const audioResponse = await fetch(sound.downloadUrl);
const fileBuffer = await audioResponse.arrayBuffer();
const fileArray = [
new File([fileBuffer], name + '.mp3', {
type: 'audio/mpeg',
lastModified: Date.now(),
}),
];
if (
window.navigator.canShare &&
window.navigator.canShare({ files: fileArray })
) {
navigator
.share({
files: fileArray,
title: name,
text: 'File share test',
})
.then(() => {
console.log('Success!');
})
.catch(console.error);
}
【问题讨论】:
标签: javascript whatsapp navigator web-share