Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Native Ringtonesβ

Improve this doc

This plugin is still in beta stage and may not work as expected. Please submit any issues to the plugin repo.

The plugin helps get the native ringtones list on Android or IOS devices. And you can also use this plugin to play or stop the native ringtones and custom ringtones(added in the www folder).

Repo: https://github.com/TongZhangzt/cordova-plugin-native-ringtones

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-native-ringtones
    $ npm install --save @ionic-native/native-ringtones@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { NativeRingtones } from '@ionic-native/native-ringtones';


constructor(private ringtones: NativeRingtones) { }

...
this.ringtones.getRingtone().then((ringtones) => { console.log(ringtones); });

this.ringtones.playRingtone('assets/ringtones/sound_1.caf');

this.ringtones.stopRingtone('assets/ringtones/sound_1.caf');

Instance Members

getRingtone()

Get the ringtone list of the device

Returns: Promise<any> Returns a promise that resolves when ringtones found successfully

playRingtone(ringtoneUri)

This function starts playing the ringtone

Param Type Details
ringtoneUri string

The path to the ringtone file

Returns: Promise<any> Returns a promise

stopRingtone(ringtoneUri)

This function stops playing the ringtone

Param Type Details
ringtoneUri string

The path to the ringtone file

Returns: Promise<any> Returns a promise

API

Native

General