@ionic-native/local-notifications

  • Version 5.36.0
  • Published
  • 114 kB
  • 1 dependency
  • MIT license

Install

npm i @ionic-native/local-notifications
yarn add @ionic-native/local-notifications
pnpm add @ionic-native/local-notifications

Overview

Ionic Native - Native plugins for ionic apps

Index

Variables

variable LocalNotifications

const LocalNotifications: LocalNotificationsOriginal;

    Classes

    class LocalNotificationsOriginal

    class LocalNotificationsOriginal extends IonicNativePlugin {}
    • Local Notifications This plugin allows you to display local notifications on the device

      import { LocalNotifications } from '@ionic-native/local-notifications/ngx';
      constructor(private localNotifications: LocalNotifications) { }
      ...
      // Schedule a single notification
      this.localNotifications.schedule({
      id: 1,
      text: 'Single ILocalNotification',
      sound: isAndroid? 'file://sound.mp3': 'file://beep.caf',
      data: { secret: key }
      });
      // Schedule multiple notifications
      this.localNotifications.schedule([{
      id: 1,
      text: 'Multi ILocalNotification 1',
      sound: isAndroid ? 'file://sound.mp3': 'file://beep.caf',
      data: { secret:key }
      },{
      id: 2,
      title: 'Local ILocalNotification Example',
      text: 'Multi ILocalNotification 2',
      icon: 'http://example.com/icon.png'
      }]);
      // Schedule delayed notification
      this.localNotifications.schedule({
      text: 'Delayed ILocalNotification',
      trigger: {at: new Date(new Date().getTime() + 3600)},
      led: 'FF0000',
      sound: null
      });

      ILocalNotification

    method addActions

    addActions: (groupId: any, actions: ILocalNotificationAction[]) => Promise<any>;
    • Adds a group of actions

      Parameter groupId

      The id of the action group

      Parameter actions

      The actions of this group

      Returns

      {Promise}

    method cancel

    cancel: (notificationId: any) => Promise<any>;
    • Cancels single or multiple notifications

      Parameter notificationId

      A single notification id, or an array of notification ids.

      Returns

      {Promise} Returns a promise when the notification is canceled

    method cancelAll

    cancelAll: () => Promise<any>;
    • Cancels all notifications

      Returns

      {Promise} Returns a promise when all notifications are canceled

    method clear

    clear: (notificationId: any) => Promise<any>;
    • Clears single or multiple notifications

      Parameter notificationId

      A single notification id, or an array of notification ids.

      Returns

      {Promise} Returns a promise when the notification had been cleared

    method clearAll

    clearAll: () => Promise<any>;
    • Clears all notifications

      Returns

      {Promise} Returns a promise when all notifications have cleared

    method fireEvent

    fireEvent: (eventName: string, args: any) => void;
    • Not an official interface, however its possible to manually fire events.

      Parameter eventName

      The name of the event. Available events: schedule, trigger, click, update, clear, clearall, cancel, cancelall. Custom event names are possible for actions

      Parameter args

      Optional arguments

    method fireQueuedEvents

    fireQueuedEvents: () => Promise<any>;
    • Fire queued events once the device is ready and all listeners are registered.

      Returns

      {Promise}

    method get

    get: (notificationId: any) => Promise<ILocalNotification>;
    • Get a notification object

      Parameter notificationId

      The id of the notification to get

      Returns

      {Promise}

    method getAll

    getAll: () => Promise<ILocalNotification[]>;
    • Get all notification objects

      Returns

      {Promise<ILocalNotification[]>}

    method getAllScheduled

    getAllScheduled: () => Promise<ILocalNotification[]>;
    • Get all scheduled notification objects

      Returns

      {Promise<Array>}

    method getAllTriggered

    getAllTriggered: () => Promise<ILocalNotification[]>;
    • Get all triggered notification objects

      Returns

      {Promise<Array>}

    method getDefaults

    getDefaults: () => Promise<any>;
    • Gets the (platform specific) default settings.

      Returns

      {Promise} An object with all default settings

    method getIds

    getIds: () => Promise<number[]>;
    • Get all the notification ids

      Returns

      {Promise<Array>}

    method getScheduled

    getScheduled: (notificationId: any) => Promise<ILocalNotification>;
    • Get a scheduled notification object

      Parameter notificationId

      The id of the notification to get

      Returns

      {Promise}

    method getScheduledIds

    getScheduledIds: () => Promise<number[]>;
    • Get the ids of scheduled notifications

      Returns

      {Promise<number[]>} Returns a promise

    method getTriggered

    getTriggered: (notificationId: any) => Promise<ILocalNotification>;
    • Get a triggered notification object

      Parameter notificationId

      The id of the notification to get

      Returns

      {Promise}

    method getTriggeredIds

    getTriggeredIds: () => Promise<number[]>;
    • Get the ids of triggered notifications

      Returns

      {Promise<Array>}

    method getType

    getType: (id: number) => Promise<boolean>;
    • Get the type (triggered, scheduled) for the notification.

      Parameter id

      The ID of the notification.

    method hasActions

    hasActions: (groupId: any) => Promise<boolean>;
    • Checks if a group of actions is defined

      Parameter groupId

      The id of the action group

      Returns

      {Promise} Whether the group is defined

    method hasPermission

    hasPermission: () => Promise<boolean>;
    • Informs if the app has the permission to show notifications.

      Returns

      {Promise}

    method hasType

    hasType: (id: number, type: string) => Promise<boolean>;
    • Check if a notification has a given type.

      Parameter id

      The ID of the notification.

      Parameter type

      The type of the notification.

      Returns

      {Promise}

    method isPresent

    isPresent: (notificationId: number) => Promise<boolean>;
    • Checks presence of a notification

      Parameter notificationId

      Returns

      {Promise}

    method isScheduled

    isScheduled: (notificationId: number) => Promise<boolean>;
    • Checks is a notification is scheduled

      Parameter notificationId

      Returns

      {Promise}

    method isTriggered

    isTriggered: (notificationId: number) => Promise<boolean>;
    • Checks if a notification is triggered

      Parameter notificationId

      Returns

      {Promise}

    method on

    on: (eventName: string) => Observable<any>;
    • Sets a callback for a specific event

      Parameter eventName

      The name of the event. Available events: schedule, trigger, click, update, clear, clearall, cancel, cancelall. Custom event names are possible for actions {Observable}

    method removeActions

    removeActions: (groupId: any) => Promise<any>;
    • Removes a group of actions

      Parameter groupId

      The id of the action group

      Returns

      {Promise}

    method requestPermission

    requestPermission: () => Promise<boolean>;
    • Request permission to show notifications if not already granted.

      Returns

      {Promise}

    method schedule

    schedule: (options?: ILocalNotification | ILocalNotification[]) => void;
    • Schedules a single or multiple notifications

      Parameter options

      optional

    method setDefaults

    setDefaults: (defaults: any) => Promise<any>;
    • Overwrites the (platform specific) default settings.

      Returns

      {Promise}

    method update

    update: (options?: ILocalNotification) => void;
    • Updates a previously scheduled notification. Must include the id in the options parameter.

      Parameter options

      optional

    Interfaces

    interface ILocalNotification

    interface ILocalNotification {}

      property actions

      actions?: string | ILocalNotificationAction[];
      • Actions id or actions

      property attachments

      attachments?: string[];
      • A list of image attachments

      property autoClear

      autoClear?: boolean;
      • ANDROID ONLY Make this notification automatically dismissed when the user touches it.

      property badge

      badge?: number;
      • The number currently set as the badge of the app icon in Springboard (iOS) or at the right-hand side of the local notification (Android) Default: 0 (which means don't show a number)

      property channel

      channel?: string;
      • ANDROID ONLY Specifies the channel the notification should be delivered on.

      property clock

      clock?: boolean | string;
      • ANDROID ONLY If and how the notification shall show the when date. Possbile values: boolean: true equals 'clock', false disable a watch/counter 'clock': Show the when date in the content view 'chronometer': Show a stopwatch

      property color

      color?: string;
      • ANDROID ONLY RGB value for the background color of the smallIcon. Default: Androids COLOR_DEFAULT, which will vary based on Android version.

      property data

      data?: any;
      • Arbitrary data, objects will be encoded to JSON string Default: null

      property defaults

      defaults?: number;
      • ANDROID ONLY Set the default notification options that will be used. The value should be one or more of the following fields combined with bitwise-or: DEFAULT_SOUND, DEFAULT_VIBRATE, DEFAULT_LIGHTS.

      property foreground

      foreground?: boolean;
      • Make this notification show when app in foreground.

      property group

      group?: string;
      • ANDROID ONLY If multiple notifications have the same group your app can present them as a single group.

      property groupSummary

      groupSummary?: boolean;
      • ANDROID ONLY If set to 'true' this notification could use 'summary' to summarize the contents of the whole group

      property icon

      icon?: string;
      • ANDROID ONLY Uri of the icon that is shown in the ticker and notification Default: res://icon

      property id

      id?: number;
      • A unique identifier required to clear, cancel, update or retrieve the local notification in the future Default: 0

      property launch

      launch?: boolean;
      • Specifies whether the a click on the notification causes the app to launch in the foreground

      property led

      led?:
      | {
      color: string;
      on: number;
      off: number;
      }
      | any[]
      | boolean
      | string;
      • ANDROID ONLY Define the blinking of the LED on the device. If set to true, the LED will blink in the default color with timings for on and off set to 1000 ms. If set to a string, the LED will blink in this ARGB value with timings for on and off set to 1000 ms. If set to an array, the value of the key 0 will be used as the color, the value of the key 1 will be used as the 'on' timing, the value of the key 2 will be used as the 'off' timing

      property lockscreen

      lockscreen?: boolean;
      • ANDROID ONLY If set to true the notification will be show in its entirety on all lockscreens. If set to false it will not be revealed on a secure lockscreen.

      property mediaSession

      mediaSession?: string;
      • ANDROID ONLY Set the token for the media session

      property number

      number?: number;
      • ANDROID ONLY Sets the number of items this notification represents.

      property priority

      priority?: number;
      • Notification priority. Integers between -2 and 2, whereas -2 is minimum and 2 is maximum priority

      property progressBar

      progressBar?: ILocalNotificationProgressBar | boolean;
      • Shows a progress bar Setting a boolean is a shortcut for {enabled: true/false} respectively

      property silent

      silent?: boolean;
      • Is a silent notification

      property smallIcon

      smallIcon?: string;
      • ANDROID ONLY Uri of the resource (only res://) to use in the notification layouts. Different classes of devices may return different sizes Default: res://ic_popup_reminder

      property sound

      sound?: string;
      • Uri of the file containing the sound to play when an alert is displayed Default: res://platform_default

      property sticky

      sticky?: boolean;
      • ANDROID ONLY Set whether this is an "ongoing" notification. Ongoing notifications cannot be dismissed by the user, so your application or service must take care of canceling them.

      property summary

      summary?: string;
      • ANDROID ONLY Summary of the whole notification group. Should be used in conjuntion with 'groupSummary' set to true

      property text

      text?: string | string[];
      • Second row of the notification Default: Empty string

      property timeoutAfter

      timeoutAfter?: number | false;
      • ANDROID ONLY Specifies a duration in milliseconds after which this notification should be canceled, if it is not already canceled.

      property title

      title?: string;
      • First row of the notification Default: Empty string (iOS) or the app name (Android)

      property trigger

      trigger?: ILocalNotificationTrigger;
      • When to trigger the notification

      property vibrate

      vibrate?: boolean;
      • ANDROID ONLY Use the default notification vibrate.

      property wakeup

      wakeup?: boolean;
      • ANDROID ONLY Wakeup the device. (default is true)

      interface ILocalNotificationAction

      interface ILocalNotificationAction {}
      • Notification action

        See Also

        • https://github.com/katzer/cordova-plugin-local-notifications#actions

      property choices

      choices?: string[];
      • ANDROID ONLY An array of pre-defined choices for users input

      property editable

      editable?: boolean;
      • ANDROID ONLY Specifies whether the user can provide arbitrary text values

      property foreground

      foreground?: boolean;
      • Make this notification show when app in foreground.

      property icon

      icon?: string;
      • The resource path of the action icon

      property id

      id?: string;
      • The id of the action is used as the event name in the listener function

      property launch

      launch?: boolean;
      • Specifies whether the action causes the app to launch in the foreground

      property needsAuth

      needsAuth?: boolean;
      • Specifies whether the action requires that the user’s device be unlocked. When the user selects an action with this option, the system prompts the user to unlock the device

      property submitTitle

      submitTitle?: string;
      • IOS ONLY The title of the text input button that is displayed to the user.

      property title

      title?: string;
      • The title of the notification message

      property type

      type?: ILocalNotificationActionType;
      • The type of the action. If omitted 'button' is used.

      property ui

      ui?: string;
      • If the value is 'decline' the action is displayed with special highlighting to indicate that it performs a destructive task

      interface ILocalNotificationEvery

      interface ILocalNotificationEvery {}

        property day

        day?: number;
        • The day.

        property hour

        hour?: number;
        • The hour.

        property minute

        minute?: number;
        • The minute.

        property month

        month?: number;
        • The month.

        property quarter

        quarter?: number;
        • The quarter.

        property week

        week?: number;
        • The week of yeaday of the ardinal week.

        property weekday

        weekday?: number;
        • The day of week.

        property weekdayOrdinal

        weekdayOrdinal?: number;
        • The day of the ordinal week.

        property weekOfMonth

        weekOfMonth?: number;
        • The week of month.

        property year

        year?: number;
        • The year.

        interface ILocalNotificationProgressBar

        interface ILocalNotificationProgressBar {}

          property description

          description?: string;
          • WINDOWS ONLY Gets or sets an optional string to be displayed instead of the default percentage string. If this isn't provided, something like "70%" will be displayed.

          property enabled

          enabled?: boolean;
          • Is the progress bar enabled?

          property indeterminate

          indeterminate?: boolean;
          • ANDROID ONLY Show an indeterminate progress bar

          property maxValue

          maxValue?: number;
          • ANDROID ONLY The maximum value (default is 100)

          property status

          status?: string;
          • WINDOWS ONLY Sets the status (required), which is displayed underneath the progress bar on the left. This string should reflect the status of the operation, like "Downloading..." or "Installing..."

          property value

          value?: number;
          • The current value

          interface ILocalNotificationTrigger

          interface ILocalNotificationTrigger {}

            property after

            after?: Date;
            • Only for "match"

            property at

            at?: Date;
            • The date and time when the system should deliver the local notification. If the specified value is nil or is a date in the past, the local notification is delivered immediately. Default: now ~ new Date()

            property before

            before?: Date;
            • The end of the repeating notification

            property center

            center?: number[];
            • IOS ONLY Center of the location Latitude and Longitude values

            property count

            count?: number;
            • Amount of units

            property every

            every?: ELocalNotificationTriggerUnit | ILocalNotificationEvery;
            • The unit

            property firstAt

            firstAt?: Date;
            • The date and time when the system should deliver the local notification. If the specified value is nil or is a date in the past, the local notification is delivered immediately. Only for "repeat" Default: now ~ new Date()

            property in

            in?: number;
            • Amount of units

            property notifyOnEntry

            notifyOnEntry?: boolean;
            • IOS ONLY Trigger on entry of the location

            property notifyOnExit

            notifyOnExit?: boolean;
            • IOS ONLY Trigger on exit of the location

            property radius

            radius?: number;
            • IOS ONLY Radius in meters

            property single

            single?: boolean;
            • IOS ONLY Trigger only once?

            property unit

            unit?: ELocalNotificationTriggerUnit;
            • Unit

            Enums

            enum ELocalNotificationTriggerUnit

            enum ELocalNotificationTriggerUnit {
            SECOND = 'second',
            MINUTE = 'minute',
            HOUR = 'hour',
            DAY = 'day',
            WEEK = 'week',
            MONTH = 'month',
            QUARTER = 'quarter',
            YEAR = 'year',
            WEEKDAY = 'weekday',
            WEEKDAY_ORDINAL = 'weekdayOrdinal',
            WEEK_OF_MONTH = 'weekOfMonth',
            }

              member DAY

              DAY = 'day'

                member HOUR

                HOUR = 'hour'

                  member MINUTE

                  MINUTE = 'minute'

                    member MONTH

                    MONTH = 'month'

                      member QUARTER

                      QUARTER = 'quarter'

                        member SECOND

                        SECOND = 'second'

                          member WEEK

                          WEEK = 'week'

                            member WEEK_OF_MONTH

                            WEEK_OF_MONTH = 'weekOfMonth'

                              member WEEKDAY

                              WEEKDAY = 'weekday'

                                member WEEKDAY_ORDINAL

                                WEEKDAY_ORDINAL = 'weekdayOrdinal'

                                  member YEAR

                                  YEAR = 'year'

                                    enum ILocalNotificationActionType

                                    enum ILocalNotificationActionType {
                                    INPUT = 'input',
                                    BUTTON = 'button',
                                    }

                                      member BUTTON

                                      BUTTON = 'button'

                                        member INPUT

                                        INPUT = 'input'

                                          Package Files (1)

                                          Dependencies (1)

                                          Dev Dependencies (0)

                                          No dev dependencies.

                                          Peer Dependencies (2)

                                          Badge

                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@ionic-native/local-notifications.

                                          • Markdown
                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@ionic-native/local-notifications)
                                          • HTML
                                            <a href="https://www.jsdocs.io/package/@ionic-native/local-notifications"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>