Vue solves the problem of invalid signature on iOS by using JS SDK on mobile side

Source: Internet
Author: User

The recent project needs a multi-image upload function, but the problem is that there is no problem in Android, but on iOS is always invalid signature, but refreshing the page is no problem.

Vue Main, router use history mode, plus JSSDK package

The situation is always found to find out the reason, and the magic is on the Android can normally get the location, just on iOS has been "invalid signature", print out the current URL with the signed URL is also clearly consistent, why still signed there is a problem!!???

The structure of the page is as follows:

SPA:

    • Page A
    • Page b

Very simple, the entire application from a into, and then jump to b,b need to get the location, I also just in B inside the configuration of JSSDK, and then encountered the problem mentioned above. And then!! The key is coming!! At a certain time, I just refresh from the B page, and then I can!!!!! What the fu*k?!!

Every time the reload from B is so silky, and from A to B, every shot, so with this problem, I came to this new world----about html5-history mode in the browser problem

Originally, is Jiangzi?!!

Ios:ios version, Android version, each time you switch routes, the URL of the spa will not change, the URL parameter that initiates the signature request must be the URL of the current page, or the URL when the page was originally entered

Android: Android version, each time you switch routes, the URL of the spa will change, and the URL parameter that initiates the signature request must be the URL of the current page (not when the page was originally entered)

Hang Daddy! I'm just comparing the URL of the request signature to the URL of the current page (LOCATION.HREF).

Solution Solutions

Decide whether iOS or Android then do the operation in Beforerouteenter.

Beforerouteenter (to, from, next) {
var u = navigator.useragent;
var Isios =!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/); iOS terminal
XXX: Fix iOS version HTML5 history compatibility issue
if (Isios && to.path!== location.pathname) {
Location.replace is not available here
Location.assign (To.fullpath)
} else {
Next ()
}
}

This will be solved, this problem has not been the whole week, the answer format of the Internet, now sorted out, hoping to help the same as my small partners.

Vue solves the problem of invalid signature on iOS by using JS SDK on mobile side

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.