操作步骤
步骤1:集成 TIMPush
// oh-package.json5 中配置集成包dependencies: {"@tencentcloud/timpush": "^VERSION","@tencentcloud/imsdk": "^VERSION",}
步骤2:注册推送
调用接口推送注册成功后,就可以收到离线推送通知了。
import { TIMPushListener, TIMPushManager, TIMPushMessage } from '@tencentcloud/timpush';TIMPushManager.getInstance().registerPush(context, IM 控制台证书 ID, 您的 sdkAppId, "客户端密钥").then((result) => {HiLog("registerPush success:", result.message);}).catch((error: Error) => {HiLog("registerPush failed", error.code, error.message);})
步骤3:消息触达统计配置
如果您需要统计触达数据,请按照如下完成配置:

回执地址:
https://api.im.qcloud.com/v3/offline_push_report/harmony步骤4:发送推送消息
步骤5:解析离线推送消息
收到推送消息后点击通知栏,组件会回调该点击事件和透传离线消息。
let pushListener: TIMPushListener = {onNotificationClicked: (data) => {HiLog("onNotificationClicked", data);}}TIMPushManager.getInstance().addPushListener(pushListener);
