File

src/app/services/local-notification/local-notification.service.ts

Index

Properties

Constructor

constructor(localNotification: LocalNotifications)
Parameters :
Name Type Optional
localNotification LocalNotifications No

Properties

createANotification
Default value : () => {...}

Creating a notification which will be visible with the experience of native OS

Parameters :
Name Description
id

This will be a unique id for the message

title

This will be the title of the notification

text

This will be the body of the notification

icon

The link of the icon of the notification

import { Injectable } from '@angular/core';
import { LocalNotifications } from '@ionic-native/local-notifications/ngx';

@Injectable({
  providedIn: 'root'
})
export class LocalNotificationService {
  constructor(private localNotification: LocalNotifications) {}

  /**
   * Creating a notification which will be visible with the experience of native OS
   * @param id This will be a unique id for the message
   * @param title This will be the title of the notification
   * @param text This will be the body of the notification
   * @param icon The link of the icon of the notification
   */
  createANotification = (title: string, text: string) => {
    const id = Math.random() * 1000;
    this.localNotification.schedule([
      {
        id,
        text,
        title
      }
    ]);
  };
}

result-matching ""

    No results matching ""