gpt4 book ai didi

angular - 使用 ionic 中的社交共享插件发送图像

转载 作者:行者123 更新时间:2023-12-05 07:28:19 25 4
gpt4 key购买 nike

我正在生成二维码,我想分享生成的二维码(通过)社交分享插件。下面是我分享图片的代码。

share() {

let currentImage= "data:image/jpeg;base64,"+ this.createdCode;
this.socialSharing.share("QR Image to share", "QRCode", currentImage, '').then(()=>{
console.log('sharing success');
}).
catch(()=>{
console.log('not possible to share ');
});
}

this.createdCode 是生成二维码的字符串。问题是,此插件显示带有共享应用程序列表的操作表。但我无法使用共享应用程序列表传输图像。但我可以传输文本。谁能告诉我如何使用社交共享插件传输图像。

最佳答案

社交分享插件接受图像作为字符串,所以如果您使用 qrcode 包,您可以使用数据 url 将生成的二维码分享到社交媒体,如下所示:

const options = {
errorCorrectionLevel: 'H',
type: 'image/jpeg',
quality: 0.3,
margin: 4
}

qrCode.toDataURL('sample text', options, (err, url) => {
if (err) throw err
this.socialSharing.shareViaTwitter("Share via Twitter", url)
.then(async () => {
const alert = await this.alert.create({
header: 'Alert',
subHeader: 'success',
message: 'shared successfully',
buttons: ['OK']
});
await alert.present();
}).catch(async (err) => {
const alert = await this.alert.create({
header: 'Alert',
subHeader: 'error',
message: 'Error, Did not share because: ' + err,
buttons: ['OK']
});
await alert.present();
})
})

关于angular - 使用 ionic 中的社交共享插件发送图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53444322/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com