jpush / jshare-react-native

https://docs.jiguang.cn
MIT License
105 stars 28 forks source link

1、Android的微信分享,没有反应,只会闪一下,其他的没问题。2、imagePath支持本地的图片,这个本地是指原生的工程中吗?我在纯RN中的是无效的 #108

Closed oncezou closed 5 years ago

JoshLipan commented 6 years ago

各个平台参数支持情况参考文档 微信分享配置是否完善?确认配置正确情况下抓 log 来看

chatugpt commented 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);
                                    });

                                })
TestsLing commented 5 years ago

@happyxlq 我在ios上获取 imagePath: e.originalFilepath, 为undefined,请问在ios上该怎么获取本地路径 image