Text Message Notifications

更新时间:
复制 MD 格式

This topic describes how to use the HarmonyOS software development kit (SDK) to integrate the text message filter interaction feature.

Feature description

For more information, see Text message filter interaction configuration.

The SDK provides methods to attach and detach phone numbers to support the text message filter interaction feature.

Attach a phone number

Use the bindPhoneNumber method to attach a phone number. The following code is an example:

import { aliyunPush } from '@aliyun/push';

aliyunPush.bindPhoneNumber(`139xxxxxxxx`, (err) => {
  if (err) {
    console.error(`Failed to attach the phone number. Error code: ${err.code}. Error message: ${err.message}`);
    return;
  }
  console.info(`Phone number attached successfully.`);
})

Detach a phone number

Use the unbindPhoneNumber method to detach a phone number. The following code is an example:

import { aliyunPush } from '@aliyun/push';

aliyunPush.unbindPhoneNumber((err) => {
  if (err) {
    console.error(`Failed to detach the phone number. Error code: ${err.code}. Error message: ${err.message}`);
    return;
  }
  console.info(`Phone number detached successfully.`);
})