New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

expo-notifications

Package Overview
Dependencies
Maintainers
24
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-notifications - npm Package Compare versions

Comparing version 0.7.2 to 0.8.0

android/src/main/java/expo/modules/notifications/notifications/triggers/WeeklyTrigger.java

1

build/BadgeModule.types.js

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=BadgeModule.types.js.map

4

build/BadgeModule.web.d.ts
import { BadgeModule } from './BadgeModule.types';
declare const _default: BadgeModule;
export default _default;
declare const badgeModule: BadgeModule;
export default badgeModule;

@@ -1,4 +0,3 @@

import * as badgin from 'badgin';
let lastSetBadgeCount = 0;
export default {
const badgeModule = {
addListener: () => { },

@@ -10,2 +9,8 @@ removeListeners: () => { },

setBadgeCountAsync: async (badgeCount, options) => {
// If this module is loaded in SSR (NextJS), we can't modify the badge.
// It also can't load the badgin module, that instantly invokes methods on window.
if (typeof window === 'undefined') {
return false;
}
const badgin = require('badgin');
if (badgeCount > 0) {

@@ -21,2 +26,3 @@ badgin.set(badgeCount, options);

};
export default badgeModule;
//# sourceMappingURL=BadgeModule.web.js.map

@@ -24,2 +24,4 @@ export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';

export { default as deleteNotificationCategoryAsync } from './deleteNotificationCategoryAsync';
export { default as getNextTriggerDateAsync } from './getNextTriggerDateAsync';
export { default as useLastNotificationResponse } from './useLastNotificationResponse';
export * from './TokenEmitter';

@@ -26,0 +28,0 @@ export * from './NotificationsEmitter';

@@ -24,2 +24,4 @@ export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';

export { default as deleteNotificationCategoryAsync } from './deleteNotificationCategoryAsync';
export { default as getNextTriggerDateAsync } from './getNextTriggerDateAsync';
export { default as useLastNotificationResponse } from './useLastNotificationResponse';
export * from './TokenEmitter';

@@ -26,0 +28,0 @@ export * from './NotificationsEmitter';

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=InstallationIdProvider.types.js.map

@@ -13,5 +13,5 @@ import { ProxyNativeModule } from '@unimodules/core';

showSubtitle?: boolean;
allowAnnouncment?: boolean;
allowAnnouncement?: boolean;
}) => Promise<NotificationCategory>;
deleteNotificationCategoryAsync: (identifier: string) => Promise<boolean>;
}

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=NotificationCategoriesModule.types.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=NotificationChannelGroupManager.types.js.map

@@ -22,3 +22,3 @@ import { ProxyNativeModule } from '@unimodules/core';

DEFAULT = 5,
/** @deprecated use DEFAULT instead */
/** @deprecated use `DEFAULT` instead */
DEEFAULT = 5,

@@ -25,0 +25,0 @@ HIGH = 6,

@@ -24,3 +24,3 @@ export var AndroidNotificationVisibility;

AndroidImportance[AndroidImportance["DEFAULT"] = 5] = "DEFAULT";
/** @deprecated use DEFAULT instead */
/** @deprecated use `DEFAULT` instead */
AndroidImportance[AndroidImportance["DEEFAULT"] = 5] = "DEEFAULT";

@@ -27,0 +27,0 @@ AndroidImportance[AndroidImportance["HIGH"] = 6] = "HIGH";

@@ -36,3 +36,15 @@ import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';

if (shouldAsk) {
status = await Notification.requestPermission();
status = await new Promise((resolve, reject) => {
let resolved = false;
function resolveOnce(status) {
if (!resolved) {
resolved = true;
resolve(status);
}
}
// Some browsers require a callback argument and some return a Promise
Notification.requestPermission(resolveOnce)
?.then(resolveOnce)
?.catch(reject);
});
}

@@ -39,0 +51,0 @@ return convertPermissionStatus(status);

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=NotificationPermissionsModule.types.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=NotificationPresenterModule.types.js.map
import { CalendarTriggerInput as NativeCalendarTriggerInput } from './NotificationScheduler.types';
export interface PushNotificationTrigger {
/**
* `payload` is set only on iOS,
* `remoteMessage` is set only on Android,
* no extra entry is for Web
*/
export declare type PushNotificationTrigger = {
type: 'push';
remoteMessage?: FirebaseRemoteMessage;
}
} & ({
payload: Record<string, unknown>;
} | {
remoteMessage: FirebaseRemoteMessage;
} | {});
export interface CalendarNotificationTrigger {

@@ -70,2 +78,8 @@ type: 'calendar';

}
export interface WeeklyNotificationTrigger {
type: 'weekly';
weekday: number;
hour: number;
minute: number;
}
export interface FirebaseRemoteMessage {

@@ -116,3 +130,3 @@ collapseKey: string | null;

}
export declare type NotificationTrigger = PushNotificationTrigger | CalendarNotificationTrigger | LocationNotificationTrigger | TimeIntervalNotificationTrigger | DailyNotificationTrigger | UnknownNotificationTrigger;
export declare type NotificationTrigger = PushNotificationTrigger | CalendarNotificationTrigger | LocationNotificationTrigger | TimeIntervalNotificationTrigger | DailyNotificationTrigger | WeeklyNotificationTrigger | UnknownNotificationTrigger;
export declare type ChannelAwareTriggerInput = {

@@ -136,2 +150,9 @@ channelId: string;

}
export interface WeeklyTriggerInput {
channelId?: string;
weekday: number;
hour: number;
minute: number;
repeats: true;
}
export declare type DateTriggerInput = Date | number | {

@@ -141,3 +162,4 @@ channelId?: string;

};
export declare type NotificationTriggerInput = null | ChannelAwareTriggerInput | DateTriggerInput | TimeIntervalTriggerInput | DailyTriggerInput | CalendarTriggerInput;
export declare type SchedulableNotificationTriggerInput = DateTriggerInput | TimeIntervalTriggerInput | DailyTriggerInput | WeeklyTriggerInput | CalendarTriggerInput;
export declare type NotificationTriggerInput = null | ChannelAwareTriggerInput | SchedulableNotificationTriggerInput;
export declare enum AndroidNotificationPriority {

@@ -144,0 +166,0 @@ MIN = "min",

@@ -8,2 +8,3 @@ import { ProxyNativeModule } from '@unimodules/core';

cancelAllScheduledNotificationsAsync?: () => Promise<void>;
getNextTriggerDateAsync?: (trigger: NotificationTriggerInput) => Promise<number>;
}

@@ -44,2 +45,9 @@ export interface ChannelAwareTriggerInput {

}
export interface WeeklyTriggerInput {
type: 'weekly';
channelId?: string;
weekday: number;
hour: number;
minute: number;
}
export interface DateTriggerInput {

@@ -50,2 +58,2 @@ type: 'date';

}
export declare type NotificationTriggerInput = null | ChannelAwareTriggerInput | DateTriggerInput | CalendarTriggerInput | TimeIntervalTriggerInput | DailyTriggerInput;
export declare type NotificationTriggerInput = null | ChannelAwareTriggerInput | DateTriggerInput | CalendarTriggerInput | TimeIntervalTriggerInput | DailyTriggerInput | WeeklyTriggerInput;

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=NotificationScheduler.types.js.map

@@ -8,2 +8,1 @@ import { Subscription } from '@unimodules/core';

export declare function removeNotificationSubscription(subscription: Subscription): void;
export declare function removeAllNotificationListeners(): void;

@@ -21,7 +21,2 @@ import { EventEmitter } from '@unimodules/core';

}
export function removeAllNotificationListeners() {
emitter.removeAllListeners(didReceiveNotificationEventName);
emitter.removeAllListeners(didDropNotificationsEventName);
emitter.removeAllListeners(didReceiveNotificationResponseEventName);
}
//# sourceMappingURL=NotificationsEmitter.js.map
import { ProxyNativeModule } from '@unimodules/core';
import { NotificationResponse } from './Notifications.types';
export interface NotificationsEmitterModule extends ProxyNativeModule {
getLastNotificationResponseAsync?: () => Promise<NotificationResponse | null>;
}

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=NotificationsEmitterModule.types.js.map

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=NotificationsHandlerModule.types.js.map
import { NotificationContentInput } from './Notifications.types';
/**
* @deprecated Use `scheduleNotificationAsync` with an explicit notification handler.
* [Read more](https://expo.fyi/presenting-notifications-deprecated).
*/
export default function presentNotificationAsync(content: NotificationContentInput, identifier?: string): Promise<string>;

@@ -5,2 +5,6 @@ import { UnavailabilityError } from '@unimodules/core';

let warningMessageShown = false;
/**
* @deprecated Use `scheduleNotificationAsync` with an explicit notification handler.
* [Read more](https://expo.fyi/presenting-notifications-deprecated).
*/
export default async function presentNotificationAsync(content, identifier = uuidv4()) {

@@ -7,0 +11,0 @@ if (__DEV__ && !warningMessageShown) {

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=PushTokenManager.types.js.map

@@ -1,2 +0,4 @@

import { NotificationRequestInput } from './Notifications.types';
import { NotificationTriggerInput as NativeNotificationTriggerInput } from './NotificationScheduler.types';
import { NotificationRequestInput, NotificationTriggerInput } from './Notifications.types';
export default function scheduleNotificationAsync(request: NotificationRequestInput): Promise<string>;
export declare function parseTrigger(userFacingTrigger: NotificationTriggerInput): NativeNotificationTriggerInput;

@@ -1,2 +0,2 @@

import { UnavailabilityError } from '@unimodules/core';
import { Platform, UnavailabilityError } from '@unimodules/core';
import uuidv4 from 'uuid/v4';

@@ -10,3 +10,3 @@ import NotificationScheduler from './NotificationScheduler';

}
function parseTrigger(userFacingTrigger) {
export function parseTrigger(userFacingTrigger) {
if (userFacingTrigger === null) {

@@ -40,2 +40,31 @@ return null;

}
else if (isWeeklyTriggerInput(userFacingTrigger)) {
const weekday = userFacingTrigger.weekday;
const hour = userFacingTrigger.hour;
const minute = userFacingTrigger.minute;
if (weekday === undefined ||
weekday == null ||
hour === undefined ||
hour == null ||
minute === undefined ||
minute == null) {
throw new TypeError('Weekday, hour and minute need to have valid values. Found undefined');
}
if (weekday < 1 || weekday > 7) {
throw new RangeError(`The weekday parameter needs to be between 1 and 7. Found: ${weekday}`);
}
if (hour < 0 || hour > 23) {
throw new RangeError(`The hour parameter needs to be between 0 and 23. Found: ${hour}`);
}
if (minute < 0 || minute > 59) {
throw new RangeError(`The minute parameter needs to be between 0 and 59. Found: ${minute}`);
}
return {
type: 'weekly',
channelId: userFacingTrigger.channelId,
weekday,
hour,
minute,
};
}
else if (isSecondsPropertyMisusedInCalendarTriggerInput(userFacingTrigger)) {

@@ -57,4 +86,6 @@ throw new TypeError('Could not have inferred the notification trigger type: if you want to use a time interval trigger, pass in only `seconds` with or without `repeats` property; if you want to use calendar-based trigger, pass in `second`.');

else {
// @ts-ignore Type '"channel"' is not assignable to type '"daily"'.ts(2322)
return { type: 'channel', channelId: userFacingTrigger.channelId };
return Platform.select({
default: null,
android: { type: 'channel', channelId: userFacingTrigger.channelId },
});
}

@@ -69,3 +100,3 @@ }

typeof trigger === 'number' ||
(typeof trigger === 'object' && trigger['date']));
(typeof trigger === 'object' && 'date' in trigger));
}

@@ -85,8 +116,18 @@ function parseDateTrigger(trigger) {

function isDailyTriggerInput(trigger) {
return (Object.keys(trigger).length === 3 &&
'hour' in trigger &&
'minute' in trigger &&
'repeats' in trigger &&
trigger.repeats === true);
const { channelId, ...triggerWithoutChannelId } = trigger;
return (Object.keys(triggerWithoutChannelId).length === 3 &&
'hour' in triggerWithoutChannelId &&
'minute' in triggerWithoutChannelId &&
'repeats' in triggerWithoutChannelId &&
triggerWithoutChannelId.repeats === true);
}
function isWeeklyTriggerInput(trigger) {
const { channelId, ...triggerWithoutChannelId } = trigger;
return (Object.keys(triggerWithoutChannelId).length === 4 &&
'weekday' in triggerWithoutChannelId &&
'hour' in triggerWithoutChannelId &&
'minute' in triggerWithoutChannelId &&
'repeats' in triggerWithoutChannelId &&
triggerWithoutChannelId.repeats === true);
}
function isSecondsPropertyMisusedInCalendarTriggerInput(trigger) {

@@ -93,0 +134,0 @@ const { channelId, ...triggerWithoutChannelId } = trigger;

@@ -10,3 +10,3 @@ import { NotificationCategory, NotificationAction } from './Notifications.types';

showSubtitle?: boolean;
allowAnnouncment?: boolean;
allowAnnouncement?: boolean;
}): Promise<NotificationCategory>;

@@ -1,2 +0,2 @@

import { Platform } from 'react-native';
import { Platform } from '@unimodules/core';
export interface NativeDevicePushToken {

@@ -3,0 +3,0 @@ type: 'ios' | 'android';

@@ -0,1 +1,2 @@

export {};
//# sourceMappingURL=Tokens.types.js.map

@@ -11,8 +11,43 @@ # Changelog

## 0.7.2 — 2020-09-17
## 0.8.0 — 2020-11-17
### 🛠 Breaking changes
- Changed the way `PermissionResponse.status` is calculated on iOS. Previously, it returns the numeric value of `UMPermissionStatus` which does not match the TypeScript enum declaration. ([#10513](https://github.com/expo/expo/pull/10513) by [@cHaLkdusT](https://github.com/cHaLkdusT))
- Changed the way `NotificationContent.data` is calculated on iOS. Previously it was the contents of remote notification payload with all entries from under `"body"` moved from under `"body"` to root level. Now it's the sole unchanged contents of `payload["body"]`. Other fields of the payload can now be accessed on iOS through `PushNotificationTrigger.payload` (similarly to how other fields of native remote message can be accessed on Android under `PushNotificationTrigger.remoteMessage`). ([#10453](https://github.com/expo/expo/pull/10453) by [@sjchmiela](https://github.com/sjchmiela))
- Changed class responsible for handling Firebase events from `FirebaseMessagingService` to `.service.NotificationsService` on Android. ([#10558](https://github.com/expo/expo/pull/10558) by [@sjchmiela](https://github.com/sjchmiela))
> Note that this change most probably will not affect you — it only affects projects that override `FirebaseMessagingService` to implement some custom handling logic.
- Changed how you can override ways in which a notification is reinterpreted from a [`StatusBarNotification`](https://developer.android.com/reference/android/service/notification/StatusBarNotification) and in which a [`Notification`](https://developer.android.com/reference/android/app/Notification.html?hl=en) is built from defining an `expo.modules.notifications#NotificationsScoper` meta-data value in `AndroidManifest.xml` to implementing a `BroadcastReceiver` subclassing `NotificationsService` delegating those responsibilities to your custom `PresentationDelegate` instance. ([#10558](https://github.com/expo/expo/pull/10558) by [@sjchmiela](https://github.com/sjchmiela))
> Note that this change most probably will not affect you — it only affects projects that override those methods to implement some custom handling logic.
- Removed `removeAllNotificationListeners` method. You can (and should) still remove listeners using `remove` method on `Subscription` objects returned by `addNotification…Listener`. ([#10883](https://github.com/expo/expo/pull/10883) by [@sjchmiela](https://github.com/sjchmiela))
### 🎉 New features
- Added `useLastNotificationResponse` React hook that always returns the notification response that has been emitted most recently. ([#10883](https://github.com/expo/expo/pull/10883) by [@sjchmiela](https://github.com/sjchmiela))
- Added `WeeklyTriggerInput` that allows scheduling a weekly recurring notification for a specific day of week, hour and minute. It is supported on both iOS and Android. ([#9973](https://github.com/expo/expo/pull/9973) by [@RikTheunis](https://github.com/riktheunis))
- Added `getNextTriggerDateAsync` method allowing you to verify manually when would the next trigger date for a particular notification trigger be. ([#10455](https://github.com/expo/expo/pull/10455) by [@sjchmiela](https://github.com/sjchmiela))
- Added support for restoring scheduled notifications alarms on Android after an app is updated. ([#10708](https://github.com/expo/expo/pull/10708) by [@sjchmiela](https://github.com/sjchmiela))
### 🐛 Bug fixes
- Fixed TypeScript definition: `setNotificationCategoryAsync` should expect `options.allowAnnouncement`, **not** `options.allowAnnouncment`. ([#11025](https://github.com/expo/expo/pull/11025) by [@cruzach](https://github.com/cruzach))
- Fixed issue where custom notification icon and color weren't being properly applied in Android managed workflow apps. ([#10828](https://github.com/expo/expo/pull/10828) by [@cruzach](https://github.com/cruzach))
- Fixed case where Android managed workflow apps could crash when receiving an interactive notification. ([#10608](https://github.com/expo/expo/pull/10608) by [@cruzach](https://github.com/cruzach))
- Fixed case where Android apps could crash if you set a new category with a text input action **without** providing any `options`. ([#10141](https://github.com/expo/expo/pull/10141) by [@cruzach](https://github.com/cruzach))
- Android apps no longer rely on the `submitButtonTitle` property as the action button title (they rely on `buttonTitle`, which matches iOS behavior). ([#10141](https://github.com/expo/expo/pull/10141) by [@cruzach](https://github.com/cruzach))
- Fixed `Notifications.requestPermissions()` returning `undetermined` instead of a known status in some browsers. ([#10296](https://github.com/expo/expo/pull/10296) by [@sjchmiela](https://github.com/sjchmiela))
- Fixed crashing when Proguard is enabled. ([#10421](https://github.com/expo/expo/pull/10421) by [@lukmccall](https://github.com/lukmccall))
- Fixed the application icon being always added as a notification icon. ([#10471](https://github.com/expo/expo/pull/10471) by [@lukmccall](https://github.com/lukmccall))
- Fixed faulty trigger detection mechanism which caused some triggers with `channelId` specified get recognized as triggers of other types. ([#10454](https://github.com/expo/expo/pull/10454) by [@sjchmiela](https://github.com/sjchmiela))
- Fixed fatal exception sometimes being thrown when notification was received or tapped on Android due to observer being cleared before it's added. ([#10640](https://github.com/expo/expo/pull/10640) by [@sjchmiela](https://github.com/sjchmiela))
- Removed the large icon from managed workflow. ([#10492](https://github.com/expo/expo/pull/10492) by [@lukmccall](https://github.com/lukmccall))
- Fixed crash happening due to non-existent `ExpoNotificationsService` being declared in `AndroidManifest.xml`. ([#10638](https://github.com/expo/expo/pull/10638) by [@sjchmiela](https://github.com/sjchmiela))
- Fixed notifications _not_ playing any sound when `shouldShowAlert: false` but `shouldPlaySound: true` in `setNotificationHandler`. ([#10699](https://github.com/expo/expo/pull/10699) by [@cruzach](https://github.com/cruzach))
- Add guard against badgin usage in SSR environments. ([#10741](https://github.com/expo/expo/pull/10741) by [@bycedric](https://github.com/bycedric))
- Moved notification events handling from main thread to a background thread which makes users' devices more responsive. ([#10762](https://github.com/expo/expo/pull/10762) by [@sjchmiela](https://github.com/sjchmiela))
- Fixed having to define `CATEGORY_DEFAULT` on an `Activity` that is expected to receive `expo.modules.notifications.OPEN_APP_ACTION` intent when handling notification response. ([#10755](https://github.com/expo/expo/pull/10755) by [@sjchmiela](https://github.com/sjchmiela))
- Fixed notifications not being returned at all from `getAllPresentedNotificationsAsync()` if the library fails to reconstruct notification request based on marshaled copy in notification data. From now on they'll be naively reconstructed from the Android notification. ([#10801](https://github.com/expo/expo/pull/10801) by [@sjchmiela](https://github.com/sjchmiela))
- May have helped fix an issue where "initial notification response" (the one that opened the app) was not being delivered to Android apps. ([#10773](https://github.com/expo/expo/pull/10773) by [@sjchmiela](https://github.com/sjchmiela))

@@ -91,3 +126,14 @@ ## 0.7.1 — 2020-08-26

> Note that the effect of this method is the same as if you called `Notifications.getPermissionsAsync()` (or `requestPermissionsAsync`) and then `Notifications.getDevicePushTokenAsync()`—it tries to both ask the user for user-facing notifications permissions and then tries to register the device for remote notifications. We are planning to deprecate the `.NOTIFICATIONS` permission soon.## 0.2.0 — 2020-05-27### 🛠 Breaking changes> Note that this may or may not be a breaking change for you — if you'd expect the notification to be automatically dismissed when tapped on this is a bug fix and a new feature (fixes inconsistency between platforms as on iOS this is the only supported behavior; adds the ability to customize the behavior on Android). If you'd expect the notification to only be dismissed at your will this is a breaking change and you'll need to add `autoDismiss: false` to your notification content inputs.- Changed the default notification behavior on Android to be automatically dismissed when clicked. This is customizable with the `autoDismiss` parameter of `NotificationContentInput`. ([#8241](https://github.com/expo/expo/pull/8241) by [@thorbenprimke](https://github.com/thorbenprimke))### 🎉 New features- Added the ability to configure whether the notification should be automatically dismissed when tapped on or not (on Android) with the `autoDismiss` parameter of `NotificationContentInput`. ([#8241](https://github.com/expo/expo/pull/8241) by [@thorbenprimke](https://github.com/thorbenprimke))
> Note that the effect of this method is the same as if you called `Notifications.getPermissionsAsync()` (or `requestPermissionsAsync`) and then `Notifications.getDevicePushTokenAsync()`—it tries to both ask the user for user-facing notifications permissions and then tries to register the device for remote notifications. We are planning to deprecate the `.NOTIFICATIONS` permission soon.
## 0.2.0 — 2020-05-27
### 🛠 Breaking changes
- > Note that this may or may not be a breaking change for you — if you'd expect the notification to be automatically dismissed when tapped on this is a bug fix and a new feature (fixes inconsistency between platforms as on iOS this is the only supported behavior; adds the ability to customize the behavior on Android). If you'd expect the notification to only be dismissed at your will this is a breaking change and you'll need to add `autoDismiss: false` to your notification content inputs.
Changed the default notification behavior on Android to be automatically dismissed when clicked. This is customizable with the `autoDismiss` parameter of `NotificationContentInput`. ([#8241](https://github.com/expo/expo/pull/8241) by [@thorbenprimke](https://github.com/thorbenprimke))
### 🎉 New features
- Added the ability to configure whether the notification should be automatically dismissed when tapped on or not (on Android) with the `autoDismiss` parameter of `NotificationContentInput`. ([#8241](https://github.com/expo/expo/pull/8241) by [@thorbenprimke](https://github.com/thorbenprimke))
- Added `DailyTriggerInput` that allows scheduling a daily recurring notification for a specific hour and minute. It is supported on both iOS and Android. ([#8199](https://github.com/expo/expo/pull/8199) by [@thorbenprimke](https://github.com/thorbenprimke))

@@ -94,0 +140,0 @@

{
"name": "expo-notifications",
"version": "0.7.2",
"version": "0.8.0",
"description": "Notifications module",

@@ -32,3 +32,3 @@ "main": "build/index.js",

"license": "MIT",
"homepage": "https://github.com/expo/expo/tree/master/packages/expo-notifications",
"homepage": "https://docs.expo.io/versions/latest/sdk/notifications/",
"jest": {

@@ -45,4 +45,4 @@ "preset": "expo-module-scripts/ios"

"badgin": "^1.1.5",
"expo-application": "~2.3.0",
"expo-constants": "9.2.0",
"expo-application": "~2.4.0",
"expo-constants": "9.3.0",
"uuid": "^3.4.0"

@@ -54,3 +54,3 @@ },

},
"gitHead": "a36598c63600807ae628fb5f401154f23507b0aa"
"gitHead": "bc6b4b3bc3cb5e44e477f145c72c07ed09588651"
}

@@ -1,3 +0,1 @@

import * as badgin from 'badgin';
import { BadgeModule } from './BadgeModule.types';

@@ -7,3 +5,3 @@

export default {
const badgeModule: BadgeModule = {
addListener: () => {},

@@ -14,3 +12,9 @@ removeListeners: () => {},

},
setBadgeCountAsync: async (badgeCount: number, options?: badgin.Options) => {
setBadgeCountAsync: async (badgeCount, options) => {
// If this module is loaded in SSR (NextJS), we can't modify the badge.
// It also can't load the badgin module, that instantly invokes methods on window.
if (typeof window === 'undefined') {
return false;
}
const badgin = require('badgin');
if (badgeCount > 0) {

@@ -24,2 +28,4 @@ badgin.set(badgeCount, options);

},
} as BadgeModule;
};
export default badgeModule;

@@ -24,2 +24,4 @@ export { default as getDevicePushTokenAsync } from './getDevicePushTokenAsync';

export { default as deleteNotificationCategoryAsync } from './deleteNotificationCategoryAsync';
export { default as getNextTriggerDateAsync } from './getNextTriggerDateAsync';
export { default as useLastNotificationResponse } from './useLastNotificationResponse';
export * from './TokenEmitter';

@@ -26,0 +28,0 @@ export * from './NotificationsEmitter';

@@ -18,3 +18,3 @@ import { ProxyNativeModule } from '@unimodules/core';

showSubtitle?: boolean;
allowAnnouncment?: boolean;
allowAnnouncement?: boolean;
}

@@ -21,0 +21,0 @@ ) => Promise<NotificationCategory>;

@@ -25,3 +25,3 @@ import { ProxyNativeModule } from '@unimodules/core';

DEFAULT = 5,
/** @deprecated use DEFAULT instead */
/** @deprecated use `DEFAULT` instead */
DEEFAULT = 5,

@@ -28,0 +28,0 @@ HIGH = 6,

@@ -51,3 +51,15 @@ import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';

if (shouldAsk) {
status = await Notification.requestPermission();
status = await new Promise((resolve, reject) => {
let resolved = false;
function resolveOnce(status: string) {
if (!resolved) {
resolved = true;
resolve(status);
}
}
// Some browsers require a callback argument and some return a Promise
Notification.requestPermission(resolveOnce)
?.then(resolveOnce)
?.catch(reject);
});
}

@@ -54,0 +66,0 @@ return convertPermissionStatus(status);

import { CalendarTriggerInput as NativeCalendarTriggerInput } from './NotificationScheduler.types';
export interface PushNotificationTrigger {
type: 'push';
remoteMessage?: FirebaseRemoteMessage;
}
/**
* `payload` is set only on iOS,
* `remoteMessage` is set only on Android,
* no extra entry is for Web
*/
export type PushNotificationTrigger = { type: 'push' } & (
| { payload: Record<string, unknown> }
| { remoteMessage: FirebaseRemoteMessage }
// eslint-disable-next-line @typescript-eslint/ban-types
| {}
);

@@ -79,2 +86,9 @@ export interface CalendarNotificationTrigger {

export interface WeeklyNotificationTrigger {
type: 'weekly';
weekday: number;
hour: number;
minute: number;
}
export interface FirebaseRemoteMessage {

@@ -131,2 +145,3 @@ collapseKey: string | null;

| DailyNotificationTrigger
| WeeklyNotificationTrigger
| UnknownNotificationTrigger;

@@ -153,12 +168,25 @@

}
export interface WeeklyTriggerInput {
channelId?: string;
weekday: number;
hour: number;
minute: number;
repeats: true;
}
export type DateTriggerInput = Date | number | { channelId?: string; date: Date | number };
export type NotificationTriggerInput =
| null
| ChannelAwareTriggerInput
export type SchedulableNotificationTriggerInput =
| DateTriggerInput
| TimeIntervalTriggerInput
| DailyTriggerInput
| WeeklyTriggerInput
| CalendarTriggerInput;
export type NotificationTriggerInput =
| null
| ChannelAwareTriggerInput
| SchedulableNotificationTriggerInput;
export enum AndroidNotificationPriority {

@@ -165,0 +193,0 @@ MIN = 'min',

@@ -14,2 +14,3 @@ import { ProxyNativeModule } from '@unimodules/core';

cancelAllScheduledNotificationsAsync?: () => Promise<void>;
getNextTriggerDateAsync?: (trigger: NotificationTriggerInput) => Promise<number>;
}

@@ -58,2 +59,10 @@

export interface WeeklyTriggerInput {
type: 'weekly';
channelId?: string;
weekday: number;
hour: number;
minute: number;
}
export interface DateTriggerInput {

@@ -71,2 +80,3 @@ type: 'date';

| TimeIntervalTriggerInput
| DailyTriggerInput;
| DailyTriggerInput
| WeeklyTriggerInput;

@@ -37,7 +37,1 @@ import { EventEmitter, Subscription } from '@unimodules/core';

}
export function removeAllNotificationListeners() {
emitter.removeAllListeners(didReceiveNotificationEventName);
emitter.removeAllListeners(didDropNotificationsEventName);
emitter.removeAllListeners(didReceiveNotificationResponseEventName);
}
import { ProxyNativeModule } from '@unimodules/core';
export interface NotificationsEmitterModule extends ProxyNativeModule {}
import { NotificationResponse } from './Notifications.types';
export interface NotificationsEmitterModule extends ProxyNativeModule {
getLastNotificationResponseAsync?: () => Promise<NotificationResponse | null>;
}

@@ -9,2 +9,6 @@ import { UnavailabilityError } from '@unimodules/core';

/**
* @deprecated Use `scheduleNotificationAsync` with an explicit notification handler.
* [Read more](https://expo.fyi/presenting-notifications-deprecated).
*/
export default async function presentNotificationAsync(

@@ -11,0 +15,0 @@ content: NotificationContentInput,

@@ -1,2 +0,2 @@

import { UnavailabilityError } from '@unimodules/core';
import { Platform, UnavailabilityError } from '@unimodules/core';
import uuidv4 from 'uuid/v4';

@@ -10,2 +10,3 @@

DailyTriggerInput,
WeeklyTriggerInput,
CalendarTriggerInput,

@@ -31,3 +32,5 @@ TimeIntervalTriggerInput,

function parseTrigger(userFacingTrigger: NotificationTriggerInput): NativeNotificationTriggerInput {
export function parseTrigger(
userFacingTrigger: NotificationTriggerInput
): NativeNotificationTriggerInput {
if (userFacingTrigger === null) {

@@ -63,2 +66,32 @@ return null;

};
} else if (isWeeklyTriggerInput(userFacingTrigger)) {
const weekday = userFacingTrigger.weekday;
const hour = userFacingTrigger.hour;
const minute = userFacingTrigger.minute;
if (
weekday === undefined ||
weekday == null ||
hour === undefined ||
hour == null ||
minute === undefined ||
minute == null
) {
throw new TypeError('Weekday, hour and minute need to have valid values. Found undefined');
}
if (weekday < 1 || weekday > 7) {
throw new RangeError(`The weekday parameter needs to be between 1 and 7. Found: ${weekday}`);
}
if (hour < 0 || hour > 23) {
throw new RangeError(`The hour parameter needs to be between 0 and 23. Found: ${hour}`);
}
if (minute < 0 || minute > 59) {
throw new RangeError(`The minute parameter needs to be between 0 and 59. Found: ${minute}`);
}
return {
type: 'weekly',
channelId: userFacingTrigger.channelId,
weekday,
hour,
minute,
};
} else if (isSecondsPropertyMisusedInCalendarTriggerInput(userFacingTrigger)) {

@@ -79,4 +112,6 @@ throw new TypeError(

} else {
// @ts-ignore Type '"channel"' is not assignable to type '"daily"'.ts(2322)
return { type: 'channel', channelId: userFacingTrigger.channelId };
return Platform.select({
default: null, // There's no notion of channels on platforms other than Android.
android: { type: 'channel', channelId: userFacingTrigger.channelId },
});
}

@@ -93,3 +128,8 @@ }

function isDateTrigger(
trigger: DateTriggerInput | DailyTriggerInput | CalendarTriggerInput | TimeIntervalTriggerInput
trigger:
| DateTriggerInput
| WeeklyTriggerInput
| DailyTriggerInput
| CalendarTriggerInput
| TimeIntervalTriggerInput
): trigger is DateTriggerInput {

@@ -99,3 +139,3 @@ return (

typeof trigger === 'number' ||
(typeof trigger === 'object' && trigger['date'])
(typeof trigger === 'object' && 'date' in trigger)
);

@@ -119,13 +159,28 @@ }

function isDailyTriggerInput(
trigger: DailyTriggerInput | CalendarTriggerInput | TimeIntervalTriggerInput
trigger: WeeklyTriggerInput | DailyTriggerInput | CalendarTriggerInput | TimeIntervalTriggerInput
): trigger is DailyTriggerInput {
const { channelId, ...triggerWithoutChannelId } = trigger;
return (
Object.keys(trigger).length === 3 &&
'hour' in trigger &&
'minute' in trigger &&
'repeats' in trigger &&
trigger.repeats === true
Object.keys(triggerWithoutChannelId).length === 3 &&
'hour' in triggerWithoutChannelId &&
'minute' in triggerWithoutChannelId &&
'repeats' in triggerWithoutChannelId &&
triggerWithoutChannelId.repeats === true
);
}
function isWeeklyTriggerInput(
trigger: WeeklyTriggerInput | DailyTriggerInput | CalendarTriggerInput | TimeIntervalTriggerInput
): trigger is WeeklyTriggerInput {
const { channelId, ...triggerWithoutChannelId } = trigger;
return (
Object.keys(triggerWithoutChannelId).length === 4 &&
'weekday' in triggerWithoutChannelId &&
'hour' in triggerWithoutChannelId &&
'minute' in triggerWithoutChannelId &&
'repeats' in triggerWithoutChannelId &&
triggerWithoutChannelId.repeats === true
);
}
function isSecondsPropertyMisusedInCalendarTriggerInput(

@@ -132,0 +187,0 @@ trigger: TimeIntervalTriggerInput | CalendarTriggerInput

@@ -17,3 +17,3 @@ import { UnavailabilityError } from '@unimodules/core';

showSubtitle?: boolean;
allowAnnouncment?: boolean;
allowAnnouncement?: boolean;
}

@@ -20,0 +20,0 @@ ): Promise<NotificationCategory> {

@@ -1,2 +0,2 @@

import { Platform } from 'react-native';
import { Platform } from '@unimodules/core';

@@ -3,0 +3,0 @@ export interface NativeDevicePushToken {

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 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 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 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