@capacitor/local-notifications
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -6,2 +6,22 @@ # Change Log | ||
# [0.3.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/local-notifications@0.2.1...@capacitor/local-notifications@0.3.0) (2021-02-05) | ||
### Bug Fixes | ||
* **android:** fire localNotificationReceived event on Android ([#217](https://github.com/ionic-team/capacitor-plugins/issues/217)) ([d97682d](https://github.com/ionic-team/capacitor-plugins/commit/d97682d9f3d6f612993716c3bc35d3015c4e0c07)) | ||
* normalize use of integers for notification IDs ([#195](https://github.com/ionic-team/capacitor-plugins/issues/195)) ([b56e111](https://github.com/ionic-team/capacitor-plugins/commit/b56e1118227ee58d1872dbb32a18b8484290d3c7)) | ||
* **web:** fix scheduled notifications not being sent ([#220](https://github.com/ionic-team/capacitor-plugins/issues/220)) ([c8e92d6](https://github.com/ionic-team/capacitor-plugins/commit/c8e92d6a178f8b3278b1d3a9c364eb8120d28848)) | ||
### Features | ||
* **local-notifications:** add more info to pending notifications ([#211](https://github.com/ionic-team/capacitor-plugins/issues/211)) ([7c50487](https://github.com/ionic-team/capacitor-plugins/commit/7c50487d40836380a27bd4c8d3655d83e0c3a720)) | ||
* **local-notifications:** Fire local notifications while app is idle ([#237](https://github.com/ionic-team/capacitor-plugins/issues/237)) ([43380ef](https://github.com/ionic-team/capacitor-plugins/commit/43380efa8901adf9d669d0c1ef20038a2fd7df8e)) | ||
* **web:** implement ActionPerformed and Received events ([#219](https://github.com/ionic-team/capacitor-plugins/issues/219)) ([e062901](https://github.com/ionic-team/capacitor-plugins/commit/e062901fc2e55cf6b6dc1ab20258d80a0be8b2d9)) | ||
## [0.2.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/local-notifications@0.2.0...@capacitor/local-notifications@0.2.1) (2021-01-26) | ||
@@ -8,0 +28,0 @@ |
@@ -140,3 +140,3 @@ import type { PermissionState, PluginListenerHandle } from '@capacitor/core'; | ||
*/ | ||
id: string; | ||
id: number; | ||
} | ||
@@ -165,3 +165,3 @@ export interface ScheduleOptions { | ||
*/ | ||
notifications: LocalNotificationDescriptor[]; | ||
notifications: PendingLocalNotificationSchema[]; | ||
} | ||
@@ -394,2 +394,34 @@ export interface RegisterActionTypesOptions { | ||
} | ||
export interface PendingLocalNotificationSchema { | ||
/** | ||
* The title of the notification. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
title: string; | ||
/** | ||
* The body of the notification, shown below the title. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
body: string; | ||
/** | ||
* The notification identifier. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
id: number; | ||
/** | ||
* Schedule this notification for a later time. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
schedule?: Schedule; | ||
/** | ||
* Set extra data to store within this notification. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
extra?: any; | ||
} | ||
export interface LocalNotificationSchema { | ||
@@ -587,2 +619,12 @@ /** | ||
/** | ||
* Allow this notification to fire while in [Doze](https://developer.android.com/training/monitoring-device-state/doze-standby) | ||
* | ||
* Only available for Android 23+. | ||
* | ||
* Note that these notifications can only fire [once per 9 minutes, per app](https://developer.android.com/training/monitoring-device-state/doze-standby#assessing_your_app). | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
allowWhileIdle?: boolean; | ||
/** | ||
* Schedule a notification on particular interval(s). | ||
@@ -589,0 +631,0 @@ * |
import type { PermissionState } from '@capacitor/core'; | ||
import { WebPlugin } from '@capacitor/core'; | ||
import type { EnabledResult, ListChannelsResult, LocalNotificationSchema, LocalNotificationsPlugin, PermissionStatus, ScheduleOptions, ScheduleResult } from './definitions'; | ||
import type { EnabledResult, ListChannelsResult, LocalNotificationSchema, LocalNotificationsPlugin, PendingResult, PermissionStatus, ScheduleOptions, ScheduleResult } from './definitions'; | ||
export declare class LocalNotificationsWeb extends WebPlugin implements LocalNotificationsPlugin { | ||
@@ -10,3 +10,3 @@ protected pending: LocalNotificationSchema[]; | ||
schedule(options: ScheduleOptions): Promise<ScheduleResult>; | ||
getPending(): Promise<ScheduleResult>; | ||
getPending(): Promise<PendingResult>; | ||
registerActionTypes(): Promise<void>; | ||
@@ -21,2 +21,4 @@ cancel(pending: ScheduleResult): Promise<void>; | ||
protected buildNotification(notification: LocalNotificationSchema): Notification; | ||
protected onClick(notification: LocalNotificationSchema): void; | ||
protected onShow(notification: LocalNotificationSchema): void; | ||
} |
@@ -22,3 +22,3 @@ import { WebPlugin } from '@capacitor/core'; | ||
notifications: options.notifications.map(notification => ({ | ||
id: notification.id.toString(), | ||
id: notification.id, | ||
})), | ||
@@ -29,5 +29,3 @@ }; | ||
return { | ||
notifications: this.pending.map(notification => ({ | ||
id: notification.id.toString(), | ||
})), | ||
notifications: this.pending, | ||
}; | ||
@@ -39,3 +37,3 @@ } | ||
async cancel(pending) { | ||
this.pending = this.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id.toString())); | ||
this.pending = this.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id)); | ||
} | ||
@@ -87,10 +85,25 @@ async areEnabled() { | ||
}, diff); | ||
return; | ||
} | ||
this.buildNotification(notification); | ||
} | ||
buildNotification(notification) { | ||
return new Notification(notification.title, { | ||
const localNotification = new Notification(notification.title, { | ||
body: notification.body, | ||
}); | ||
localNotification.addEventListener('click', this.onClick.bind(this, notification), false); | ||
localNotification.addEventListener('show', this.onShow.bind(this, notification), false); | ||
return localNotification; | ||
} | ||
onClick(notification) { | ||
const data = { | ||
actionId: 'tap', | ||
notification, | ||
}; | ||
this.notifyListeners('localNotificationActionPerformed', data); | ||
} | ||
onShow(notification) { | ||
this.notifyListeners('localNotificationReceived', notification); | ||
} | ||
} | ||
//# sourceMappingURL=web.js.map |
@@ -31,3 +31,3 @@ 'use strict'; | ||
notifications: options.notifications.map(notification => ({ | ||
id: notification.id.toString(), | ||
id: notification.id, | ||
})), | ||
@@ -38,5 +38,3 @@ }; | ||
return { | ||
notifications: this.pending.map(notification => ({ | ||
id: notification.id.toString(), | ||
})), | ||
notifications: this.pending, | ||
}; | ||
@@ -48,3 +46,3 @@ } | ||
async cancel(pending) { | ||
this.pending = this.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id.toString())); | ||
this.pending = this.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id)); | ||
} | ||
@@ -96,9 +94,24 @@ async areEnabled() { | ||
}, diff); | ||
return; | ||
} | ||
this.buildNotification(notification); | ||
} | ||
buildNotification(notification) { | ||
return new Notification(notification.title, { | ||
const localNotification = new Notification(notification.title, { | ||
body: notification.body, | ||
}); | ||
localNotification.addEventListener('click', this.onClick.bind(this, notification), false); | ||
localNotification.addEventListener('show', this.onShow.bind(this, notification), false); | ||
return localNotification; | ||
} | ||
onClick(notification) { | ||
const data = { | ||
actionId: 'tap', | ||
notification, | ||
}; | ||
this.notifyListeners('localNotificationActionPerformed', data); | ||
} | ||
onShow(notification) { | ||
this.notifyListeners('localNotificationReceived', notification); | ||
} | ||
} | ||
@@ -105,0 +118,0 @@ |
@@ -28,3 +28,3 @@ var capacitorHaptics = (function (exports, core) { | ||
notifications: options.notifications.map(notification => ({ | ||
id: notification.id.toString(), | ||
id: notification.id, | ||
})), | ||
@@ -35,5 +35,3 @@ }; | ||
return { | ||
notifications: this.pending.map(notification => ({ | ||
id: notification.id.toString(), | ||
})), | ||
notifications: this.pending, | ||
}; | ||
@@ -45,3 +43,3 @@ } | ||
async cancel(pending) { | ||
this.pending = this.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id.toString())); | ||
this.pending = this.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id)); | ||
} | ||
@@ -93,9 +91,24 @@ async areEnabled() { | ||
}, diff); | ||
return; | ||
} | ||
this.buildNotification(notification); | ||
} | ||
buildNotification(notification) { | ||
return new Notification(notification.title, { | ||
const localNotification = new Notification(notification.title, { | ||
body: notification.body, | ||
}); | ||
localNotification.addEventListener('click', this.onClick.bind(this, notification), false); | ||
localNotification.addEventListener('show', this.onShow.bind(this, notification), false); | ||
return localNotification; | ||
} | ||
onClick(notification) { | ||
const data = { | ||
actionId: 'tap', | ||
notification, | ||
}; | ||
this.notifyListeners('localNotificationActionPerformed', data); | ||
} | ||
onShow(notification) { | ||
this.notifyListeners('localNotificationReceived', notification); | ||
} | ||
} | ||
@@ -102,0 +115,0 @@ |
{ | ||
"name": "@capacitor/local-notifications", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "The Local Notifications API provides a way to schedule device notifications locally (i.e. without a server sending push notifications).", | ||
@@ -50,3 +50,3 @@ "main": "dist/plugin.cjs.js", | ||
"@capacitor/core": "^3.0.0-beta.1", | ||
"@capacitor/docgen": "0.0.14", | ||
"@capacitor/docgen": "0.0.15", | ||
"@capacitor/ios": "^3.0.0-beta.1", | ||
@@ -83,3 +83,3 @@ "@ionic/eslint-config": "^0.3.0", | ||
}, | ||
"gitHead": "9c7056ff622b1619c0c0d1c59a09b47d20d5739f" | ||
"gitHead": "e10d9dc09f6189f1547a82b8ae29759749fc1f8d" | ||
} |
@@ -276,3 +276,3 @@ # @capacitor/local-notifications | ||
| -------- | ------------------- | ---------------------------- | ----- | | ||
| **`id`** | <code>string</code> | The notification identifier. | 1.0.0 | | ||
| **`id`** | <code>number</code> | The notification identifier. | 1.0.0 | | ||
@@ -316,9 +316,10 @@ | ||
| Prop | Type | Description | Since | | ||
| ------------- | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | | ||
| **`at`** | <code><a href="#date">Date</a></code> | <a href="#schedule">Schedule</a> a notification at a specific date and time. | 1.0.0 | | ||
| **`repeats`** | <code>boolean</code> | Repeat delivery of this notification at the date and time specified by `at`. Only available for iOS and Android. | 1.0.0 | | ||
| **`on`** | <code><a href="#scheduleon">ScheduleOn</a></code> | <a href="#schedule">Schedule</a> a notification on particular interval(s). This is similar to scheduling [cron](https://en.wikipedia.org/wiki/Cron) jobs. Only available for iOS and Android. | 1.0.0 | | ||
| **`every`** | <code><a href="#scheduleevery">ScheduleEvery</a></code> | <a href="#schedule">Schedule</a> a notification on a particular interval. | 1.0.0 | | ||
| **`count`** | <code>number</code> | Limit the number times a notification is delivered by the interval specified by `every`. | 1.0.0 | | ||
| Prop | Type | Description | Since | | ||
| -------------------- | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | | ||
| **`at`** | <code><a href="#date">Date</a></code> | <a href="#schedule">Schedule</a> a notification at a specific date and time. | 1.0.0 | | ||
| **`repeats`** | <code>boolean</code> | Repeat delivery of this notification at the date and time specified by `at`. Only available for iOS and Android. | 1.0.0 | | ||
| **`allowWhileIdle`** | <code>boolean</code> | Allow this notification to fire while in [Doze](https://developer.android.com/training/monitoring-device-state/doze-standby) Only available for Android 23+. Note that these notifications can only fire [once per 9 minutes, per app](https://developer.android.com/training/monitoring-device-state/doze-standby#assessing_your_app). | 1.0.0 | | ||
| **`on`** | <code><a href="#scheduleon">ScheduleOn</a></code> | <a href="#schedule">Schedule</a> a notification on particular interval(s). This is similar to scheduling [cron](https://en.wikipedia.org/wiki/Cron) jobs. Only available for iOS and Android. | 1.0.0 | | ||
| **`every`** | <code><a href="#scheduleevery">ScheduleEvery</a></code> | <a href="#schedule">Schedule</a> a notification on a particular interval. | 1.0.0 | | ||
| **`count`** | <code>number</code> | Limit the number times a notification is delivered by the interval specified by `every`. | 1.0.0 | | ||
@@ -411,7 +412,18 @@ | ||
| Prop | Type | Description | Since | | ||
| ------------------- | ------------------------------------------ | ---------------------------------- | ----- | | ||
| **`notifications`** | <code>LocalNotificationDescriptor[]</code> | The list of pending notifications. | 1.0.0 | | ||
| Prop | Type | Description | Since | | ||
| ------------------- | --------------------------------------------- | ---------------------------------- | ----- | | ||
| **`notifications`** | <code>PendingLocalNotificationSchema[]</code> | The list of pending notifications. | 1.0.0 | | ||
#### PendingLocalNotificationSchema | ||
| Prop | Type | Description | Since | | ||
| -------------- | --------------------------------------------- | -------------------------------------------------------------------- | ----- | | ||
| **`title`** | <code>string</code> | The title of the notification. | 1.0.0 | | ||
| **`body`** | <code>string</code> | The body of the notification, shown below the title. | 1.0.0 | | ||
| **`id`** | <code>number</code> | The notification identifier. | 1.0.0 | | ||
| **`schedule`** | <code><a href="#schedule">Schedule</a></code> | <a href="#schedule">Schedule</a> this notification for a later time. | 1.0.0 | | ||
| **`extra`** | <code>any</code> | Set extra data to store within this notification. | 1.0.0 | | ||
#### RegisterActionTypesOptions | ||
@@ -418,0 +430,0 @@ |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
287421
3550
551