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

@capacitor/local-notifications

Package Overview
Dependencies
Maintainers
9
Versions
641
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 0.5.1 to 0.6.0

18

CHANGELOG.md

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

# [0.6.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/local-notifications@0.5.1...@capacitor/local-notifications@0.6.0) (2021-03-10)
### Bug Fixes
* **local-notification:** Throw unavailable if Notification API not supported ([#285](https://github.com/ionic-team/capacitor-plugins/issues/285)) ([a90a88b](https://github.com/ionic-team/capacitor-plugins/commit/a90a88b217f5fa2a257416050afb476dd84d8051))
* **local-notifications:** Adding check for `new Notification` support ([#295](https://github.com/ionic-team/capacitor-plugins/issues/295)) ([a806f22](https://github.com/ionic-team/capacitor-plugins/commit/a806f22577209322bdc93ef7fe5490d3b0b6e42f))
### Features
* **local-notifications:** Adding summary text to grouped notifications ([#296](https://github.com/ionic-team/capacitor-plugins/issues/296)) ([f625bd2](https://github.com/ionic-team/capacitor-plugins/commit/f625bd28bc00dbd0b51d7bdecf5e6f3077dcc7a9))
* **local-notifications:** Support for Big Text and Inbox Notification Style ([#280](https://github.com/ionic-team/capacitor-plugins/issues/280)) ([dc96ef9](https://github.com/ionic-team/capacitor-plugins/commit/dc96ef923725f5b53346431d35f82d5ff13f4e17))
## [0.5.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/local-notifications@0.5.0...@capacitor/local-notifications@0.5.1) (2021-03-02)

@@ -8,0 +26,0 @@

import type { PermissionState, PluginListenerHandle } from '@capacitor/core';
declare module '@capacitor/cli' {
interface PluginsConfig {
/**
* On Android, the Local Notifications can be configured with the following options:
*/
LocalNotifications?: {

@@ -15,2 +18,3 @@ /**

* @since 1.0.0
* @example "ic_stat_icon_config_sample"
*/

@@ -24,2 +28,3 @@ smallIcon?: string;

* @since 1.0.0
* @example "#488AFF"
*/

@@ -36,2 +41,3 @@ iconColor?: string;

* @since 1.0.0
* @example "beep.wav"
*/

@@ -441,2 +447,16 @@ sound?: string;

/**
* Sets a multiline text block for display in a big text notification style.
*
* @since 1.0.0
*/
largeBody?: string;
/**
* Used to set the summary text detail in inbox and big text notification styles.
*
* Only available for Android.
*
* @since 1.0.0
*/
summaryText?: string;
/**
* The notification identifier.

@@ -484,2 +504,14 @@ *

/**
* Set a large icon for notifications.
*
* Icons should be placed in your app's `res/drawable` folder. The value for
* this option should be the drawable resource ID, which is the filename
* without an extension.
*
* Only available for Android.
*
* @since 1.0.0
*/
largeIcon?: string;
/**
* Set the color of the notification icon.

@@ -596,2 +628,12 @@ *

autoCancel?: boolean;
/**
* Sets a list of strings for display in an inbox style notification.
*
* Up to 5 strings are allowed.
*
* Only available for Android.
*
* @since 1.0.0
*/
inboxList?: string[];
}

@@ -598,0 +640,0 @@ /**

1

dist/esm/web.d.ts

@@ -16,2 +16,3 @@ import type { PermissionState } from '@capacitor/core';

checkPermissions(): Promise<PermissionStatus>;
protected hasNotificationSupport: () => boolean;
protected transformNotificationPermission(permission: NotificationPermission): PermissionState;

@@ -18,0 +19,0 @@ protected sendPending(): void;

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

this.pending = [];
this.hasNotificationSupport = () => {
if (!('Notification' in window) || !Notification.requestPermission) {
return false;
}
if (Notification.permission !== 'granted') {
// don't test for `new Notification` if permission has already been granted
// otherwise this sends a real notification on supported browsers
try {
new Notification('');
}
catch (e) {
if (e.name == 'TypeError') {
return false;
}
}
}
return true;
};
}

@@ -18,2 +36,5 @@ async createChannel() {

async schedule(options) {
if (!this.hasNotificationSupport()) {
throw this.unavailable('Notifications not supported in this browser.');
}
for (const notification of options.notifications) {

@@ -46,2 +67,5 @@ this.sendNotification(notification);

async requestPermissions() {
if (!this.hasNotificationSupport()) {
throw this.unavailable('Notifications not supported in this browser.');
}
const display = this.transformNotificationPermission(await Notification.requestPermission());

@@ -51,2 +75,5 @@ return { display };

async checkPermissions() {
if (!this.hasNotificationSupport()) {
throw this.unavailable('Notifications not supported in this browser.');
}
const display = this.transformNotificationPermission(Notification.permission);

@@ -53,0 +80,0 @@ return { display };

@@ -15,2 +15,20 @@ 'use strict';

this.pending = [];
this.hasNotificationSupport = () => {
if (!('Notification' in window) || !Notification.requestPermission) {
return false;
}
if (Notification.permission !== 'granted') {
// don't test for `new Notification` if permission has already been granted
// otherwise this sends a real notification on supported browsers
try {
new Notification('');
}
catch (e) {
if (e.name == 'TypeError') {
return false;
}
}
}
return true;
};
}

@@ -27,2 +45,5 @@ async createChannel() {

async schedule(options) {
if (!this.hasNotificationSupport()) {
throw this.unavailable('Notifications not supported in this browser.');
}
for (const notification of options.notifications) {

@@ -55,2 +76,5 @@ this.sendNotification(notification);

async requestPermissions() {
if (!this.hasNotificationSupport()) {
throw this.unavailable('Notifications not supported in this browser.');
}
const display = this.transformNotificationPermission(await Notification.requestPermission());

@@ -60,2 +84,5 @@ return { display };

async checkPermissions() {
if (!this.hasNotificationSupport()) {
throw this.unavailable('Notifications not supported in this browser.');
}
const display = this.transformNotificationPermission(Notification.permission);

@@ -62,0 +89,0 @@ return { display };

@@ -12,2 +12,20 @@ var capacitorHaptics = (function (exports, core) {

this.pending = [];
this.hasNotificationSupport = () => {
if (!('Notification' in window) || !Notification.requestPermission) {
return false;
}
if (Notification.permission !== 'granted') {
// don't test for `new Notification` if permission has already been granted
// otherwise this sends a real notification on supported browsers
try {
new Notification('');
}
catch (e) {
if (e.name == 'TypeError') {
return false;
}
}
}
return true;
};
}

@@ -24,2 +42,5 @@ async createChannel() {

async schedule(options) {
if (!this.hasNotificationSupport()) {
throw this.unavailable('Notifications not supported in this browser.');
}
for (const notification of options.notifications) {

@@ -52,2 +73,5 @@ this.sendNotification(notification);

async requestPermissions() {
if (!this.hasNotificationSupport()) {
throw this.unavailable('Notifications not supported in this browser.');
}
const display = this.transformNotificationPermission(await Notification.requestPermission());

@@ -57,2 +81,5 @@ return { display };

async checkPermissions() {
if (!this.hasNotificationSupport()) {
throw this.unavailable('Notifications not supported in this browser.');
}
const display = this.transformNotificationPermission(Notification.permission);

@@ -59,0 +86,0 @@ return { display };

16

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

@@ -47,7 +47,7 @@ "main": "dist/plugin.cjs.js",

"devDependencies": {
"@capacitor/android": "3.0.0-beta.6",
"@capacitor/cli": "3.0.0-beta.6",
"@capacitor/core": "3.0.0-beta.6",
"@capacitor/docgen": "0.0.15",
"@capacitor/ios": "3.0.0-beta.6",
"@capacitor/android": "3.0.0-rc.0",
"@capacitor/cli": "3.0.0-rc.0",
"@capacitor/core": "3.0.0-rc.0",
"@capacitor/docgen": "0.0.16",
"@capacitor/ios": "3.0.0-rc.0",
"@ionic/eslint-config": "^0.3.0",

@@ -65,3 +65,3 @@ "@ionic/prettier-config": "~1.0.1",

"peerDependencies": {
"@capacitor/core": "^3.0.0-beta.6"
"@capacitor/core": "3.0.0-rc.0"
},

@@ -84,3 +84,3 @@ "prettier": "@ionic/prettier-config",

},
"gitHead": "c704ab6c24723c3f46aac07bc949aac00ca631cd"
"gitHead": "94a39a9300beb941a43ba30d6505d9fefaff0b98"
}

@@ -14,8 +14,17 @@ # @capacitor/local-notifications

<docgen-config>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
On Android, the Local Notifications can be configured with the following options:
- `smallIcon`: It allows you to set the default icon for the local notification.
- `iconColor`: It allows you to set the default color for the local notification icon.
- `sound`: It allows you to set the default notification sound. On Android 26+ it sets the default channel sound and can’t be changed unless the app is uninstalled.
| Prop | Type | Description | Since |
| --------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **`smallIcon`** | <code>string</code> | Set the default status bar icon for notifications. Icons should be placed in your app's `res/drawable` folder. The value for this option should be the drawable resource ID, which is the filename without an extension. Only available for Android. | 1.0.0 |
| **`iconColor`** | <code>string</code> | Set the default color of status bar icons for notifications. Only available for Android. | 1.0.0 |
| **`sound`** | <code>string</code> | Set the default notification sound for notifications. On Android 26+ it sets the default channel sound and can't be changed unless the app is uninstalled. Only available for Android. | 1.0.0 |
### Examples
In `capacitor.config.json`:
```json

@@ -33,2 +42,24 @@ {

In `capacitor.config.ts`:
```ts
/// <reference types="@capacitor/local-notifications" />
import { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = {
plugins: {
LocalNotifications: {
smallIcon: "ic_stat_icon_config_sample",
iconColor: "#488AFF",
sound: "beep.wav",
},
},
};
export = config;
```
</docgen-config>
## Doze

@@ -318,2 +349,4 @@

| **`body`** | <code>string</code> | The body of the notification, shown below the title. | 1.0.0 |
| **`largeBody`** | <code>string</code> | Sets a multiline text block for display in a big text notification style. | 1.0.0 |
| **`summaryText`** | <code>string</code> | Used to set the summary text detail in inbox and big text notification styles. Only available for Android. | 1.0.0 |
| **`id`** | <code>number</code> | The notification identifier. | 1.0.0 |

@@ -323,2 +356,3 @@ | **`schedule`** | <code><a href="#schedule">Schedule</a></code> | <a href="#schedule">Schedule</a> this notification for a later time. | 1.0.0 |

| **`smallIcon`** | <code>string</code> | Set a custom status bar icon. If set, this overrides the `smallIcon` option from Capacitor configuration. Icons should be placed in your app's `res/drawable` folder. The value for this option should be the drawable resource ID, which is the filename without an extension. Only available for Android. | 1.0.0 |
| **`largeIcon`** | <code>string</code> | Set a large icon for notifications. Icons should be placed in your app's `res/drawable` folder. The value for this option should be the drawable resource ID, which is the filename without an extension. Only available for Android. | 1.0.0 |
| **`iconColor`** | <code>string</code> | Set the color of the notification icon. Only available for Android. | 1.0.0 |

@@ -335,2 +369,3 @@ | **`attachments`** | <code>Attachment[]</code> | Set attachments for this notification. | 1.0.0 |

| **`autoCancel`** | <code>boolean</code> | If true, the notification is canceled when the user clicks on it. Calls `setAutoCancel()` on [`NotificationCompat.Builder`](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder) with the provided value. Only available for Android. | 1.0.0 |
| **`inboxList`** | <code>string[]</code> | Sets a list of strings for display in an inbox style notification. Up to 5 strings are allowed. Only available for Android. | 1.0.0 |

@@ -337,0 +372,0 @@

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

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