[Switch] doline on micro-channel JSSDK encountered "invalid signature" of

Author: MapleShaw
link: https: //juejin.im/post/5a3cc5ae5188252103347221
Source: Nuggets
copyright reserved by the authors. Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.

 

wx.config () piece of information online too much, the basic configuration of this bypass, the most direct say the pit of problems encountered ---- invalid signature

Investigation of each case is always no cause, but the magic is available on the Android normal position, just on ios been "invalid signature", printed with the signature of the current url url also obviously the same, Why is the signature there is a problem! ! ? ? ?

Structure of the page as follows:

SPA:

  • A page
  • Page B

Very simple, the entire application accessible from A, then jump to B, B needs to get position, I just micro-channel configuration JSSDK inside B, then we ran into the previously mentioned problems. then! ! The key here! ! In a time when debugging, I refresh the page directly from B, and then on it! ! ! ! ! What the fuk? ! !

Refresh every load is so silky from B, and from A to B, to be shot each time, so holding this problem, I came to this new world ---- About html5-History mode micro browser letter problems within the

It turned out that Jiang Zi? ! !

IOS: micro-channel version of IOS, Andrews micro-channel version, every time you switch routing, SPA's url will not change, initiated url parameter signing request must be url when the current page is the first to enter the page url

Android: Andrews micro-channel version, every time you switch routing, SPA's url is bound to change, initiated url parameter signing request must be url of the current page (not the first time into the page)

Pit father ah! Loss I put the request signed url with the url (location.href) of the current page for Bi Mingming is the same!

 

solution:

url (window.entryUrl) of global memory into the SPA, Android unchanged, still get url of the current page, IOS on the use of window.entryUrl, then the signature, done!

// record into the app url, followed by micro-channel SDK 
IF (window.entryUrl === '' ) {
    window.entryUrl = location.href.split('#')[0]
}
// time to sign 
url: isAndroid () location.href.split ( ' #') [0]:? Window.entryUrl

Digression: looks like to see people have similar problems in dealing with micro-channel sharing



Guess you like

Origin www.cnblogs.com/sungong1987/p/12384322.html