search

Home  >  Q&A  >  body text

javascript - ios does not execute the js method of WeChat callback, but the Android machine has no problem. Why and how to solve it?

wx.onMenuShareTimeline({

      title: shareData.title, // Share title

      link: shareData.link, // Share link

      imgUrl: shareData.imgUrl, // Share icon

      success: function () {

          alert(123);


      },

      cancel: function () {

         

      }

  });

The ios callback success method does not execute, the cancel method executes with no problem, and the Android machine has no problem. Can anyone explain why? How to solve it

仅有的幸福仅有的幸福2753 days ago668

reply all(3)I'll reply

  • 阿神

    阿神2017-05-16 13:04:14

    It’s not a problem of non-execution, it’s that the alert is blocked on iOS, so if you want to prompt something, you can only use js to control p to pop up the prompt box.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-16 13:04:14

    It may not be the reason for iOS and Android systems.
    The difference may be caused by the different WeChat versions of the two mobile phones.

    Recently regarding sharing, WeChat has upgraded to the latest version and has strict requirements on shared links, which must be page links under JS secure domain names.

    If it is not the above problem, you can

    wx.config({
        debug: true, // 开启调试模式,
    })
    查找具体原因。

    reply
    0
  • 怪我咯

    怪我咯2017-05-16 13:04:14

    Whether the web address and the shared address are in the same domain

    I ate a lot of shit a few days ago because of this. . . .
    For example, if your html is at http://abc.com/index.html, then those sharing links must also be under the same domain name

    If different domains: Some machines are normal and some are abnormal.

    (And the most important thing is: WeChat’s development documentation has two versions, one version points out this, one does not point it out, it’s simply wonderful. According to the code given in your problem description, it is the latter, I guess I’ve tricked a lot of people)


    Other situations

    Use development tools to see if wx.config is successful

    success callback faild callback alert these callbacks

    . . . Of course, I feel that your problem is caused by different domains. . . . .

    reply
    0
  • Cancelreply