A cordova plugin, a JS version of Wechat SDK
Share title, description, image, and link to wechat moment(朋友圈)
See cordova-plugin-wechat-example
-
Add wechat lib to your project. Don't forget to add the "URL Type".
-
cordova plugin add https://github.com/xu-li/cordova-plugin-wechat
, or using plugman, phonegap -
cordova build ios
(it will fail if you haven't include the wechat lib yet.) -
Open
config.xml
in xcode at the root. -
Add
<preference name="wechatappid" value="YOUR_WECHAT_APP_ID" />
Wechat.share({
message: {
title: "Message Title",
description: "Message Description(optional)",
mediaTagName: "Media Tag Name(optional)",
thumb: "http://YOUR_THUMBNAIL_IMAGE",
media: {
type: Wechat.Type.WEBPAGE, // webpage
webpageUrl: "https://github.com/xu-li/cordova-plugin-wechat" // webpage
}
},
scene: Wechat.Scene.TIMELINE // share to Timeline
}, function () {
alert("Success");
}, function (reason) {
alert("Failed: " + reason);
});
Q: "Wechat not installed", even installed
A: Please make sure "wechatappid" is added in config.xml
-
Add android version -
Share to wechat session(聊天) and wechat favorite(收藏) -
Add other media types, including music etc.