fix 移除废弃方法,修复 scene 参数类型错误导致无效的问题
This commit is contained in:
parent
e7d34c677f
commit
3b7492fc48
3
index.d.ts
vendored
3
index.d.ts
vendored
@ -133,9 +133,6 @@ declare module "react-native-wechat-lib" {
|
||||
export function shareMiniProgram(
|
||||
message: ShareMiniProgramMetadata
|
||||
): Promise<{ errCode?: number; errStr?: string }>;
|
||||
export function shareToTimeline(
|
||||
message: ShareMetadata
|
||||
): Promise<{ errCode?: number; errStr?: string }>;
|
||||
export function launchMiniProgram(
|
||||
message: LaunchMiniProgramMetadata
|
||||
): Promise<{ errCode?: number; errStr?: string }>;
|
||||
|
||||
75
index.js
75
index.js
@ -182,6 +182,9 @@ export function sendAuthRequest(scopes, state) {
|
||||
* @param {Object} data
|
||||
*/
|
||||
export function shareText(data) {
|
||||
if (data && data.scene == null) {
|
||||
data.scene = 0
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
nativeShareText(data);
|
||||
emitter.once('SendMessageToWX.Resp', resp => {
|
||||
@ -200,6 +203,9 @@ export function shareText(data) {
|
||||
* @param {Object} data
|
||||
*/
|
||||
export function shareImage(data) {
|
||||
if (data && data.scene == null) {
|
||||
data.scene = 0
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
nativeShareImage(data);
|
||||
emitter.once('SendMessageToWX.Resp', resp => {
|
||||
@ -218,6 +224,9 @@ export function shareImage(data) {
|
||||
* @param {Object} data
|
||||
*/
|
||||
export function shareLocalImage(data) {
|
||||
if (data && data.scene == null) {
|
||||
data.scene = 0
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
nativeShareLocalImage(data);
|
||||
emitter.once('SendMessageToWX.Resp', resp => {
|
||||
@ -236,6 +245,9 @@ export function shareLocalImage(data) {
|
||||
* @param {Object} data
|
||||
*/
|
||||
export function shareMusic(data) {
|
||||
if (data && data.scene == null) {
|
||||
data.scene = 0
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
nativeShareMusic(data);
|
||||
emitter.once('SendMessageToWX.Resp', resp => {
|
||||
@ -254,6 +266,9 @@ export function shareMusic(data) {
|
||||
* @param {Object} data
|
||||
*/
|
||||
export function shareVideo(data) {
|
||||
if (data && data.scene == null) {
|
||||
data.scene = 0
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
nativeShareVideo(data);
|
||||
emitter.once('SendMessageToWX.Resp', resp => {
|
||||
@ -272,6 +287,9 @@ export function shareVideo(data) {
|
||||
* @param {Object} data
|
||||
*/
|
||||
export function shareWebpage(data) {
|
||||
if (data && data.scene == null) {
|
||||
data.scene = 0
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
nativeShareWebpage(data);
|
||||
emitter.once('SendMessageToWX.Resp', resp => {
|
||||
@ -289,7 +307,10 @@ export function shareWebpage(data) {
|
||||
* @param {Object} data
|
||||
*/
|
||||
export function shareMiniProgram(data) {
|
||||
if (data.miniProgramType == null) {
|
||||
if (data && data.scene == null) {
|
||||
data.scene = 0
|
||||
}
|
||||
if (data && data.miniProgramType == null) {
|
||||
data.miniProgramType = 0
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
@ -304,32 +325,6 @@ export function shareMiniProgram(data) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Share something to timeline/moments/朋友圈
|
||||
* @method shareToTimeline
|
||||
* @param {Object} data
|
||||
* @param {String} data.thumbImage - Thumb image of the message, which can be a uri or a resource id.
|
||||
* @param {String} data.type - Type of this message. Could be {news|text|imageUrl|imageFile|imageResource|video|audio|file}
|
||||
* @param {String} data.webpageUrl - Required if type equals news. The webpage link to share.
|
||||
* @param {String} data.imageUrl - Provide a remote image if type equals image.
|
||||
* @param {String} data.videoUrl - Provide a remote video if type equals video.
|
||||
* @param {String} data.musicUrl - Provide a remote music if type equals audio.
|
||||
* @param {String} data.filePath - Provide a local file if type equals file.
|
||||
* @param {String} data.fileExtension - Provide the file type if type equals file.
|
||||
*/
|
||||
export function shareToTimeline(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
nativeShareToTimeline(data);
|
||||
emitter.once('SendMessageToWX.Resp', resp => {
|
||||
if (resp.errCode === 0) {
|
||||
resolve(resp);
|
||||
} else {
|
||||
reject(new WechatError(resp));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开小程序
|
||||
* @method launchMini
|
||||
@ -355,32 +350,6 @@ export function launchMiniProgram({userName, miniProgramType = 0, path = ''}) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Share something to a friend or group
|
||||
* @method shareToSession
|
||||
* @param {Object} data
|
||||
* @param {String} data.thumbImage - Thumb image of the message, which can be a uri or a resource id.
|
||||
* @param {String} data.type - Type of this message. Could be {news|text|imageUrl|imageFile|imageResource|video|audio|file}
|
||||
* @param {String} data.webpageUrl - Required if type equals news. The webpage link to share.
|
||||
* @param {String} data.imageUrl - Provide a remote image if type equals image.
|
||||
* @param {String} data.videoUrl - Provide a remote video if type equals video.
|
||||
* @param {String} data.musicUrl - Provide a remote music if type equals audio.
|
||||
* @param {String} data.filePath - Provide a local file if type equals file.
|
||||
* @param {String} data.fileExtension - Provide the file type if type equals file.
|
||||
*/
|
||||
export function shareToSession(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
nativeShareToSession(data);
|
||||
emitter.once('SendMessageToWX.Resp', resp => {
|
||||
if (resp.errCode === 0) {
|
||||
resolve(resp);
|
||||
} else {
|
||||
reject(new WechatError(resp));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Share something to favorite
|
||||
* @method shareToFavorite
|
||||
|
||||
@ -229,7 +229,7 @@ RCT_EXPORT_METHOD(shareText:(NSDictionary *)data
|
||||
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
req.bText = YES;
|
||||
req.text = data[@"text"];
|
||||
req.scene = data[@"scene"] || WXSceneSession;
|
||||
req.scene = [data[@"scene"] integerValue];
|
||||
void ( ^ completion )( BOOL );
|
||||
completion = ^( BOOL success )
|
||||
{
|
||||
@ -273,7 +273,7 @@ RCT_EXPORT_METHOD(shareImage:(NSDictionary *)data
|
||||
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
req.bText = NO;
|
||||
req.message = message;
|
||||
req.scene = data[@"scene"] || WXSceneSession;
|
||||
req.scene = [data[@"scene"] integerValue];
|
||||
// [WXApi sendReq:req];
|
||||
void ( ^ completion )( BOOL );
|
||||
completion = ^( BOOL success )
|
||||
@ -318,7 +318,7 @@ RCT_EXPORT_METHOD(shareLocalImage:(NSDictionary *)data
|
||||
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
req.bText = NO;
|
||||
req.message = message;
|
||||
req.scene = data[@"scene"] || WXSceneSession;
|
||||
req.scene = [data[@"scene"] integerValue];
|
||||
// [WXApi sendReq:req];
|
||||
void ( ^ completion )( BOOL );
|
||||
completion = ^( BOOL success )
|
||||
@ -352,7 +352,7 @@ RCT_EXPORT_METHOD(shareMusic:(NSDictionary *)data
|
||||
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
req.bText = NO;
|
||||
req.message = message;
|
||||
req.scene = data[@"scene"] || WXSceneSession;
|
||||
req.scene = [data[@"scene"] integerValue];
|
||||
void ( ^ completion )( BOOL );
|
||||
completion = ^( BOOL success )
|
||||
{
|
||||
@ -381,7 +381,7 @@ RCT_EXPORT_METHOD(shareVideo:(NSDictionary *)data
|
||||
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
req.bText = NO;
|
||||
req.message = message;
|
||||
req.scene = data[@"scene"] || WXSceneSession;
|
||||
req.scene = [data[@"scene"] integerValue];
|
||||
void ( ^ completion )( BOOL );
|
||||
completion = ^( BOOL success )
|
||||
{
|
||||
@ -409,7 +409,7 @@ RCT_EXPORT_METHOD(shareWebpage:(NSDictionary *)data
|
||||
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
req.bText = NO;
|
||||
req.message = message;
|
||||
req.scene = data[@"scene"] || WXSceneSession;
|
||||
req.scene = [data[@"scene"] integerValue];
|
||||
void ( ^ completion )( BOOL );
|
||||
completion = ^( BOOL success )
|
||||
{
|
||||
@ -449,7 +449,7 @@ RCT_EXPORT_METHOD(shareMiniProgram:(NSDictionary *)data
|
||||
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
||||
req.bText = NO;
|
||||
req.message = message;
|
||||
req.scene = data[@"scene"] || WXSceneSession;
|
||||
req.scene = [data[@"scene"] integerValue];
|
||||
void ( ^ completion )( BOOL );
|
||||
completion = ^( BOOL success )
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user