gpt4 book ai didi

angular - ionic 电容器共享插件不与whatsapp共享图像

转载 作者:行者123 更新时间:2023-12-04 13:26:02 31 4
gpt4 key购买 nike

我创建了这个功能,可以在许多应用程序上很好地共享图像,但是当涉及到 时微信 或 Instagram 它不共享图像。
我正在使用带有电容器 v3 的 Ionic v5


async shareImage() {
let receiptName = 'Receipt N:123.png';
const div = this.screenshotElement.nativeElement;
const divHeight = div.clientHeight;
const divWidth = div.clientWidth;
const options = { background: '#ffffff', width: divWidth, height: divHeight };

await Filesystem.requestPermissions();

let base64Data = await domtoimage.toPng(div, options);

// device shareing
await Filesystem.writeFile({
path: receiptName,
data: base64Data,
directory: Directory.Cache
});


let fileResult = await Filesystem.getUri({
directory: Directory.Cache,
path: receiptName
});

let imageLink = Capacitor.convertFileSrc(fileResult.uri);

Share.share({
title: receiptName,
text: receiptName,
url: fileResult.uri,
})
.then(() => console.log('Successful share'))
.catch((error) => console.log('Error sharing ::: ', error));

}


进口
import domtoimage from 'dom-to-image';
import { Share } from '@capacitor/share';
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
import { Capacitor } from '@capacitor/core';
import { Camera, CameraResultType } from '@capacitor/camera';
包裹
 "@capacitor/android": "^3.1.1",
"@capacitor/app": "^1.0.2",
"@capacitor/camera": "^1.0.3",
"@capacitor/cli": "^3.1.1",
"@capacitor/core": "^3.1.1",
"@capacitor/filesystem": "^1.0.2",
"@capacitor/haptics": "^1.0.2",
"@capacitor/ios": "^3.1.1",
"@capacitor/keyboard": "^1.0.2",
"@capacitor/push-notifications": "^1.0.3",
"@capacitor/share": "^1.0.3",
"@capacitor/status-bar": "^1.0.2",

最佳答案

我发现@capacitor/share 有这个已知问题。
见:https://github.com/ionic-team/capacitor-plugins/issues/196
我通过使用解决了它

npm install cordova-plugin-x-socialsharing
npm install @ionic-native/social-sharing
ionic cap sync
见: https://ionicframework.com/docs/native/social-sharing

关于angular - ionic 电容器共享插件不与whatsapp共享图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68411694/

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