-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
188 lines (188 loc) · 4.6 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
declare module "@byron-react-native/wechat" {
/*
* @brief 请求发送场景
*/
export enum WXScene {
/**
* 聊天界面
*/
WXSceneSession = 0,
/**
* 朋友圈
*/
WXSceneTimeline = 1,
/**
* 收藏
*/
WXSceneFavorite = 2,
/**
* 指定联系人
*/
WXSceneSpecifiedSession = 3,
/**
* 状态
*/
WXSceneState = 4,
}
export interface WXBaseResp {
errCode: number;
errStr: string;
type: number;
}
export interface WXSendAuthResp extends WXBaseResp {
code: string;
state: string;
lang: string;
country: string;
}
export interface WXImageParams {
filePath: string;
tagName: string;
messageExt: string;
action: string;
thumbPath: string;
scene: WXScene;
}
export interface WXLinkURLParams {
url: string;
tagName: string;
title: string;
description: string;
thumbPath: string;
scene: WXScene;
}
export interface WXMusicURLParams {
url: string;
dataURL: string;
title: string;
description: string;
thumbPath: string;
scene: WXScene;
}
export interface WXVideoURLParams {
url: string;
title: string;
description: string;
thumbPath: string;
scene: WXScene;
}
export interface WXSubscribeMsgResp extends WXBaseResp {
templateId: string;
scene: WXScene;
action: string;
reserved: string;
openId: string;
}
export interface WXPayParams {
partnerId: string;
prepayId: string;
nonceStr: string;
timeStamp: string;
sign: string;
package: string;
extData: string;
appId: string;
}
class WXSdk {
/**
* @brief WXApi的成员函数,向微信终端程序注册第三方应用
* @attention 需要在每次启动第三方应用程序时调用
* @param appid 微信开发者ID
* @param universalLink 微信开发者Universal Link
* @returns 成功返回YES,失败返回NO
*/
static registerApp(appid: string, universalLink: string): Promise<boolean>;
/**
* @brief 检查微信是否已被用户安装
* @returns 微信已安装返回YES,未安装返回NO
*/
static isWXAppInstalled(): Promise<boolean>;
/**
* @brief 判断当前微信的版本是否支持OpenApi
* @returns 支持返回YES,不支持返回NO
*/
static isWXAppSupportApi(): Promise<boolean>;
/**
* @brief 获取微信的itunes安装地址
* @returns 微信的安装地址字符串
*/
static getWXAppInstallUrl(): Promise<string>;
/**
* @brief 获取当前微信SDK的版本号
* @returns 返回当前微信SDK的版本号
*/
static getApiVersion(): Promise<string>;
/**
* @brief 打开微信
* @returns 成功返回YES,失败返回NO。
*/
static openWXApp(): Promise<boolean>;
/**
* 第三方程序要向微信申请认证
* @param scope 字符串长度不能超过1K
* @param state 字符串长度不能超过1K
* @param openID 字符串长度不能超过1K
*/
static sendAuth(
scope: string,
state: string,
openID: string
): Promise<WXSendAuthResp | undefined>;
/**
* 发送Text消息给微信
* @param text 文本长度必须大于0且小于10K
* @param scene 请求发送场景
*/
static sendText(
text: string,
scene: WXScene
): Promise<WXBaseResp | undefined>;
/**
* 发送Photo消息给微信
*/
static sendImage(params: WXImageParams): Promise<WXBaseResp | undefined>;
/**
* 发送Link消息给微信
*/
static sendLinkURL(
params: WXLinkURLParams
): Promise<WXBaseResp | undefined>;
/**
* 发送Music消息给微
*/
static sendMusicURL(
params: WXMusicURLParams
): Promise<WXBaseResp | undefined>;
/**
* 发送Video消息给微信
*/
static sendVideoURL(
params: WXVideoURLParams
): Promise<WXBaseResp | undefined>;
/**
* 订阅消息
*/
static subscription(
scene: string,
templateId: string,
reserved: string,
cb: (data: WXSubscribeMsgResp) => void
): Promise<{ remove: () => void } | undefined>;
/**
* 跳转到微信客服会话
*/
static openCustomerService(
corpId: string,
url: string
): Promise<(WXBaseResp & { extMsg: string }) | undefined>;
static pay(params: Partial<WXPayParams>): Promise<boolean>;
static addListener(
cb: (data: {
extInfo: string;
title: string;
description: string;
}) => void
): { remove: () => void };
}
export default WXSdk;
}