@capacitor/local-notifications
Advanced tools
@@ -5,2 +5,4 @@ package com.capacitorjs.plugins.localnotifications; | ||
| import android.content.Context; | ||
| import android.graphics.Bitmap; | ||
| import android.graphics.BitmapFactory; | ||
| import com.getcapacitor.JSArray; | ||
@@ -14,2 +16,3 @@ import com.getcapacitor.JSObject; | ||
| import java.util.List; | ||
| import org.json.JSONArray; | ||
| import org.json.JSONException; | ||
@@ -25,8 +28,12 @@ import org.json.JSONObject; | ||
| private String body; | ||
| private String largeBody; | ||
| private String summaryText; | ||
| private Integer id; | ||
| private String sound; | ||
| private String smallIcon; | ||
| private String largeIcon; | ||
| private String iconColor; | ||
| private String actionTypeId; | ||
| private String group; | ||
| private List<String> inboxList; | ||
| private boolean groupSummary; | ||
@@ -57,2 +64,18 @@ private boolean ongoing; | ||
| public void setLargeBody(String largeBody) { | ||
| this.largeBody = largeBody; | ||
| } | ||
| public String getLargeBody() { | ||
| return this.largeBody; | ||
| } | ||
| public void setSummaryText(String summaryText) { | ||
| this.summaryText = summaryText; | ||
| } | ||
| public String getSummaryText() { | ||
| return this.summaryText; | ||
| } | ||
| public LocalNotificationSchedule getSchedule() { | ||
@@ -90,2 +113,14 @@ return schedule; | ||
| public void setLargeIcon(String largeIcon) { | ||
| this.largeIcon = AssetUtil.getResourceBaseName(largeIcon); | ||
| } | ||
| public void setInboxList(List<String> inboxList) { | ||
| this.inboxList = inboxList; | ||
| } | ||
| public List<String> getInboxList() { | ||
| return this.inboxList; | ||
| } | ||
| public String getIconColor(String globalColor) { | ||
@@ -219,2 +254,4 @@ // use the one defined local before trying for a globally defined color | ||
| localNotification.setBody(jsonObject.getString("body")); | ||
| localNotification.setLargeBody(jsonObject.getString("largeBody")); | ||
| localNotification.setSummaryText(jsonObject.getString("summaryText")); | ||
| localNotification.setActionTypeId(jsonObject.getString("actionTypeId")); | ||
@@ -225,2 +262,3 @@ localNotification.setGroup(jsonObject.getString("group")); | ||
| localNotification.setSmallIcon(jsonObject.getString("smallIcon")); | ||
| localNotification.setLargeIcon(jsonObject.getString("largeIcon")); | ||
| localNotification.setIconColor(jsonObject.getString("iconColor")); | ||
@@ -230,3 +268,2 @@ localNotification.setAttachments(LocalNotificationAttachment.getAttachments(jsonObject)); | ||
| localNotification.setChannelId(jsonObject.getString("channelId")); | ||
| JSObject schedule = jsonObject.getJSObject("schedule"); | ||
@@ -236,3 +273,2 @@ if (schedule != null) { | ||
| } | ||
| localNotification.setExtra(jsonObject.getJSObject("extra")); | ||
@@ -242,2 +278,13 @@ localNotification.setOngoing(jsonObject.getBoolean("ongoing", false)); | ||
| try { | ||
| JSONArray inboxList = jsonObject.getJSONArray("inboxList"); | ||
| if (inboxList != null) { | ||
| List<String> inboxStringList = new ArrayList<>(); | ||
| for (int i = 0; i < inboxList.length(); i++) { | ||
| inboxStringList.add(inboxList.getString(i)); | ||
| } | ||
| localNotification.setInboxList(inboxStringList); | ||
| } | ||
| } catch (Exception ex) {} | ||
| return localNotification; | ||
@@ -305,2 +352,11 @@ } | ||
| public Bitmap getLargeIcon(Context context) { | ||
| if (largeIcon != null) { | ||
| int resId = AssetUtil.getResourceID(context, largeIcon, "drawable"); | ||
| return BitmapFactory.decodeResource(context.getResources(), resId); | ||
| } | ||
| return null; | ||
| } | ||
| public boolean isScheduled() { | ||
@@ -364,5 +420,7 @@ return ( | ||
| if (body != null ? !body.equals(that.body) : that.body != null) return false; | ||
| if (largeBody != null ? !largeBody.equals(that.largeBody) : that.largeBody != null) return false; | ||
| if (id != null ? !id.equals(that.id) : that.id != null) return false; | ||
| if (sound != null ? !sound.equals(that.sound) : that.sound != null) return false; | ||
| if (smallIcon != null ? !smallIcon.equals(that.smallIcon) : that.smallIcon != null) return false; | ||
| if (largeIcon != null ? !largeIcon.equals(that.largeIcon) : that.largeIcon != null) return false; | ||
| if (iconColor != null ? !iconColor.equals(that.iconColor) : that.iconColor != null) return false; | ||
@@ -373,2 +431,3 @@ if (actionTypeId != null ? !actionTypeId.equals(that.actionTypeId) : that.actionTypeId != null) return false; | ||
| if (attachments != null ? !attachments.equals(that.attachments) : that.attachments != null) return false; | ||
| if (inboxList != null ? !inboxList.equals(that.inboxList) : that.inboxList != null) return false; | ||
| if (groupSummary != that.groupSummary) return false; | ||
@@ -375,0 +434,0 @@ if (ongoing != that.ongoing) return false; |
@@ -177,5 +177,21 @@ package com.capacitorjs.plugins.localnotifications; | ||
| // support multiline text | ||
| mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(localNotification.getBody())); | ||
| if (localNotification.getLargeBody() != null) { | ||
| // support multiline text | ||
| mBuilder.setStyle( | ||
| new NotificationCompat.BigTextStyle() | ||
| .bigText(localNotification.getLargeBody()) | ||
| .setSummaryText(localNotification.getSummaryText()) | ||
| ); | ||
| } | ||
| if (localNotification.getInboxList() != null) { | ||
| NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); | ||
| for (String line : localNotification.getInboxList()) { | ||
| inboxStyle.addLine(line); | ||
| } | ||
| inboxStyle.setBigContentTitle(localNotification.getTitle()); | ||
| inboxStyle.setSummaryText(localNotification.getSummaryText()); | ||
| mBuilder.setStyle(inboxStyle); | ||
| } | ||
| String sound = localNotification.getSound(context, getDefaultSound(context)); | ||
@@ -195,2 +211,5 @@ if (sound != null) { | ||
| mBuilder.setGroup(group); | ||
| if (localNotification.isGroupSummary()) { | ||
| mBuilder.setSubText(localNotification.getSummaryText()); | ||
| } | ||
| } | ||
@@ -207,2 +226,3 @@ | ||
| mBuilder.setSmallIcon(localNotification.getSmallIcon(context, getDefaultSmallIcon(context))); | ||
| mBuilder.setLargeIcon(localNotification.getLargeIcon(context)); | ||
@@ -209,0 +229,0 @@ String iconColor = localNotification.getIconColor(config.getString(CONFIG_KEY_PREFIX + "iconColor")); |
+18
-0
@@ -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 @@ /** |
@@ -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; |
+27
-0
@@ -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 }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAa5C,MAAM,OAAO,qBACX,SAAQ,SAAS;IADnB;;QAGY,YAAO,GAA8B,EAAE,CAAC;IA8IpD,CAAC;IA5IC,KAAK,CAAC,aAAa;QACjB,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAwB;QACrC,KAAK,MAAM,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE;YAChD,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;SACrC;QAED,OAAO;YACL,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;gBACxD,EAAE,EAAE,YAAY,CAAC,EAAE;aACpB,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO;YACL,aAAa,EAAE,IAAI,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=> { | ||
| 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 }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst LocalNotifications = registerPlugin('LocalNotifications', {\n web: () => import('./web').then(m => new m.LocalNotificationsWeb()),\n});\nexport * from './definitions';\nexport { LocalNotifications };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class LocalNotificationsWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.pending = [];\n }\n async createChannel() {\n throw this.unimplemented('Not implemented on web.');\n }\n async deleteChannel() {\n throw this.unimplemented('Not implemented on web.');\n }\n async listChannels() {\n throw this.unimplemented('Not implemented on web.');\n }\n async schedule(options) {\n for (const notification of options.notifications) {\n this.sendNotification(notification);\n }\n return {\n notifications: options.notifications.map(notification => ({\n id: notification.id,\n })),\n };\n }\n async getPending() {\n return {\n notifications: this.pending,\n };\n }\n async registerActionTypes() {\n throw this.unimplemented('Not implemented on web.');\n }\n async cancel(pending) {\n this.pending = this.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id));\n }\n async areEnabled() {\n const { display } = await this.checkPermissions();\n return {\n value: display === 'granted',\n };\n }\n async requestPermissions() {\n const display = this.transformNotificationPermission(await Notification.requestPermission());\n return { display };\n }\n async checkPermissions() {\n const display = this.transformNotificationPermission(Notification.permission);\n return { display };\n }\n transformNotificationPermission(permission) {\n switch (permission) {\n case 'granted':\n return 'granted';\n case 'denied':\n return 'denied';\n default:\n return 'prompt';\n }\n }\n sendPending() {\n var _a;\n const toRemove = [];\n const now = new Date().getTime();\n for (const notification of this.pending) {\n if (((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) &&\n notification.schedule.at.getTime() <= now) {\n this.buildNotification(notification);\n toRemove.push(notification);\n }\n }\n this.pending = this.pending.filter(notification => !toRemove.find(n => n === notification));\n }\n sendNotification(notification) {\n var _a;\n if ((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) {\n const diff = notification.schedule.at.getTime() - new Date().getTime();\n this.pending.push(notification);\n setTimeout(() => {\n this.sendPending();\n }, diff);\n return;\n }\n this.buildNotification(notification);\n }\n buildNotification(notification) {\n const localNotification = new Notification(notification.title, {\n body: notification.body,\n });\n localNotification.addEventListener('click', this.onClick.bind(this, notification), false);\n localNotification.addEventListener('show', this.onShow.bind(this, notification), false);\n return localNotification;\n }\n onClick(notification) {\n const data = {\n actionId: 'tap',\n notification,\n };\n this.notifyListeners('localNotificationActionPerformed', data);\n }\n onShow(notification) {\n this.notifyListeners('localNotificationReceived', notification);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,kBAAkB,GAAGA,mBAAc,CAAC,oBAAoB,EAAE;AAChE,IAAI,GAAG,EAA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AAQ,MAAM,iBAAiB,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,KAAK,EAAE;AACvE,YAAY,IAAI,EAAE,YAAY,CAAC,IAAI;AACnC,SAAS,CAAC,CAAC;AACX,QAAQ,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;AAClG,QAAQ,iBAAiB,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;AAChG,QAAQ,OAAO,iBAAiB,CAAC;AACjC,KAAK;AACL,IAAI,OAAO,CAAC,YAAY,EAAE;AAC1B,QAAQ,MAAM,IAAI,GAAG;AACrB,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,YAAY;AACxB,SAAS,CAAC;AACV,QAAQ,IAAI,CAAC,eAAe,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAC;AACvE,KAAK;AACL,IAAI,MAAM,CAAC,YAAY,EAAE;AACzB,QAAQ,IAAI,CAAC,eAAe,CAAC,2BAA2B,EAAE,YAAY,CAAC,CAAC;AACxE,KAAK;AACL;;;;;;;;;"} | ||
| {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst LocalNotifications = registerPlugin('LocalNotifications', {\n web: () => import('./web').then(m => new m.LocalNotificationsWeb()),\n});\nexport * from './definitions';\nexport { LocalNotifications };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class LocalNotificationsWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.pending = [];\n this.hasNotificationSupport = () => {\n if (!('Notification' in window) || !Notification.requestPermission) {\n return false;\n }\n if (Notification.permission !== 'granted') {\n // don't test for `new Notification` if permission has already been granted\n // otherwise this sends a real notification on supported browsers\n try {\n new Notification('');\n }\n catch (e) {\n if (e.name == 'TypeError') {\n return false;\n }\n }\n }\n return true;\n };\n }\n async createChannel() {\n throw this.unimplemented('Not implemented on web.');\n }\n async deleteChannel() {\n throw this.unimplemented('Not implemented on web.');\n }\n async listChannels() {\n throw this.unimplemented('Not implemented on web.');\n }\n async schedule(options) {\n if (!this.hasNotificationSupport()) {\n throw this.unavailable('Notifications not supported in this browser.');\n }\n for (const notification of options.notifications) {\n this.sendNotification(notification);\n }\n return {\n notifications: options.notifications.map(notification => ({\n id: notification.id,\n })),\n };\n }\n async getPending() {\n return {\n notifications: this.pending,\n };\n }\n async registerActionTypes() {\n throw this.unimplemented('Not implemented on web.');\n }\n async cancel(pending) {\n this.pending = this.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id));\n }\n async areEnabled() {\n const { display } = await this.checkPermissions();\n return {\n value: display === 'granted',\n };\n }\n async requestPermissions() {\n if (!this.hasNotificationSupport()) {\n throw this.unavailable('Notifications not supported in this browser.');\n }\n const display = this.transformNotificationPermission(await Notification.requestPermission());\n return { display };\n }\n async checkPermissions() {\n if (!this.hasNotificationSupport()) {\n throw this.unavailable('Notifications not supported in this browser.');\n }\n const display = this.transformNotificationPermission(Notification.permission);\n return { display };\n }\n transformNotificationPermission(permission) {\n switch (permission) {\n case 'granted':\n return 'granted';\n case 'denied':\n return 'denied';\n default:\n return 'prompt';\n }\n }\n sendPending() {\n var _a;\n const toRemove = [];\n const now = new Date().getTime();\n for (const notification of this.pending) {\n if (((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) &&\n notification.schedule.at.getTime() <= now) {\n this.buildNotification(notification);\n toRemove.push(notification);\n }\n }\n this.pending = this.pending.filter(notification => !toRemove.find(n => n === notification));\n }\n sendNotification(notification) {\n var _a;\n if ((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) {\n const diff = notification.schedule.at.getTime() - new Date().getTime();\n this.pending.push(notification);\n setTimeout(() => {\n this.sendPending();\n }, diff);\n return;\n }\n this.buildNotification(notification);\n }\n buildNotification(notification) {\n const localNotification = new Notification(notification.title, {\n body: notification.body,\n });\n localNotification.addEventListener('click', this.onClick.bind(this, notification), false);\n localNotification.addEventListener('show', this.onShow.bind(this, notification), false);\n return localNotification;\n }\n onClick(notification) {\n const data = {\n actionId: 'tap',\n notification,\n };\n this.notifyListeners('localNotificationActionPerformed', data);\n }\n onShow(notification) {\n this.notifyListeners('localNotificationReceived', notification);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,kBAAkB,GAAGA,mBAAc,CAAC,oBAAoB,EAAE;AAChE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,qBAAqB,EAAE,CAAC;AACvE,CAAC;;ACFM,MAAM,qBAAqB,SAASC,cAAS,CAAC;AACrD,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;AAC5B,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;AAC1B,QAAQ,IAAI,CAAC,sBAAsB,GAAG,MAAM;AAC5C,YAAY,IAAI,EAAE,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE;AAChF,gBAAgB,OAAO,KAAK,CAAC;AAC7B,aAAa;AACb,YAAY,IAAI,YAAY,CAAC,UAAU,KAAK,SAAS,EAAE;AACvD;AACA;AACA,gBAAgB,IAAI;AACpB,oBAAoB,IAAI,YAAY,CAAC,EAAE,CAAC,CAAC;AACzC,iBAAiB;AACjB,gBAAgB,OAAO,CAAC,EAAE;AAC1B,oBAAoB,IAAI,CAAC,CAAC,IAAI,IAAI,WAAW,EAAE;AAC/C,wBAAwB,OAAO,KAAK,CAAC;AACrC,qBAAqB;AACrB,iBAAiB;AACjB,aAAa;AACb,YAAY,OAAO,IAAI,CAAC;AACxB,SAAS,CAAC;AACV,KAA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AACnB,SAAS;AACT,QAAQ,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAC7C,KAAK;AACL,IAAI,iBAAiB,CAAC,YAAY,EAAE;AACpC,QAAQ,MAAM,iBAAiB,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,KAAK,EAAE;AACvE,YAAY,IAAI,EAAE,YAAY,CAAC,IAAI;AACnC,SAAS,CAAC,CAAC;AACX,QAAQ,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;AAClG,QAAQ,iBAAiB,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;AAChG,QAAQ,OAAO,iBAAiB,CAAC;AACjC,KAAK;AACL,IAAI,OAAO,CAAC,YAAY,EAAE;AAC1B,QAAQ,MAAM,IAAI,GAAG;AACrB,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,YAAY;AACxB,SAAS,CAAC;AACV,QAAQ,IAAI,CAAC,eAAe,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAC;AACvE,KAAK;AACL,IAAI,MAAM,CAAC,YAAY,EAAE;AACzB,QAAQ,IAAI,CAAC,eAAe,CAAC,2BAA2B,EAAE,YAAY,CAAC,CAAC;AACxE,KAAK;AACL;;;;;;;;;"} |
+27
-0
@@ -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 }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst LocalNotifications = registerPlugin('LocalNotifications', {\n web: () => import('./web').then(m => new m.LocalNotificationsWeb()),\n});\nexport * from './definitions';\nexport { LocalNotifications };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class LocalNotificationsWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.pending = [];\n }\n async createChannel() {\n throw this.unimplemented('Not implemented on web.');\n }\n async deleteChannel() {\n throw this.unimplemented('Not implemented on web.');\n }\n async listChannels() {\n throw this.unimplemented('Not implemented on web.');\n }\n async schedule(options) {\n for (const notification of options.notifications) {\n this.sendNotification(notification);\n }\n return {\n notifications: options.notifications.map(notification => ({\n id: notification.id,\n })),\n };\n }\n async getPending() {\n return {\n notifications: this.pending,\n };\n }\n async registerActionTypes() {\n throw this.unimplemented('Not implemented on web.');\n }\n async cancel(pending) {\n this.pending = this.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id));\n }\n async areEnabled() {\n const { display } = await this.checkPermissions();\n return {\n value: display === 'granted',\n };\n }\n async requestPermissions() {\n const display = this.transformNotificationPermission(await Notification.requestPermission());\n return { display };\n }\n async checkPermissions() {\n const display = this.transformNotificationPermission(Notification.permission);\n return { display };\n }\n transformNotificationPermission(permission) {\n switch (permission) {\n case 'granted':\n return 'granted';\n case 'denied':\n return 'denied';\n default:\n return 'prompt';\n }\n }\n sendPending() {\n var _a;\n const toRemove = [];\n const now = new Date().getTime();\n for (const notification of this.pending) {\n if (((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) &&\n notification.schedule.at.getTime() <= now) {\n this.buildNotification(notification);\n toRemove.push(notification);\n }\n }\n this.pending = this.pending.filter(notification => !toRemove.find(n => n === notification));\n }\n sendNotification(notification) {\n var _a;\n if ((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) {\n const diff = notification.schedule.at.getTime() - new Date().getTime();\n this.pending.push(notification);\n setTimeout(() => {\n this.sendPending();\n }, diff);\n return;\n }\n this.buildNotification(notification);\n }\n buildNotification(notification) {\n const localNotification = new Notification(notification.title, {\n body: notification.body,\n });\n localNotification.addEventListener('click', this.onClick.bind(this, notification), false);\n localNotification.addEventListener('show', this.onShow.bind(this, notification), false);\n return localNotification;\n }\n onClick(notification) {\n const data = {\n actionId: 'tap',\n notification,\n };\n this.notifyListeners('localNotificationActionPerformed', data);\n }\n onShow(notification) {\n this.notifyListeners('localNotificationReceived', notification);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,kBAAkB,GAAGA,mBAAc,CAAC,oBAAoB,EAAE;IAChE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,qBAAqB,EAAE,CAAC;IACvE,CAAC;;ICFM,MAAM,qBAAqB,SAASC,cAAS,CAAC;IACrD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5B,QAA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AC,IAAI,EAAE,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;IAClG,QAAQ,iBAAiB,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;IAChG,QAAQ,OAAO,iBAAiB,CAAC;IACjC,KAAK;IACL,IAAI,OAAO,CAAC,YAAY,EAAE;IAC1B,QAAQ,MAAM,IAAI,GAAG;IACrB,YAAY,QAAQ,EAAE,KAAK;IAC3B,YAAY,YAAY;IACxB,SAAS,CAAC;IACV,QAAQ,IAAI,CAAC,eAAe,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAC;IACvE,KAAK;IACL,IAAI,MAAM,CAAC,YAAY,EAAE;IACzB,QAAQ,IAAI,CAAC,eAAe,CAAC,2BAA2B,EAAE,YAAY,CAAC,CAAC;IACxE,KAAK;IACL;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst LocalNotifications = registerPlugin('LocalNotifications', {\n web: () => import('./web').then(m => new m.LocalNotificationsWeb()),\n});\nexport * from './definitions';\nexport { LocalNotifications };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class LocalNotificationsWeb extends WebPlugin {\n constructor() {\n super(...arguments);\n this.pending = [];\n this.hasNotificationSupport = () => {\n if (!('Notification' in window) || !Notification.requestPermission) {\n return false;\n }\n if (Notification.permission !== 'granted') {\n // don't test for `new Notification` if permission has already been granted\n // otherwise this sends a real notification on supported browsers\n try {\n new Notification('');\n }\n catch (e) {\n if (e.name == 'TypeError') {\n return false;\n }\n }\n }\n return true;\n };\n }\n async createChannel() {\n throw this.unimplemented('Not implemented on web.');\n }\n async deleteChannel() {\n throw this.unimplemented('Not implemented on web.');\n }\n async listChannels() {\n throw this.unimplemented('Not implemented on web.');\n }\n async schedule(options) {\n if (!this.hasNotificationSupport()) {\n throw this.unavailable('Notifications not supported in this browser.');\n }\n for (const notification of options.notifications) {\n this.sendNotification(notification);\n }\n return {\n notifications: options.notifications.map(notification => ({\n id: notification.id,\n })),\n };\n }\n async getPending() {\n return {\n notifications: this.pending,\n };\n }\n async registerActionTypes() {\n throw this.unimplemented('Not implemented on web.');\n }\n async cancel(pending) {\n this.pending = this.pending.filter(notification => !pending.notifications.find(n => n.id === notification.id));\n }\n async areEnabled() {\n const { display } = await this.checkPermissions();\n return {\n value: display === 'granted',\n };\n }\n async requestPermissions() {\n if (!this.hasNotificationSupport()) {\n throw this.unavailable('Notifications not supported in this browser.');\n }\n const display = this.transformNotificationPermission(await Notification.requestPermission());\n return { display };\n }\n async checkPermissions() {\n if (!this.hasNotificationSupport()) {\n throw this.unavailable('Notifications not supported in this browser.');\n }\n const display = this.transformNotificationPermission(Notification.permission);\n return { display };\n }\n transformNotificationPermission(permission) {\n switch (permission) {\n case 'granted':\n return 'granted';\n case 'denied':\n return 'denied';\n default:\n return 'prompt';\n }\n }\n sendPending() {\n var _a;\n const toRemove = [];\n const now = new Date().getTime();\n for (const notification of this.pending) {\n if (((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) &&\n notification.schedule.at.getTime() <= now) {\n this.buildNotification(notification);\n toRemove.push(notification);\n }\n }\n this.pending = this.pending.filter(notification => !toRemove.find(n => n === notification));\n }\n sendNotification(notification) {\n var _a;\n if ((_a = notification.schedule) === null || _a === void 0 ? void 0 : _a.at) {\n const diff = notification.schedule.at.getTime() - new Date().getTime();\n this.pending.push(notification);\n setTimeout(() => {\n this.sendPending();\n }, diff);\n return;\n }\n this.buildNotification(notification);\n }\n buildNotification(notification) {\n const localNotification = new Notification(notification.title, {\n body: notification.body,\n });\n localNotification.addEventListener('click', this.onClick.bind(this, notification), false);\n localNotification.addEventListener('show', this.onShow.bind(this, notification), false);\n return localNotification;\n }\n onClick(notification) {\n const data = {\n actionId: 'tap',\n notification,\n };\n this.notifyListeners('localNotificationActionPerformed', data);\n }\n onShow(notification) {\n this.notifyListeners('localNotificationReceived', notification);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,kBAAkB,GAAGA,mBAAc,CAAC,oBAAoB,EAAE;IAChE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,qBAAqB,EAAE,CAAC;IACvE,CAAC;;ICFM,MAAM,qBAAqB,SAASC,cAAS,CAAC;IACrD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5B,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IAC1B,QAAQ,IAAI,CAAC,sBAAsB,GAAG,MAAM;IAC5C,YAAY,IAAI,EAAE,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE;IAChF,gBAAgB,OAAO,KAAK,CAAC;IAC7B,aAAa;IACb,YAAY,IAAI,YAAY,CAAC,UAAU,KAAK,SAAS,EAAE;IACvD;IACA;IACA,gBAAgB,IAAI;IACpB,oBAAoB,IAAI,YAAY,CAAC,EAAE,CAAC,CAAC;IACzC,iBAAiB;IACjB,gBAAgB,OAAO,CAAC,EAAE;IAC1B,oBAAoB,IAAI,CAAC,CAAC,IAAI,IAAI,WAAW,EAAE;IAC/C,wBAAwB,OAAO,KAAK,CAAC;IACrC,qBAAqB;IACrB,iBAAiB;IACjB,aAAa;IACb,YAAY,OAAO,IAAI,CAAC;IACxB,SAAS,CAAC;IACV,KAAK;IACL,IAAI,MAAM,aAAa,GAAG;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IACL,IAAI,MAAM,aAAa,GAAG;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IAC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YAAY,CAAC,IAAI;IACnC,SAAS,CAAC,CAAC;IACX,QAAQ,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;IAClG,QAAQ,iBAAiB,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;IAChG,QAAQ,OAAO,iBAAiB,CAAC;IACjC,KAAK;IACL,IAAI,OAAO,CAAC,YAAY,EAAE;IAC1B,QAAQ,MAAM,IAAI,GAAG;IACrB,YAAY,QAAQ,EAAE,KAAK;IAC3B,YAAY,YAAY;IACxB,SAAS,CAAC;IACV,QAAQ,IAAI,CAAC,eAAe,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAC;IACvE,KAAK;IACL,IAAI,MAAM,CAAC,YAAY,EAAE;IACzB,QAAQ,IAAI,CAAC,eAAe,CAAC,2BAA2B,EAAE,YAAY,CAAC,CAAC;IACxE,KAAK;IACL;;;;;;;;;;;;;;;;;"} |
+8
-8
| { | ||
| "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" | ||
| } |
+38
-3
@@ -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 too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
312827
7.01%5601
5.64%611
6.08%0
-100%5
25%