Closed oncezou closed 5 years ago
本地图片的问题 测试是可以的
import {ImageEditor} from 'react-native';
import RNFS from 'react-native-fs';
JShareModule.isWeChatInstalled((e)=>{
if(e == false)
{
Toast.fail('请安装微信');
return;
}
let cropData = {
offset: {x: 0, y: 0},
size: {width: 120, height: 120},
resizeMode: 'cover',
};
ImageEditor.cropImage(this.state.image , cropData, (image => {
RNFS.stat(image).then((e)=>{console.info(e)
let message = {
type: 'link',
platform: 'wechat_timeLine', // 分享到指定平台,目前只支持趣聊
url: 'https://www.baidu.com/',
imagePath:e.originalFilepath,
title: this.state.title?this.state.title:'',
text: this.state.content?this.state.content:'',
}
JShareModule.share(message, (map) => {
console.log("share succeed, map: " + map);
RNFS.unlink(image)
.then(() => {
console.log('FILE DELETED');
})
// `unlink` will throw an error, if the item to unlink does not exist
.catch((err) => {
console.log(err.message);
});
}, (map) => {
RNFS.unlink(image)
.then(() => {
console.log('FILE DELETED');
})
// `unlink` will throw an error, if the item to unlink does not exist
.catch((err) => {
console.log(err.message);
});
console.log("share fail, map: ");
console.info(map);
Toast.fail('分享失败');
})
}).catch((e)=>{console.info(e)})
}),(e)=>{
console.info(e);
});
})
@happyxlq 我在ios上获取 imagePath: e.originalFilepath, 为undefined,请问在ios上该怎么获取本地路径
各个平台参数支持情况参考文档 微信分享配置是否完善?确认配置正确情况下抓 log 来看