目录
1.概述
这里我们能做有两件事:
1)主动发起分享
2)监听右上角分享('...'按钮,发朋友圈也在这里)
API:官方文档
2.代码
1)主动发起分享:WX.ShareAppMessage
cs
WX.ShareAppMessage(new ShareAppMessageOption
{
imageUrl = imageUrl, // 图片的URL,也可以不填(自动截屏)
title = title, // 显示文本
query = query, // 附带参数,限制2k长度
});
2)监听右上角分享
分享:shareAppMessage
朋友圈:shareTimeline
cs
public void OnShareAppMessage(bool isListen = true, string imageUrl = "", string title = "", string query = "")
{
if (isListen)
{
WX.ShowShareMenu(new ShowShareMenuOption()
{
withShareTicket = true,
menus = new string[] { "shareAppMessage", "shareTimeline" },
});
}
// 获取用户信息
WX.OnShareAppMessage(new WXShareAppMessageParam()
{
imageUrl = imageUrl,
title = title,
query = query,
});
WX.OnShareTimeline((x) => {
x.Invoke(new OnShareTimelineListenerResult()
{
imageUrl = imageUrl,
title = title,
query = query,
});
});
}
3.示例
4.个人作品
小游戏:小小狼吃羊
感兴趣的可以玩玩看^_^