Skip to content

Commit e04f765

Browse files
committed
fix xcode10 issue
1 parent cd2fef1 commit e04f765

File tree

8 files changed

+233
-7
lines changed

8 files changed

+233
-7
lines changed

README.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![](https://www.repostatus.org/badges/latest/active.svg)
22

3-
QQ群:190808518
3+
[中文文档](README_CN.md)
44

55
# cordova-plugin-wechat
66

@@ -84,7 +84,30 @@ Wechat.share({
8484
...
8585
media: {
8686
type: Wechat.Type.WEBPAGE,
87-
webpageUrl: "http://tech.qq.com/zt2012/tmtdecode/252.htm"
87+
webpageUrl: "http://www.jason-z.com"
88+
}
89+
},
90+
scene: Wechat.Scene.TIMELINE // share to Timeline
91+
}, function () {
92+
alert("Success");
93+
}, function (reason) {
94+
alert("Failed: " + reason);
95+
});
96+
```
97+
98+
### Share mini program
99+
```Javascript
100+
Wechat.share({
101+
message: {
102+
...
103+
media: {
104+
type: Wechat.Type.MINI,
105+
webpageUrl: "http://www.jason-z.com", // 兼容低版本的网页链接
106+
userName: "wxxxxxxxx", // 小程序原始id
107+
path: "user/info", // 小程序的页面路径
108+
hdImageData: "http://wwww.xxx.com/xx.jpg", // 程序新版本的预览图二进制数据 不超过128kb
109+
withShareTicket: true, // 是否使用带shareTicket的分享
110+
miniprogramType: 0 //正式版:0,测试版:1,体验版:2
88111
}
89112
},
90113
scene: Wechat.Scene.TIMELINE // share to Timeline
@@ -138,6 +161,11 @@ See [FAQ](https://github.com/xu-li/cordova-plugin-wechat/wiki/FAQ).
138161

139162
1. share to wechat mini program(微信小程序)
140163

164+
# Donate
165+
166+
we need your support to improve open source software ,if we induce your develop time ,welcome to donate us.
167+
168+
[![paypal](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/jasonz1987/6.66)
141169

142170
# LICENSE
143171

README_CN.md

+173
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
![](https://www.repostatus.org/badges/latest/active.svg)
2+
3+
# 关于
4+
5+
微信sdk的cordova插件
6+
7+
# 功能
8+
9+
微信登录,微信app支付,微信分享,微信投票
10+
11+
# demo
12+
13+
[cordova-plugin-wechat-example](https://github.com/xu-li/cordova-plugin-wechat-example)
14+
15+
# 安装
16+
17+
1. ```cordova plugin add cordova-plugin-wechat --variable wechatappid=YOUR_WECHAT_APPID```, or using [plugman](https://npmjs.org/package/plugman), [phonegap](https://npmjs.org/package/phonegap), [ionic](http://ionicframework.com/)
18+
19+
2. ```cordova build ios``` or ```cordova build android```
20+
21+
3. (iOS only) if your cordova version <5.1.1,check the URL Type using XCode
22+
23+
# 用法
24+
25+
## 检查微信是否安装
26+
```Javascript
27+
Wechat.isInstalled(function (installed) {
28+
alert("Wechat installed: " + (installed ? "Yes" : "No"));
29+
}, function (reason) {
30+
alert("Failed: " + reason);
31+
});
32+
```
33+
34+
## 微信认证
35+
```Javascript
36+
var scope = "snsapi_userinfo",
37+
state = "_" + (+new Date());
38+
Wechat.auth(scope, state, function (response) {
39+
// you may use response.code to get the access token.
40+
alert(JSON.stringify(response));
41+
}, function (reason) {
42+
alert("Failed: " + reason);
43+
});
44+
```
45+
46+
## 分享文本
47+
```Javascript
48+
Wechat.share({
49+
text: "This is just a plain string",
50+
scene: Wechat.Scene.TIMELINE // share to Timeline
51+
}, function () {
52+
alert("Success");
53+
}, function (reason) {
54+
alert("Failed: " + reason);
55+
});
56+
```
57+
58+
## 分享媒体(例如链接,照片,音乐,视频等)
59+
```Javascript
60+
Wechat.share({
61+
message: {
62+
title: "Hi, there",
63+
description: "This is description.",
64+
thumb: "www/img/thumbnail.png",
65+
mediaTagName: "TEST-TAG-001",
66+
messageExt: "这是第三方带的测试字段",
67+
messageAction: "<action>dotalist</action>",
68+
media: "YOUR_MEDIA_OBJECT_HERE"
69+
},
70+
scene: Wechat.Scene.TIMELINE // share to Timeline
71+
}, function () {
72+
alert("Success");
73+
}, function (reason) {
74+
alert("Failed: " + reason);
75+
});
76+
```
77+
78+
### 分享网页
79+
```Javascript
80+
Wechat.share({
81+
message: {
82+
...
83+
media: {
84+
type: Wechat.Type.WEBPAGE,
85+
webpageUrl: "http://tech.qq.com/zt2012/tmtdecode/252.htm"
86+
}
87+
},
88+
scene: Wechat.Scene.TIMELINE // share to Timeline
89+
}, function () {
90+
alert("Success");
91+
}, function (reason) {
92+
alert("Failed: " + reason);
93+
});
94+
```
95+
96+
### 分享到小程序
97+
```Javascript
98+
Wechat.share({
99+
message: {
100+
...
101+
media: {
102+
type: Wechat.Type.MINI,
103+
webpageUrl: "http://www.jason-z.com", // 兼容低版本的网页链接
104+
userName: "wxxxxxxxx", // 小程序原始id
105+
path: "user/info", // 小程序的页面路径
106+
hdImageData: "http://wwww.xxx.com/xx.jpg", // 程序新版本的预览图二进制数据 不超过128kb
107+
withShareTicket: true, // 是否使用带shareTicket的分享
108+
miniprogramType: 0 //正式版:0,测试版:1,体验版:2
109+
}
110+
},
111+
scene: Wechat.Scene.TIMELINE // share to Timeline
112+
}, function () {
113+
alert("Success");
114+
}, function (reason) {
115+
alert("Failed: " + reason);
116+
});
117+
```
118+
119+
## 发送支付请求
120+
```Javascript
121+
// See https://github.com/xu-li/cordova-plugin-wechat-example/blob/master/server/payment_demo.php for php demo
122+
var params = {
123+
partnerid: '10000100', // merchant id
124+
prepayid: 'wx201411101639507cbf6ffd8b0779950874', // prepay id
125+
noncestr: '1add1a30ac87aa2db72f57a2375d8fec', // nonce
126+
timestamp: '1439531364', // timestamp
127+
sign: '0CB01533B8C1EF103065174F50BCA001', // signed string
128+
};
129+
130+
Wechat.sendPaymentRequest(params, function () {
131+
alert("Success");
132+
}, function (reason) {
133+
alert("Failed: " + reason);
134+
});
135+
```
136+
137+
## Choose invoices from card list
138+
```Javascript
139+
//offical doc https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1496561749_f7T6D
140+
var params = {
141+
timeStamp: '1510198391', // timeStamp
142+
   signType: 'SHA1', // sign type
143+
cardSign: 'dff450eeeed08120159d285e79737173aec3df94', // cardSign
144+
nonceStr: '5598190f-5fb3-4bff-8314-fd189ab4e4b8', // nonce
145+
};
146+
147+
Wechat.chooseInvoiceFromWX(data,function(data){
148+
console.log(data);
149+
},function(){
150+
alert('error');
151+
})
152+
```
153+
154+
# FAQ
155+
156+
See [FAQ](https://github.com/xu-li/cordova-plugin-wechat/wiki/FAQ).
157+
158+
QQ群:190808518
159+
160+
# TODO
161+
162+
1. share to wechat mini program(微信小程序)
163+
164+
# 捐赠
165+
166+
开源软件的发展离不开大家的推动和支持,如果我们的插件帮助到了你,欢迎捐赠(注:微信插件)。
167+
168+
![donate.png](donate.png)
169+
170+
171+
# LICENSE
172+
173+
[MIT LICENSE](http://opensource.org/licenses/MIT)

donate.png

25 KB
Loading

plugin.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<framework src="SystemConfiguration.framework" />
7777
<framework src="Security.framework" />
7878
<framework src="CFNetwork.framework" />
79-
<framework src="libstdc++.6.tbd" />
79+
<framework src="libc++.1.tbd" />
8080
</platform>
8181

8282
<!-- android -->

src/android/Wechat.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.tencent.mm.opensdk.modelmsg.WXTextObject;
2121
import com.tencent.mm.opensdk.modelmsg.WXVideoObject;
2222
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
23+
import com.tencent.mm.opensdk.modelmsg.WXMiniProgramObject;
2324
import com.tencent.mm.opensdk.modelpay.PayReq;
2425
import com.tencent.mm.opensdk.openapi.IWXAPI;
2526
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
@@ -80,6 +81,10 @@ public class Wechat extends CordovaPlugin {
8081
public static final String KEY_ARG_MESSAGE_MEDIA_EMOTION = "emotion";
8182
public static final String KEY_ARG_MESSAGE_MEDIA_EXTINFO = "extInfo";
8283
public static final String KEY_ARG_MESSAGE_MEDIA_URL = "url";
84+
public static final String KEY_ARG_MESSAGE_MEDIA_USERNAME = "userName";
85+
public static final String KEY_ARG_MESSAGE_MEDIA_MINIPROGRAMTYPE = "miniProgramType";
86+
public static final String KEY_ARG_MESSAGE_MEDIA_PATH = "path";
87+
public static final String KEY_ARG_MESSAGE_MEDIA_WITHSHARETICKET = "withShareTicket";
8388

8489
public static final int TYPE_WECHAT_SHARING_APP = 1;
8590
public static final int TYPE_WECHAT_SHARING_EMOTION = 2;
@@ -88,7 +93,7 @@ public class Wechat extends CordovaPlugin {
8893
public static final int TYPE_WECHAT_SHARING_MUSIC = 5;
8994
public static final int TYPE_WECHAT_SHARING_VIDEO = 6;
9095
public static final int TYPE_WECHAT_SHARING_WEBPAGE = 7;
91-
public static final int TYPE_WECHAT_SHARING_TEXT = 8;
96+
public static final int TYPE_WECHAT_SHARING_MINI = 8;
9297

9398
public static final int SCENE_SESSION = 0;
9499
public static final int SCENE_TIMELINE = 1;
@@ -455,6 +460,16 @@ protected WXMediaMessage buildSharingMessage(JSONObject params)
455460
mediaObject = videoObject;
456461
break;
457462

463+
case TYPE_WECHAT_SHARING_MINI:
464+
WXMiniProgramObject miniProgramObj = new WXMiniProgramObject();
465+
miniProgramObj.webpageUrl = media.getString(KEY_ARG_MESSAGE_MEDIA_WEBPAGEURL); // 兼容低版本的网页链接
466+
miniProgramObj.miniprogramType = media.getInt(KEY_ARG_MESSAGE_MEDIA_MINIPROGRAMTYPE);// 正式版:0,测试版:1,体验版:2
467+
miniProgramObj.userName = media.getString(KEY_ARG_MESSAGE_MEDIA_USERNAME); // 小程序原始id
468+
miniProgramObj.path = media.getString(KEY_ARG_MESSAGE_MEDIA_PATH); //小程序页面路径
469+
miniProgramObj.withShareTicket = media.getBoolean(KEY_ARG_MESSAGE_MEDIA_WITHSHARETICKET); // 是否使用带shareTicket的分享
470+
mediaObject = miniProgramObj;
471+
break;
472+
458473
case TYPE_WECHAT_SHARING_WEBPAGE:
459474
default:
460475
mediaObject = new WXWebpageObject(media.getString(KEY_ARG_MESSAGE_MEDIA_WEBPAGEURL));

src/ios/CDVWechat.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ enum CDVWechatSharingType {
1717
CDVWXSharingTypeImage,
1818
CDVWXSharingTypeMusic,
1919
CDVWXSharingTypeVideo,
20-
CDVWXSharingTypeWebPage
20+
CDVWXSharingTypeWebPage,
21+
CDVWXSharingTypeMini
2122
};
2223

2324
@interface CDVWechat:CDVPlugin <WXApiDelegate>

src/ios/CDVWechat.m

+9-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,15 @@ - (WXMediaMessage *)buildSharingMessage:(NSDictionary *)message
433433
mediaObject = [WXVideoObject object];
434434
((WXVideoObject*)mediaObject).videoUrl = [media objectForKey:@"videoUrl"];
435435
break;
436-
436+
case CDVWXSharingTypeMini:
437+
object = [WXMiniProgramObject object];
438+
object.webpageUrl = [media objectForKey:@"webpageUrl"];
439+
object.userName = [media objectForKey:@"userName"];
440+
object.path = [media objectForKey:@"path"];
441+
object.hdImageData = [self getNSDataFromURL:[media objectForKey:@"hdImage"]];
442+
object.withShareTicket = [media objectForKey:@"withShareTicket"];
443+
object.miniProgramType = [media objectForKey:@"miniProgramType"];
444+
break;
437445
case CDVWXSharingTypeWebPage:
438446
default:
439447
mediaObject = [WXWebpageObject object];

www/wechat.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ module.exports = {
1414
IMAGE: 4,
1515
MUSIC: 5,
1616
VIDEO: 6,
17-
WEBPAGE: 7
17+
WEBPAGE: 7,
18+
MINI: 8
1819
},
1920

2021
isInstalled: function (onSuccess, onError) {

0 commit comments

Comments
 (0)