HarmonyOS鸿蒙Next中成功接入微信与QQ好友分享功能
HarmonyOS鸿蒙Next中成功接入微信与QQ好友分享功能 QQ好友分享:
官方文档:HarmonyOS_SDK接口说明 — QQ互联WIKI
官方demo:SDK下载 — QQ互联WIKI
比较坑的是demo里面没有HMAC-SHA1 签名算法,签名官方说明:QQ 互联分享签名分享方案 — QQ互联WIKI
关于签名算法 [https://ohpm.openharmony.cn/#/cn/detail/@ohos%2Fcrypto-js](https://ohpm.openharmony.cn/#/cn/detail/@ohos%2Fcrypto-js)
export async function demoGenSign(appId:string|number, shareDataStr: string, timestamp: number, nonce: number) : Promise<string> {
let totalStr = `POSTconnect.qq.com/share?appid=${appId}&nonce=${nonce}&ts=${timestamp}&${shareDataStr}`
const hmac = CryptoJS.HmacSHA1(totalStr, "xxxxxxxxxxxxxxxxxx"); //xxx为QQ开放平台应用的APP Key
return hmac.toString(CryptoJS.enc.Base64);
}
平台注册信息填写注意
1. 安装包签名获取方法:
let bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO);
let fingerprint = bundleInfo.signatureInfo.fingerprint.toLowerCase() // 获取 fingerprint
得到fingerprint再MD5
2. AppLinking 获取方法:
使用App Linking实现应用间跳转-拉起指定应用-应用间跳转-Stage模型开发指导-Ability Kit(程序框架服务)-应用框架 - 华为HarmonyOS开发者 (huawei.com)
const req = new wxopensdk.SendMessageToWXReq()
req.callbackAbility = "包名.EntryAbility" //微信返回自己应用
注:分享前注意判断下APP是否安装
this.wxApi.isWXAppInstalled()
this.qqOpenApi.isQQInstalled()
更多关于HarmonyOS鸿蒙Next中成功接入微信与QQ好友分享功能的实战教程也可以访问 https://www.itying.com/category-93-b0.html
更多关于HarmonyOS鸿蒙Next中成功接入微信与QQ好友分享功能的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
在HarmonyOS鸿蒙Next中,成功接入微信与QQ好友分享功能,主要依赖于系统提供的社交分享API。开发者需在应用中集成相关SDK,并调用分享接口,实现文本、图片、链接等内容的一键分享。通过系统级优化,分享过程更加流畅,用户体验显著提升。同时,鸿蒙Next的分布式能力支持跨设备分享,进一步拓展了社交分享的应用场景。