Skip to content
Titanium SDK
Version13.0.1

You are reading 13.0.1. See this page in 13.4.1.

Titanium.Android.NotificationChannel

proxyAndroidsince 7.0.0

Extends Titanium.Proxy

Module for notification channels.

You can create a notification channel for each distinct type of notification you need to send.

To create a notification channel, use the Titanium.Android.createNotificationChannel method.

Further Reading:

Examples

Notification Channel Example

The following example shows how to create a notification with a channel.

var channel = Ti.Android.NotificationManager.createNotificationChannel({
        id: 'my_channel',
        name: 'TEST CHANNEL',
        importance: Ti.Android.IMPORTANCE_DEFAULT
    }),
    notification = Ti.Android.createNotification({
        icon: Ti.Android.R.drawable.ic_dialog_info,
        contentTitle: 'TITLE',
        contentText : 'This is a test',
        channelId: channel.id
    });

Ti.Android.NotificationManager.notify(100, notification);

Properties 16

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

bypassDnd

Boolean

Whether or not notifications posted to this channel can interrupt the user.

User visible description of this channel.

Whether notifications posted to this channel should display notification lights

Whether notification posted to this channel should vibrate.

groupId

String

Group id this channel belongs to.

id

String

The channel id specified for the notification channel.

The notification light color for notifications posted to this channel.

name

String

The visible name of this channel. The recommended maximum length is 40 characters; the value may be truncated if it is too long.

showBadge

Boolean

Whether notifications posted to this channel can appear as application icon badges in a Launcher.

sound

Stringsince 7.5.0

A URL to the sound to play.

The URL cannot refer to a file in the Resources directory, but it can refer to a file in the raw resources directory (Filesystem.resRawDirectory).

To create a raw resource, place the audio file in the platform/android/res/raw folder and reference it as:

notificationChannel.sound = Ti.Filesystem.resRawDirectory + 'my_sound.wav';

vibratePattern

Array<Number>

The vibration pattern for notifications posted to this channel.

Specify the pattern in milliseconds as an array. (e.g [100, 100, 100, 400, 400, 100, 100, 100])

Methods 4

Inherited from Titanium.Proxy

Adds the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

Name of the event.

event?Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Inherited from Titanium.Proxy

Removes the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.