Sharing to WeChat: WeixinJSBridge is undefined

1k views Asked by At

I'm trying to implement sharing to WeChat on our site.

Accordingly to docs, I have to load SDK from http://res.wx.qq.com/open/js/jweixin-1.0.0.js, configure it, and call corresponding methods (onMenuShareAppMessage in my case).

I did all configuration, it seems that it's ok (no errors displayed, wx.ready() callback is executed), but when I call wx methods, nothing happens at all.

Reading SDK code (minified), I can see that everything is wrapped in constructions like window.WeixinJSBridge ? WeixinJSBridge.doSmth() : doNothing(). In my case WeixinJSBridge is undefined.

But what is that WeixinJSBridge and where should I get it? It's not described in docs. Googling it gives some pages on Chinese with same question – "WeixinJSBridge is undefined" and with no answer.

How to properly work with all this stuff? Or, maybe I'm totally misunderstand the docs and sharing to WeChat from website is impossible at all? Please somebody explain.

2

There are 2 answers

0
hiperboreo On

WeixinJSBridge is an object available once http://res.wx.qq.com/open/js/jweixin-1.0.0.js is loaded inside the Wechat Web Browser.

It's used specifically to start the payment process in Wechat App.

If you wanna test/debug it, download the wechat testing software for desktop here: https://mp.weixin.qq.com/wiki?action=doc&id=mp1455784140

0
jeron-diovis On

Understood. That SDK is only for WeChat browser, built-in inside their mobile application. For other browsers SDK has no sense.

So yep, normally it's impossible to share content to WeChat from website.