npm i --save @elgibor-solution/fcm-custom-sound
- 版本: 1.0.0
- GitHub: https://github.com/elgiborsolution/esolution-nativescript-plugins
- NPM: https://npmjs.net.cn/package/%40elgibor-solution%2Ffcm-custom-sound
- 下载量
- 前一天: 0
- 上周: 1
- 上个月: 4
Nativescript FCM 自定义声音通知
firebase云消息(FCM)的自定义通知声音。 目前仅适用于Android。
安装
ns plugin add @elgibor-solution/fcm-custom-sound
用法
# app.component.ts
import { customSound, CustomSoundOptions } from '@elgibor-solution/fcm-custom-sound';
const options: CustomSoundOptions = [
{ channelId: 'channel_1', audio: 'notif' },
{ channelId: 'channel_2', audio: 'notif2' }
];
customSound(options);
API
方法 | 返回类型 | 描述 |
---|---|---|
customSound(options: CustomSoundOptions[]) |
void |
根据提供的配置选项播放自定义声音。 |
CustomSoundOptions 接口
名称 | 类型 | 描述 |
---|---|---|
channelId |
string |
自定义声音的通道标识符。 |
audio |
string |
自定义声音的音频文件路径或资源标识符。目前仅支持.wav 音频文件。音频文件应放置在文件夹:App_Resources/Android/src/main/assets/raw |
⚠️ 重要!
为了在后台播放通知声音,发送FCM的后端必须根据Android应用程序指定的设置设置通道名称或ID。
音频文件必须为.wav
格式,并放置在App_Resources/Android/src/main/assets/raw
文件夹中。在CustomSoundOptions
接口中的audio
属性应只包含文件名,不带扩展名。例如,如果音频文件名为notif.wav
,则只需要notif
。
作者
许可
Apache许可证版本2.0