文档

移动推送SDK合规说明(Harmony)

更新时间:

说明

根据《个人信息保护法》、《数据安全法》、《网络安全法》等法律法规和监管部门规章要求,App开发运营者(以下简称为“开发者”)在提供网络产品服务时应尊重和保护最终用户的个人信息,不得违法违规收集使用个人信息。为帮助开发者在使用移动推送SDK的过程中更好地落实用户个人信息保护相关要求,避免出现侵害最终用户个人信息权益的情形,特制定本合规使用说明。

一、移动推送SDK申请系统权限说明

权限内容

是否必选

权限用途

INTERNET

允许SDK联网的最基础权限,用于建立推送长连接,实现推送能力。

GET_NETWORK_INFO

检测网络状态,用于判断网络连接状态,在网络恢复时,恢复连接。

二、移动推送SDK功能及相关个人信息

功能

采集个人信息字段

个人信息采集目的

功能配置方案及示例

推送功能

(基础功能)

设备标识信息(手机品牌、型号、系统版本)

提供推送精准度和可靠性

基础功能,必要信息

三、移动推送SDK可选个人信息字段配置方案

可选个人信息字段

个人信息采集目的

功能配置方案及示例

手机号

如果需要使用移动推送的短信联动能力,则需要获取用户手机号并做绑定。

通过aliyunPush.bindPhoneNumber(number, callback)配置。默认不绑定手机号。

四、移动推送SDK合规初始化配置方案

/**
 * 推送SDK接口
 */
export interface IPushService {
  /**
   * 初始化配置
   * @param config
   */
  init(config: PushConfig): void;

  /**
   * 建连、注册设备
   * 您务必确保用户同意《隐私政策》之后再调用register(...)方法。
   * @param callback
   */
  register(callback: AsyncCallback): void;
  register(): Promise<void>;
}
重要
  • aliyunPush.init(...)方法可以在用户同意《隐私政策》前调用。

  • 您务必确保用户同意《隐私政策》之后再调用aliyunPush.register(...)方法。

代码示例

import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI';
import {
  aliyunPush,
  BasePushData,
  Channel,
  IPushListener,
  PushMessage,
  PushNotification,
  PushNotificationHandler
} from '@aliyun/push';
import { pushService } from '@kit.PushKit';

/**
 * 自定义的推送回调接口实现
 */
class MyPushListener implements IPushListener {
  onReceiveNotification(data: PushNotification): boolean {
    // 处理推送通知
    return false;
  }

  onShowNotification(data: PushNotification): void {
    // 处理通知展示事件
  }

  onReceiveMessage(data: PushMessage): void {
    // 处理推送消息
  }
}

/**
 * 自定义推送数据的处理类
 */
class MyPushNotificationHandler implements PushNotificationHandler {
  onClickNotification(data: PushNotification | BasePushData, from: Channel): void {
    // 由用户点击通知拉起的页面,获取推送数据,处理业务逻辑
  }

  noPushData(): void {
    // 不是由用户点击通知拉的页面
  }
}

export default class EntryAbility extends UIAbility {
  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {

    // ************* 初始化SDK begin *************
    aliyunPush.init({
      appKey: '请填入在准备工作中查询的应用AppKey',
      appSecret: '请填入在准备工作中查询的应用AppSecret',
      context: this.context,
    })
    // ************* 初始化SDK end *************

    // ************* 设置推送回调接口 begin *************
    aliyunPush.setPushListener(new MyPushListener());
    // ************* 设置推送回调接口 end *************

    // ************* 调用推送通知点击处理接口 begin *************
    aliyunPush.handleClickNotification(want, new MyPushNotificationHandler())
    // ************* 调用推送通知点击处理接口 end *************

    // 建议应用通过本地状态保存用户是否同意过隐私政策,同意过在初始化时,执行register方法
    if(hasSignedAgreement) {
      this.registerPush();
    } else {
      // 没有同意过,等用户同意时,再执行register方法。
    }
    
  }

  private async registerPush() {
    // ************* 注册设备获取设备ID begin *************
    await aliyunPush.register();
    const deviceId = aliyunPush.getDeviceId();
    // ************* 注册设备获取设备ID end *************

    const pushToken = await pushService.getToken();
    // ************* 注册鸿蒙PushToken begin *************
    await aliyunPush.registerThirdToken(pushToken);
    // ************* 注册鸿蒙PushToken end *************
  }

  onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void {
    // ************* 调用推送通知点击处理接口 begin *************
    aliyunPush.handleClickNotification(want, new MyPushNotificationHandler())
    // ************* 调用推送通知点击处理接口 end *************
  }

  // 省略其它代码
}