-
Notifications
You must be signed in to change notification settings - Fork 34
/
index.js
89 lines (75 loc) · 1.89 KB
/
index.js
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
'use strict';
import React from 'react-native';
let RCTWeChat = React.NativeModules.WeChat;
function isFunction(fn) {
return typeof fn === 'function';
}
function safeCallback(callback) {
return isFunction(callback) ? callback : function() {};
}
export default {
registerApp(appid, appdesc, callback) {
if (isFunction(appdesc)) {
callback = appdesc;
appdesc = null;
}
if (!isFunction(callback)) {
callback = function() {};
}
if (!appdesc) {
RCTWeChat.registerApp(appid, callback);
} else {
RCTWeChat.registerAppWithDesc(appid, appdesc, callback);
}
},
isWXAppInstalled(callback) {
RCTWeChat.isWXAppInstalled(safeCallback(callback));
},
getWXAppInstallUrl(callback) {
RCTWeChat.getWXAppInstallUrl(safeCallback(callback));
},
isWXAppSupportApi(callback) {
RCTWeChat.isWXAppSupportApi(safeCallback(callback));
},
getApiVersion(callback) {
RCTWeChat.getApiVersion(safeCallback(callback));
},
openWXApp(callback) {
RCTWeChat.openWXApp(safeCallback(callback));
},
sendAuthReq(scope, state, callback) {
RCTWeChat.sendAuthReq(scope, state, safeCallback(callback));
},
weChatPay(dict,callback) {
RCTWeChat.wechatPay(dict,safeCallback(callback));
},
/**
* [sendLinkURL 向微信发送链接内容]
* @param scene 0:聊天界面 1:朋友圈 2:收藏
*/
sendLinkURL(options, callback) {
RCTWeChat.sendLinkURL(
options.link,
options.tagName,
options.title,
options.desc,
options.thumbImage,
options.scene,
safeCallback(callback)
);
},
/**
* [sendImage 本地图片分享]
* @param scene 0:聊天界面 1:朋友圈 2:收藏
*/
sendImage(options, callback){
RCTWeChat.sendImage(
options.path,
options.tagName,
options.title,
options.desc,
options.scene,
safeCallback(callback)
);
}
};