Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@capacitor/local-notifications

Package Overview
Dependencies
Maintainers
12
Versions
636
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor/local-notifications - npm Package Compare versions

Comparing version 4.0.0-beta.0 to 4.0.0-beta.2

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [4.0.0-beta.2](https://github.com/ionic-team/capacitor-plugins/compare/4.0.0-beta.0...4.0.0-beta.2) (2022-07-08)
### Features
* **local-notifications:** Add delivered notification handling ([#1060](https://github.com/ionic-team/capacitor-plugins/issues/1060)) ([0a89dc9](https://github.com/ionic-team/capacitor-plugins/commit/0a89dc97407685a7f1ec97532af304115fea7a0f))
# 4.0.0-beta.0 (2022-06-27)

@@ -8,0 +19,0 @@

123

dist/esm/definitions.d.ts

@@ -84,2 +84,20 @@ import type { PermissionState, PluginListenerHandle } from '@capacitor/core';

/**
* Get a list of notifications that are visible on the notifications screen.
*
* @since 4.0.0
*/
getDeliveredNotifications(): Promise<DeliveredNotifications>;
/**
* Remove the specified notifications from the notifications screen.
*
* @since 4.0.0
*/
removeDeliveredNotifications(delivered: DeliveredNotifications): Promise<void>;
/**
* Remove all the notifications from the notifications screen.
*
* @since 4.0.0
*/
removeAllDeliveredNotifications(): Promise<void>;
/**
* Create a notification channel.

@@ -565,3 +583,3 @@ *

*
* Only available for iOS 12+.
* Only available for iOS.
*

@@ -763,2 +781,105 @@ * @since 1.0.0

}
export interface DeliveredNotificationSchema {
/**
* The notification identifier.
*
* @since 4.0.0
*/
id: number;
/**
* The notification tag.
*
* Only available on Android.
*
* @since 4.0.0
*/
tag?: string;
/**
* The title of the notification.
*
* @since 4.0.0
*/
title: string;
/**
* The body of the notification, shown below the title.
*
* @since 4.0.0
*/
body: string;
/**
* The configured group of the notification.
*
*
* Only available for Android.
*
* @since 4.0.0
*/
group?: string;
/**
* If this notification is the summary for a group of notifications.
*
* Only available for Android.
*
* @since 4.0.0
*/
groupSummary?: boolean;
/**
* Any additional data that was included in the
* notification payload.
*
* Only available for Android.
*
* @since 4.0.0
*/
data?: any;
/**
* Extra data to store within this notification.
*
* Only available for iOS.
*
* @since 4.0.0
*/
extra?: any;
/**
* The attachments for this notification.
*
* Only available for iOS.
*
* @since 1.0.0
*/
attachments?: Attachment[];
/**
* Action type ssociated with this notification.
*
* Only available for iOS.
*
* @since 4.0.0
*/
actionTypeId?: string;
/**
* Schedule used to fire this notification.
*
* Only available for iOS.
*
* @since 4.0.0
*/
schedule?: Schedule;
/**
* Sound that was used when the notification was displayed.
*
* Only available for iOS.
*
* @since 4.0.0
*/
sound?: string;
}
export interface DeliveredNotifications {
/**
* List of notifications that are visible on the
* notifications screen.
*
* @since 1.0.0
*/
notifications: DeliveredNotificationSchema[];
}
export interface Channel {

@@ -765,0 +886,0 @@ /**

import { WebPlugin } from '@capacitor/core';
import type { PermissionState } from '@capacitor/core';
import type { EnabledResult, ListChannelsResult, LocalNotificationSchema, LocalNotificationsPlugin, PendingResult, PermissionStatus, ScheduleOptions, ScheduleResult } from './definitions';
import type { DeliveredNotifications, EnabledResult, ListChannelsResult, LocalNotificationSchema, LocalNotificationsPlugin, PendingResult, PermissionStatus, ScheduleOptions, ScheduleResult } from './definitions';
export declare class LocalNotificationsWeb extends WebPlugin implements LocalNotificationsPlugin {
protected pending: LocalNotificationSchema[];
protected deliveredNotifications: Notification[];
getDeliveredNotifications(): Promise<DeliveredNotifications>;
removeDeliveredNotifications(delivered: DeliveredNotifications): Promise<void>;
removeAllDeliveredNotifications(): Promise<void>;
createChannel(): Promise<void>;

@@ -7,0 +11,0 @@ deleteChannel(): Promise<void>;

@@ -6,2 +6,3 @@ import { WebPlugin } from '@capacitor/core';

this.pending = [];
this.deliveredNotifications = [];
this.hasNotificationSupport = () => {

@@ -26,2 +27,29 @@ if (!('Notification' in window) || !Notification.requestPermission) {

}
async getDeliveredNotifications() {
const deliveredSchemas = [];
for (const notification of this.deliveredNotifications) {
const deliveredSchema = {
title: notification.title,
id: parseInt(notification.tag),
body: notification.body,
};
deliveredSchemas.push(deliveredSchema);
}
return {
notifications: deliveredSchemas,
};
}
async removeDeliveredNotifications(delivered) {
for (const toRemove of delivered.notifications) {
const found = this.deliveredNotifications.find(n => n.tag === String(toRemove.id));
found === null || found === void 0 ? void 0 : found.close();
this.deliveredNotifications = this.deliveredNotifications.filter(() => !found);
}
}
async removeAllDeliveredNotifications() {
for (const notification of this.deliveredNotifications) {
notification.close();
}
this.deliveredNotifications = [];
}
async createChannel() {

@@ -118,5 +146,10 @@ throw this.unimplemented('Not implemented on web.');

body: notification.body,
tag: String(notification.id),
});
localNotification.addEventListener('click', this.onClick.bind(this, notification), false);
localNotification.addEventListener('show', this.onShow.bind(this, notification), false);
localNotification.addEventListener('close', () => {
this.deliveredNotifications = this.deliveredNotifications.filter(() => !this);
}, false);
this.deliveredNotifications.push(localNotification);
return localNotification;

@@ -123,0 +156,0 @@ }

@@ -30,2 +30,3 @@ 'use strict';

this.pending = [];
this.deliveredNotifications = [];
this.hasNotificationSupport = () => {

@@ -50,2 +51,29 @@ if (!('Notification' in window) || !Notification.requestPermission) {

}
async getDeliveredNotifications() {
const deliveredSchemas = [];
for (const notification of this.deliveredNotifications) {
const deliveredSchema = {
title: notification.title,
id: parseInt(notification.tag),
body: notification.body,
};
deliveredSchemas.push(deliveredSchema);
}
return {
notifications: deliveredSchemas,
};
}
async removeDeliveredNotifications(delivered) {
for (const toRemove of delivered.notifications) {
const found = this.deliveredNotifications.find(n => n.tag === String(toRemove.id));
found === null || found === void 0 ? void 0 : found.close();
this.deliveredNotifications = this.deliveredNotifications.filter(() => !found);
}
}
async removeAllDeliveredNotifications() {
for (const notification of this.deliveredNotifications) {
notification.close();
}
this.deliveredNotifications = [];
}
async createChannel() {

@@ -142,5 +170,10 @@ throw this.unimplemented('Not implemented on web.');

body: notification.body,
tag: String(notification.id),
});
localNotification.addEventListener('click', this.onClick.bind(this, notification), false);
localNotification.addEventListener('show', this.onShow.bind(this, notification), false);
localNotification.addEventListener('close', () => {
this.deliveredNotifications = this.deliveredNotifications.filter(() => !this);
}, false);
this.deliveredNotifications.push(localNotification);
return localNotification;

@@ -147,0 +180,0 @@ }

@@ -27,2 +27,3 @@ var capacitorLocalNotifications = (function (exports, core) {

this.pending = [];
this.deliveredNotifications = [];
this.hasNotificationSupport = () => {

@@ -47,2 +48,29 @@ if (!('Notification' in window) || !Notification.requestPermission) {

}
async getDeliveredNotifications() {
const deliveredSchemas = [];
for (const notification of this.deliveredNotifications) {
const deliveredSchema = {
title: notification.title,
id: parseInt(notification.tag),
body: notification.body,
};
deliveredSchemas.push(deliveredSchema);
}
return {
notifications: deliveredSchemas,
};
}
async removeDeliveredNotifications(delivered) {
for (const toRemove of delivered.notifications) {
const found = this.deliveredNotifications.find(n => n.tag === String(toRemove.id));
found === null || found === void 0 ? void 0 : found.close();
this.deliveredNotifications = this.deliveredNotifications.filter(() => !found);
}
}
async removeAllDeliveredNotifications() {
for (const notification of this.deliveredNotifications) {
notification.close();
}
this.deliveredNotifications = [];
}
async createChannel() {

@@ -139,5 +167,10 @@ throw this.unimplemented('Not implemented on web.');

body: notification.body,
tag: String(notification.id),
});
localNotification.addEventListener('click', this.onClick.bind(this, notification), false);
localNotification.addEventListener('show', this.onShow.bind(this, notification), false);
localNotification.addEventListener('close', () => {
this.deliveredNotifications = this.deliveredNotifications.filter(() => !this);
}, false);
this.deliveredNotifications.push(localNotification);
return localNotification;

@@ -144,0 +177,0 @@ }

4

package.json
{
"name": "@capacitor/local-notifications",
"version": "4.0.0-beta.0",
"version": "4.0.0-beta.2",
"description": "The Local Notifications API provides a way to schedule device notifications locally (i.e. without a server sending push notifications).",

@@ -83,3 +83,3 @@ "main": "dist/plugin.cjs.js",

},
"gitHead": "fd7db8285f72990522da0adc889514c9804b6dae"
"gitHead": "32240b675c12a774920c07a86b4483ecec7a9c8d"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc