Merge pull request #245 from BambooSword/master
feat: add openCustomerServiceChat method
This commit is contained in:
commit
2c774270cb
@ -32,6 +32,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|||||||
import com.tencent.mm.opensdk.modelbase.BaseReq;
|
import com.tencent.mm.opensdk.modelbase.BaseReq;
|
||||||
import com.tencent.mm.opensdk.modelbase.BaseResp;
|
import com.tencent.mm.opensdk.modelbase.BaseResp;
|
||||||
import com.tencent.mm.opensdk.modelbiz.ChooseCardFromWXCardPackage;
|
import com.tencent.mm.opensdk.modelbiz.ChooseCardFromWXCardPackage;
|
||||||
|
import com.tencent.mm.opensdk.modelbiz.WXOpenCustomerServiceChat;
|
||||||
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
import com.tencent.mm.opensdk.modelmsg.SendAuth;
|
||||||
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||||
import com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX;
|
import com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX;
|
||||||
@ -672,6 +673,20 @@ public class WeChatLibModule extends ReactContextBaseJavaModule implements IWXAP
|
|||||||
callback.invoke(api.sendReq(payReq) ? null : INVOKE_FAILED);
|
callback.invoke(api.sendReq(payReq) ? null : INVOKE_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ReactMethod
|
||||||
|
public void openCustomerServiceChat(String corpId, String kfUrl, Callback callback) {
|
||||||
|
if (api == null) {
|
||||||
|
callback.invoke(NOT_REGISTERED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// open customer service logic
|
||||||
|
WXOpenCustomerServiceChat.Req req = new WXOpenCustomerServiceChat.Req();
|
||||||
|
|
||||||
|
req.corpId = corpId;
|
||||||
|
req.url = kfUrl;
|
||||||
|
callback.invoke(null, api.sendReq(req));
|
||||||
|
}
|
||||||
|
|
||||||
private void _share(final int scene, final ReadableMap data, final Callback callback) {
|
private void _share(final int scene, final ReadableMap data, final Callback callback) {
|
||||||
Uri uri = null;
|
Uri uri = null;
|
||||||
if (data.hasKey("thumbImage")) {
|
if (data.hasKey("thumbImage")) {
|
||||||
|
|||||||
@ -568,6 +568,17 @@ RCT_EXPORT_METHOD(pay:(NSDictionary *)data
|
|||||||
// callback(@[success ? [NSNull null] : INVOKE_FAILED]);
|
// callback(@[success ? [NSNull null] : INVOKE_FAILED]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 跳转微信客服
|
||||||
|
RCT_EXPORT_METHOD(openCustomerServiceChat:(NSString *)corpId
|
||||||
|
:(NSString *)kfUrl
|
||||||
|
:(RCTResponseSenderBlock)callback)
|
||||||
|
{
|
||||||
|
WXOpenCustomerServiceReq *req = [[WXOpenCustomerServiceReq alloc] init];
|
||||||
|
req.corpid = corpId; //企业ID
|
||||||
|
req.url = kfUrl; //客服URL
|
||||||
|
[WXApi sendReq:req completion:nil];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - wx callback
|
#pragma mark - wx callback
|
||||||
|
|
||||||
-(void) onReq:(BaseReq*)req
|
-(void) onReq:(BaseReq*)req
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
86D0366429A4BF3E00A01343 /* libWeChatSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 86D0365E29A4BF2600A01343 /* libWeChatSDK.a */; };
|
86D0366429A4BF3E00A01343 /* libWeChatSDK.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 86D0365E29A4BF2600A01343 /* libWeChatSDK.a */; };
|
||||||
86D0366529A4BF5900A01343 /* WechatLib.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* WechatLib.m */; };
|
86D0366529A4BF5900A01343 /* WechatLib.mm in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* WechatLib.mm */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
@ -31,7 +31,7 @@
|
|||||||
86D0366029A4BF2700A01343 /* WechatAuthSDK.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WechatAuthSDK.h; sourceTree = "<group>"; };
|
86D0366029A4BF2700A01343 /* WechatAuthSDK.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WechatAuthSDK.h; sourceTree = "<group>"; };
|
||||||
86D0366129A4BF2700A01343 /* WXApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXApi.h; sourceTree = "<group>"; };
|
86D0366129A4BF2700A01343 /* WXApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXApi.h; sourceTree = "<group>"; };
|
||||||
B3E7B5881CC2AC0600A0062D /* WechatLib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WechatLib.h; sourceTree = "<group>"; };
|
B3E7B5881CC2AC0600A0062D /* WechatLib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WechatLib.h; sourceTree = "<group>"; };
|
||||||
B3E7B5891CC2AC0600A0062D /* WechatLib.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WechatLib.m; sourceTree = "<group>"; };
|
B3E7B5891CC2AC0600A0062D /* WechatLib.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WechatLib.mm; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -63,7 +63,7 @@
|
|||||||
86D0366129A4BF2700A01343 /* WXApi.h */,
|
86D0366129A4BF2700A01343 /* WXApi.h */,
|
||||||
86D0365D29A4BF2600A01343 /* WXApiObject.h */,
|
86D0365D29A4BF2600A01343 /* WXApiObject.h */,
|
||||||
B3E7B5881CC2AC0600A0062D /* WechatLib.h */,
|
B3E7B5881CC2AC0600A0062D /* WechatLib.h */,
|
||||||
B3E7B5891CC2AC0600A0062D /* WechatLib.m */,
|
B3E7B5891CC2AC0600A0062D /* WechatLib.mm */,
|
||||||
134814211AA4EA7D00B7C361 /* Products */,
|
134814211AA4EA7D00B7C361 /* Products */,
|
||||||
86D0366329A4BF3E00A01343 /* Frameworks */,
|
86D0366329A4BF3E00A01343 /* Frameworks */,
|
||||||
);
|
);
|
||||||
@ -133,7 +133,7 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
86D0366529A4BF5900A01343 /* WechatLib.m in Sources */,
|
86D0366529A4BF5900A01343 /* WechatLib.mm in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
50
src/index.d.ts
vendored
50
src/index.d.ts
vendored
@ -9,7 +9,14 @@ enum WXScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
declare module 'react-native-wechat-lib' {
|
declare module 'react-native-wechat-lib' {
|
||||||
export function registerApp(appId: string, universalLink?: string): Promise<boolean>;
|
export function registerApp(
|
||||||
|
appId: string,
|
||||||
|
universalLink?: string
|
||||||
|
): Promise<boolean>;
|
||||||
|
export function openCustomerServiceChat(
|
||||||
|
corpId: string,
|
||||||
|
kfUrl: string
|
||||||
|
): Promise<string>;
|
||||||
export function isWXAppInstalled(): Promise<boolean>;
|
export function isWXAppInstalled(): Promise<boolean>;
|
||||||
export function isWXAppSupportApi(): Promise<boolean>;
|
export function isWXAppSupportApi(): Promise<boolean>;
|
||||||
export function getApiVersion(): Promise<string>;
|
export function getApiVersion(): Promise<string>;
|
||||||
@ -39,9 +46,20 @@ declare module 'react-native-wechat-lib' {
|
|||||||
state?: string;
|
state?: string;
|
||||||
returnKey?: string;
|
returnKey?: string;
|
||||||
}
|
}
|
||||||
export function sendAuthRequest(scope: string | string[], state?: string): Promise<AuthResponse>;
|
export function sendAuthRequest(
|
||||||
|
scope: string | string[],
|
||||||
|
state?: string
|
||||||
|
): Promise<AuthResponse>;
|
||||||
export interface ShareMetadata {
|
export interface ShareMetadata {
|
||||||
type: 'news' | 'text' | 'imageUrl' | 'imageFile' | 'imageResource' | 'video' | 'audio' | 'file';
|
type:
|
||||||
|
| 'news'
|
||||||
|
| 'text'
|
||||||
|
| 'imageUrl'
|
||||||
|
| 'imageFile'
|
||||||
|
| 'imageResource'
|
||||||
|
| 'video'
|
||||||
|
| 'audio'
|
||||||
|
| 'file';
|
||||||
thumbImage?: string;
|
thumbImage?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
webpageUrl?: string;
|
webpageUrl?: string;
|
||||||
@ -109,31 +127,31 @@ declare module 'react-native-wechat-lib' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function shareText(
|
export function shareText(
|
||||||
message: ShareTextMetadata,
|
message: ShareTextMetadata
|
||||||
): Promise<{ errCode?: number; errStr?: string }>;
|
): Promise<{ errCode?: number; errStr?: string }>;
|
||||||
export function shareImage(
|
export function shareImage(
|
||||||
message: ShareImageMetadata,
|
message: ShareImageMetadata
|
||||||
): Promise<{ errCode?: number; errStr?: string }>;
|
): Promise<{ errCode?: number; errStr?: string }>;
|
||||||
export function shareLocalImage(
|
export function shareLocalImage(
|
||||||
message: ShareImageMetadata,
|
message: ShareImageMetadata
|
||||||
): Promise<{ errCode?: number; errStr?: string }>;
|
): Promise<{ errCode?: number; errStr?: string }>;
|
||||||
export function shareMusic(
|
export function shareMusic(
|
||||||
message: ShareMusicMetadata,
|
message: ShareMusicMetadata
|
||||||
): Promise<{ errCode?: number; errStr?: string }>;
|
): Promise<{ errCode?: number; errStr?: string }>;
|
||||||
export function shareVideo(
|
export function shareVideo(
|
||||||
message: ShareVideoMetadata,
|
message: ShareVideoMetadata
|
||||||
): Promise<{ errCode?: number; errStr?: string }>;
|
): Promise<{ errCode?: number; errStr?: string }>;
|
||||||
export function shareWebpage(
|
export function shareWebpage(
|
||||||
message: ShareWebpageMetadata,
|
message: ShareWebpageMetadata
|
||||||
): Promise<{ errCode?: number; errStr?: string }>;
|
): Promise<{ errCode?: number; errStr?: string }>;
|
||||||
export function shareMiniProgram(
|
export function shareMiniProgram(
|
||||||
message: ShareMiniProgramMetadata,
|
message: ShareMiniProgramMetadata
|
||||||
): Promise<{ errCode?: number; errStr?: string }>;
|
): Promise<{ errCode?: number; errStr?: string }>;
|
||||||
export function launchMiniProgram(
|
export function launchMiniProgram(
|
||||||
message: LaunchMiniProgramMetadata,
|
message: LaunchMiniProgramMetadata
|
||||||
): Promise<{ errCode?: number; errStr?: string }>;
|
): Promise<{ errCode?: number; errStr?: string }>;
|
||||||
export function subscribeMessage(
|
export function subscribeMessage(
|
||||||
message: SubscribeMessageMetadata,
|
message: SubscribeMessageMetadata
|
||||||
): Promise<{ errCode?: number; errStr?: string }>;
|
): Promise<{ errCode?: number; errStr?: string }>;
|
||||||
export interface PaymentLoad {
|
export interface PaymentLoad {
|
||||||
partnerId: string;
|
partnerId: string;
|
||||||
@ -143,7 +161,9 @@ declare module 'react-native-wechat-lib' {
|
|||||||
package: string;
|
package: string;
|
||||||
sign: string;
|
sign: string;
|
||||||
}
|
}
|
||||||
export function pay(payload: PaymentLoad): Promise<{ errCode?: number; errStr?: string }>;
|
export function pay(
|
||||||
|
payload: PaymentLoad
|
||||||
|
): Promise<{ errCode?: number; errStr?: string }>;
|
||||||
|
|
||||||
export interface ChooseInvoice {
|
export interface ChooseInvoice {
|
||||||
signType?: string;
|
signType?: string;
|
||||||
@ -159,7 +179,7 @@ declare module 'react-native-wechat-lib' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function chooseInvoice(
|
export function chooseInvoice(
|
||||||
data: ChooseInvoice,
|
data: ChooseInvoice
|
||||||
): Promise<{ errCode?: number; errStr?: string; cards: Invoice[] }>;
|
): Promise<{ errCode?: number; errStr?: string; cards: Invoice[] }>;
|
||||||
|
|
||||||
export interface ShareFileMetadata {
|
export interface ShareFileMetadata {
|
||||||
@ -169,6 +189,6 @@ declare module 'react-native-wechat-lib' {
|
|||||||
scene?: WXScene;
|
scene?: WXScene;
|
||||||
}
|
}
|
||||||
export function shareFile(
|
export function shareFile(
|
||||||
data: ShareFileMetadata,
|
data: ShareFileMetadata
|
||||||
): Promise<{ errCode?: number; errStr?: string }>;
|
): Promise<{ errCode?: number; errStr?: string }>;
|
||||||
}
|
}
|
||||||
|
|||||||
26
src/index.js
26
src/index.js
@ -146,13 +146,19 @@ export const getApiVersion = wrapApi(WeChat.getApiVersion);
|
|||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
export const openWXApp = wrapApi(WeChat.openWXApp);
|
export const openWXApp = wrapApi(WeChat.openWXApp);
|
||||||
|
/**
|
||||||
|
* Open wechat app
|
||||||
|
* @method openCustomerServiceChat
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
|
export const openCustomerServiceChat = wrapApi(WeChat.openCustomerServiceChat);
|
||||||
|
|
||||||
// wrap the APIs
|
// wrap the APIs
|
||||||
const nativeShareToTimeline = wrapApi(WeChat.shareToTimeline);
|
// const nativeShareToTimeline = wrapApi(WeChat.shareToTimeline);
|
||||||
const nativeLaunchMiniProgram = wrapApi(WeChat.launchMiniProgram);
|
const nativeLaunchMiniProgram = wrapApi(WeChat.launchMiniProgram);
|
||||||
const nativeShareToSession = wrapApi(WeChat.shareToSession);
|
// const nativeShareToSession = wrapApi(WeChat.shareToSession);
|
||||||
const nativeShareToFavorite = wrapApi(WeChat.shareToFavorite);
|
const nativeShareToFavorite = wrapApi(WeChat.shareToFavorite);
|
||||||
const nativeSendAuthRequest = wrapApi(WeChat.sendAuthRequest);
|
// const nativeSendAuthRequest = wrapApi(WeChat.sendAuthRequest);
|
||||||
const nativeShareText = wrapApi(WeChat.shareText);
|
const nativeShareText = wrapApi(WeChat.shareText);
|
||||||
const nativeShareImage = wrapApi(WeChat.shareImage);
|
const nativeShareImage = wrapApi(WeChat.shareImage);
|
||||||
const nativeShareLocalImage = wrapApi(WeChat.shareLocalImage);
|
const nativeShareLocalImage = wrapApi(WeChat.shareLocalImage);
|
||||||
@ -385,14 +391,22 @@ export function shareMiniProgram(data) {
|
|||||||
* @param {Integer} miniProgramType - 拉起小程序的类型. 0-正式版 1-开发版 2-体验版
|
* @param {Integer} miniProgramType - 拉起小程序的类型. 0-正式版 1-开发版 2-体验版
|
||||||
* @param {String} path - 拉起小程序页面的可带参路径,不填默认拉起小程序首页
|
* @param {String} path - 拉起小程序页面的可带参路径,不填默认拉起小程序首页
|
||||||
*/
|
*/
|
||||||
export function launchMiniProgram({ userName, miniProgramType = 0, path = '' }) {
|
export function launchMiniProgram({
|
||||||
|
userName,
|
||||||
|
miniProgramType = 0,
|
||||||
|
path = '',
|
||||||
|
}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (miniProgramType !== 0 && miniProgramType !== 1 && miniProgramType !== 2) {
|
if (
|
||||||
|
miniProgramType !== 0 &&
|
||||||
|
miniProgramType !== 1 &&
|
||||||
|
miniProgramType !== 2
|
||||||
|
) {
|
||||||
reject(
|
reject(
|
||||||
new WechatError({
|
new WechatError({
|
||||||
errStr: '拉起小程序的类型不对,0-正式版 1-开发版 2-体验版',
|
errStr: '拉起小程序的类型不对,0-正式版 1-开发版 2-体验版',
|
||||||
errCode: -1,
|
errCode: -1,
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user