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
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.
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
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. . . . .