npm i --save @elgibor-solution/fcm-custom-sound
- Version: 1.0.0
- GitHub: https://github.com/elgiborsolution/esolution-nativescript-plugins
- NPM: https://www.npmjs.com/package/%40elgibor-solution%2Ffcm-custom-sound
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 0
Nativescript FCM Custom Sound Notification
Custom notification sound of firebase cloud messaging (FCM). Currently only working on Android.
Installation
ns plugin add @elgibor-solution/fcm-custom-sound
Usage
# 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
Methods | Return Type | Description |
---|---|---|
customSound(options: CustomSoundOptions[]) |
void |
Plays custom sounds based on the provided configuration options. |
CustomSoundOptions Interface
Name | Type | Description |
---|---|---|
channelId |
string |
The channel identifier for the custom sound. |
audio |
string |
The audio file path or resource identifier for the custom sound. Currently only support .wav audio file. Audio file should be placed to folder: App_Resources/Android/src/main/assets/raw |
⚠️ Important!
To enable notification sounds to play in the background, the backend sending FCM must set the channel name or id according to the one specified by the Android application.
The audio file must be in .wav
format and placed in the App_Resources/Android/src/main/assets/raw
folder.
The audio
property in the CustomSoundOptions
interface should only contain the file name without the extension. For example, if the audio file is named notif.wav
, only notif
is required.
Authors
License
Apache License Version 2.0