From 168cea12d97e74ae432f9fce262d96f9f1b898e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 15:48:14 +0200 Subject: [PATCH 01/17] [expo-notifications] Fix types and add web support for NotificationScheduler --- .../build/NotificationScheduler.d.ts | 10 +--------- .../build/NotificationScheduler.js.map | 2 +- .../build/NotificationScheduler.types.d.ts | 8 ++++++++ .../build/NotificationScheduler.types.js.map | 2 +- .../cancelAllScheduledNotificationsAsync.js | 4 ++-- .../cancelAllScheduledNotificationsAsync.js.map | 2 +- .../build/getAllScheduledNotificationsAsync.js | 4 ++++ .../getAllScheduledNotificationsAsync.js.map | 2 +- .../build/scheduleNotificationAsync.js | 4 ++++ .../build/scheduleNotificationAsync.js.map | 2 +- .../src/NotificationScheduler.ts | 16 ++-------------- .../src/NotificationScheduler.types.ts | 15 +++++++++++++++ .../src/cancelAllScheduledNotificationsAsync.ts | 4 ++-- .../src/getAllScheduledNotificationsAsync.ts | 6 ++++++ .../src/scheduleNotificationAsync.ts | 5 +++++ 15 files changed, 54 insertions(+), 32 deletions(-) diff --git a/packages/expo-notifications/build/NotificationScheduler.d.ts b/packages/expo-notifications/build/NotificationScheduler.d.ts index d3680f744da3f..5d8ed08a573d0 100644 --- a/packages/expo-notifications/build/NotificationScheduler.d.ts +++ b/packages/expo-notifications/build/NotificationScheduler.d.ts @@ -1,11 +1,3 @@ -import { ProxyNativeModule } from '@unimodules/core'; -import { NotificationTriggerInput } from './NotificationScheduler.types'; -import { NotificationRequest, NotificationContentInput } from './Notifications.types'; -export interface NotificationSchedulerModule extends ProxyNativeModule { - getAllScheduledNotificationsAsync: () => Promise; - scheduleNotificationAsync: (identifier: string, notificationContent: NotificationContentInput, trigger: NotificationTriggerInput) => Promise; - cancelScheduledNotificationAsync: (identifier: string) => Promise; - cancelAllScheduledNotificationsAsync: () => Promise; -} +import { NotificationSchedulerModule } from './NotificationScheduler.types'; declare const _default: NotificationSchedulerModule; export default _default; diff --git a/packages/expo-notifications/build/NotificationScheduler.js.map b/packages/expo-notifications/build/NotificationScheduler.js.map index e18a8edf8394d..1355706d0577b 100644 --- a/packages/expo-notifications/build/NotificationScheduler.js.map +++ b/packages/expo-notifications/build/NotificationScheduler.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationScheduler.js","sourceRoot":"","sources":["../src/NotificationScheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,kBAAkB,CAAC;AAgBzE,eAAgB,kBAAkB,CAAC,yBAAgE,CAAC","sourcesContent":["import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core';\n\nimport { NotificationTriggerInput } from './NotificationScheduler.types';\nimport { NotificationRequest, NotificationContentInput } from './Notifications.types';\n\nexport interface NotificationSchedulerModule extends ProxyNativeModule {\n getAllScheduledNotificationsAsync: () => Promise;\n scheduleNotificationAsync: (\n identifier: string,\n notificationContent: NotificationContentInput,\n trigger: NotificationTriggerInput\n ) => Promise;\n cancelScheduledNotificationAsync: (identifier: string) => Promise;\n cancelAllScheduledNotificationsAsync: () => Promise;\n}\n\nexport default (NativeModulesProxy.ExpoNotificationScheduler as any) as NotificationSchedulerModule;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationScheduler.js","sourceRoot":"","sources":["../src/NotificationScheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,yBAAgE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationSchedulerModule } from './NotificationScheduler.types';\n\nexport default (NativeModulesProxy.ExpoNotificationScheduler as any) as NotificationSchedulerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationScheduler.types.d.ts b/packages/expo-notifications/build/NotificationScheduler.types.d.ts index 7afd02c430cad..aefd8728f06a9 100644 --- a/packages/expo-notifications/build/NotificationScheduler.types.d.ts +++ b/packages/expo-notifications/build/NotificationScheduler.types.d.ts @@ -1,3 +1,11 @@ +import { ProxyNativeModule } from '@unimodules/core'; +import { NotificationRequest, NotificationContentInput } from './Notifications.types'; +export interface NotificationSchedulerModule extends ProxyNativeModule { + getAllScheduledNotificationsAsync?: () => Promise; + scheduleNotificationAsync?: (identifier: string, notificationContent: NotificationContentInput, trigger: NotificationTriggerInput) => Promise; + cancelScheduledNotificationAsync?: (identifier: string) => Promise; + cancelAllScheduledNotificationsAsync?: () => Promise; +} export interface CalendarTriggerInput { type: 'calendar'; repeats?: boolean; diff --git a/packages/expo-notifications/build/NotificationScheduler.types.js.map b/packages/expo-notifications/build/NotificationScheduler.types.js.map index 3a933b8314d5a..ee84890a48cde 100644 --- a/packages/expo-notifications/build/NotificationScheduler.types.js.map +++ b/packages/expo-notifications/build/NotificationScheduler.types.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationScheduler.types.js","sourceRoot":"","sources":["../src/NotificationScheduler.types.ts"],"names":[],"mappings":"","sourcesContent":["// ISO8601 calendar pattern-matching\nexport interface CalendarTriggerInput {\n type: 'calendar';\n repeats?: boolean;\n value: {\n timezone?: string;\n\n year?: number;\n month?: number;\n weekday?: number;\n weekOfMonth?: number;\n weekOfYear?: number;\n weekdayOrdinal?: number;\n day?: number;\n\n hour?: number;\n minute?: number;\n second?: number;\n };\n}\n\nexport interface TimeIntervalTriggerInput {\n type: 'timeInterval';\n repeats: boolean;\n seconds: number;\n}\n\nexport interface DailyTriggerInput {\n type: 'daily';\n hour: number;\n minute: number;\n}\n\nexport interface DateTriggerInput {\n type: 'date';\n timestamp: number; // seconds since 1970\n}\n\nexport type NotificationTriggerInput =\n | null\n | DateTriggerInput\n | CalendarTriggerInput\n | TimeIntervalTriggerInput\n | DailyTriggerInput;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationScheduler.types.js","sourceRoot":"","sources":["../src/NotificationScheduler.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\n\nimport { NotificationRequest, NotificationContentInput } from './Notifications.types';\n\nexport interface NotificationSchedulerModule extends ProxyNativeModule {\n getAllScheduledNotificationsAsync?: () => Promise;\n scheduleNotificationAsync?: (\n identifier: string,\n notificationContent: NotificationContentInput,\n trigger: NotificationTriggerInput\n ) => Promise;\n cancelScheduledNotificationAsync?: (identifier: string) => Promise;\n cancelAllScheduledNotificationsAsync?: () => Promise;\n}\n\n// ISO8601 calendar pattern-matching\nexport interface CalendarTriggerInput {\n type: 'calendar';\n repeats?: boolean;\n value: {\n timezone?: string;\n\n year?: number;\n month?: number;\n weekday?: number;\n weekOfMonth?: number;\n weekOfYear?: number;\n weekdayOrdinal?: number;\n day?: number;\n\n hour?: number;\n minute?: number;\n second?: number;\n };\n}\n\nexport interface TimeIntervalTriggerInput {\n type: 'timeInterval';\n repeats: boolean;\n seconds: number;\n}\n\nexport interface DailyTriggerInput {\n type: 'daily';\n hour: number;\n minute: number;\n}\n\nexport interface DateTriggerInput {\n type: 'date';\n timestamp: number; // seconds since 1970\n}\n\nexport type NotificationTriggerInput =\n | null\n | DateTriggerInput\n | CalendarTriggerInput\n | TimeIntervalTriggerInput\n | DailyTriggerInput;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js b/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js index 13005fa351e9f..f2527940b66a6 100644 --- a/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js +++ b/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js @@ -1,8 +1,8 @@ import { UnavailabilityError } from '@unimodules/core'; import NotificationScheduler from './NotificationScheduler'; export default async function cancelScheduledNotificationAsync() { - if (!NotificationScheduler.cancelScheduledNotificationAsync) { - throw new UnavailabilityError('Notifications', 'cancelScheduledNotificationAsync'); + if (!NotificationScheduler.cancelAllScheduledNotificationsAsync) { + throw new UnavailabilityError('Notifications', 'cancelAllScheduledNotificationsAsync'); } return await NotificationScheduler.cancelAllScheduledNotificationsAsync(); } diff --git a/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js.map b/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js.map index 82f435ca3cc46..41ddc6e2f188a 100644 --- a/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js.map +++ b/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js.map @@ -1 +1 @@ -{"version":3,"file":"cancelAllScheduledNotificationsAsync.js","sourceRoot":"","sources":["../src/cancelAllScheduledNotificationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gCAAgC;IAC5D,IAAI,CAAC,qBAAqB,CAAC,gCAAgC,EAAE;QAC3D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,kCAAkC,CAAC,CAAC;KACpF;IAED,OAAO,MAAM,qBAAqB,CAAC,oCAAoC,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport NotificationScheduler from './NotificationScheduler';\n\nexport default async function cancelScheduledNotificationAsync(): Promise {\n if (!NotificationScheduler.cancelScheduledNotificationAsync) {\n throw new UnavailabilityError('Notifications', 'cancelScheduledNotificationAsync');\n }\n\n return await NotificationScheduler.cancelAllScheduledNotificationsAsync();\n}\n"]} \ No newline at end of file +{"version":3,"file":"cancelAllScheduledNotificationsAsync.js","sourceRoot":"","sources":["../src/cancelAllScheduledNotificationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gCAAgC;IAC5D,IAAI,CAAC,qBAAqB,CAAC,oCAAoC,EAAE;QAC/D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,sCAAsC,CAAC,CAAC;KACxF;IAED,OAAO,MAAM,qBAAqB,CAAC,oCAAoC,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport NotificationScheduler from './NotificationScheduler';\n\nexport default async function cancelScheduledNotificationAsync(): Promise {\n if (!NotificationScheduler.cancelAllScheduledNotificationsAsync) {\n throw new UnavailabilityError('Notifications', 'cancelAllScheduledNotificationsAsync');\n }\n\n return await NotificationScheduler.cancelAllScheduledNotificationsAsync();\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/getAllScheduledNotificationsAsync.js b/packages/expo-notifications/build/getAllScheduledNotificationsAsync.js index 7905e80f5793a..3e7ccb1cff451 100644 --- a/packages/expo-notifications/build/getAllScheduledNotificationsAsync.js +++ b/packages/expo-notifications/build/getAllScheduledNotificationsAsync.js @@ -1,5 +1,9 @@ +import { UnavailabilityError } from '@unimodules/core'; import NotificationScheduler from './NotificationScheduler'; export default async function getAllScheduledNotificationsAsync() { + if (!NotificationScheduler.getAllScheduledNotificationsAsync) { + throw new UnavailabilityError('Notifications', 'getAllScheduledNotificationsAsync'); + } return await NotificationScheduler.getAllScheduledNotificationsAsync(); } //# sourceMappingURL=getAllScheduledNotificationsAsync.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/getAllScheduledNotificationsAsync.js.map b/packages/expo-notifications/build/getAllScheduledNotificationsAsync.js.map index 1e65e47d031e0..7c77d38072a50 100644 --- a/packages/expo-notifications/build/getAllScheduledNotificationsAsync.js.map +++ b/packages/expo-notifications/build/getAllScheduledNotificationsAsync.js.map @@ -1 +1 @@ -{"version":3,"file":"getAllScheduledNotificationsAsync.js","sourceRoot":"","sources":["../src/getAllScheduledNotificationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAG5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,iCAAiC;IAC7D,OAAO,MAAM,qBAAqB,CAAC,iCAAiC,EAAE,CAAC;AACzE,CAAC","sourcesContent":["import NotificationScheduler from './NotificationScheduler';\nimport { NotificationRequest } from './Notifications.types';\n\nexport default async function getAllScheduledNotificationsAsync(): Promise {\n return await NotificationScheduler.getAllScheduledNotificationsAsync();\n}\n"]} \ No newline at end of file +{"version":3,"file":"getAllScheduledNotificationsAsync.js","sourceRoot":"","sources":["../src/getAllScheduledNotificationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAG5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,iCAAiC;IAC7D,IAAI,CAAC,qBAAqB,CAAC,iCAAiC,EAAE;QAC5D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,mCAAmC,CAAC,CAAC;KACrF;IAED,OAAO,MAAM,qBAAqB,CAAC,iCAAiC,EAAE,CAAC;AACzE,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport NotificationScheduler from './NotificationScheduler';\nimport { NotificationRequest } from './Notifications.types';\n\nexport default async function getAllScheduledNotificationsAsync(): Promise {\n if (!NotificationScheduler.getAllScheduledNotificationsAsync) {\n throw new UnavailabilityError('Notifications', 'getAllScheduledNotificationsAsync');\n }\n\n return await NotificationScheduler.getAllScheduledNotificationsAsync();\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/scheduleNotificationAsync.js b/packages/expo-notifications/build/scheduleNotificationAsync.js index 8d2b5dd54676e..d96b3e487d520 100644 --- a/packages/expo-notifications/build/scheduleNotificationAsync.js +++ b/packages/expo-notifications/build/scheduleNotificationAsync.js @@ -1,6 +1,10 @@ +import { UnavailabilityError } from '@unimodules/core'; import uuidv4 from 'uuid/v4'; import NotificationScheduler from './NotificationScheduler'; export default async function scheduleNotificationAsync(request) { + if (!NotificationScheduler.scheduleNotificationAsync) { + throw new UnavailabilityError('Notifications', 'scheduleNotificationAsync'); + } return await NotificationScheduler.scheduleNotificationAsync(request.identifier ?? uuidv4(), request.content, parseTrigger(request.trigger)); } function parseTrigger(userFacingTrigger) { diff --git a/packages/expo-notifications/build/scheduleNotificationAsync.js.map b/packages/expo-notifications/build/scheduleNotificationAsync.js.map index 8f07ca5c940c3..ccc439ff41e3f 100644 --- a/packages/expo-notifications/build/scheduleNotificationAsync.js.map +++ b/packages/expo-notifications/build/scheduleNotificationAsync.js.map @@ -1 +1 @@ -{"version":3,"file":"scheduleNotificationAsync.js","sourceRoot":"","sources":["../src/scheduleNotificationAsync.ts"],"names":[],"mappings":"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","sourcesContent":["import uuidv4 from 'uuid/v4';\n\nimport NotificationScheduler from './NotificationScheduler';\nimport { NotificationTriggerInput as NativeNotificationTriggerInput } from './NotificationScheduler.types';\nimport {\n NotificationRequestInput,\n NotificationTriggerInput,\n DailyTriggerInput,\n CalendarTriggerInput,\n TimeIntervalTriggerInput,\n} from './Notifications.types';\n\nexport default async function scheduleNotificationAsync(\n request: NotificationRequestInput\n): Promise {\n return await NotificationScheduler.scheduleNotificationAsync(\n request.identifier ?? uuidv4(),\n request.content,\n parseTrigger(request.trigger)\n );\n}\n\nfunction parseTrigger(userFacingTrigger: NotificationTriggerInput): NativeNotificationTriggerInput {\n if (userFacingTrigger === null) {\n return null;\n }\n\n if (userFacingTrigger === undefined) {\n throw new TypeError(\n 'Encountered an `undefined` notification trigger. If you want to trigger the notification immediately, pass in an explicit `null` value.'\n );\n }\n\n if (userFacingTrigger instanceof Date) {\n return { type: 'date', timestamp: userFacingTrigger.getTime() };\n } else if (typeof userFacingTrigger === 'number') {\n return { type: 'date', timestamp: userFacingTrigger };\n } else if (isDailyTriggerInput(userFacingTrigger)) {\n const hour = userFacingTrigger.hour;\n const minute = userFacingTrigger.minute;\n if (hour === undefined || hour == null || minute === undefined || minute == null) {\n throw new TypeError('Both hour and minute need to have valid values. Found undefined');\n }\n if (hour < 0 || hour > 23) {\n throw new RangeError(`The hour parameter needs to be between 0 and 23. Found: ${hour}`);\n }\n if (minute < 0 || minute > 59) {\n throw new RangeError(`The minute parameter needs to be between 0 and 59. Found: ${minute}`);\n }\n return {\n type: 'daily',\n hour,\n minute,\n };\n } else if (isSecondsPropertyMisusedInCalendarTriggerInput(userFacingTrigger)) {\n throw new TypeError(\n '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`.'\n );\n } else if ('seconds' in userFacingTrigger) {\n return {\n type: 'timeInterval',\n seconds: userFacingTrigger.seconds,\n repeats: userFacingTrigger.repeats ?? false,\n };\n } else {\n const { repeats, ...calendarTrigger } = userFacingTrigger;\n return { type: 'calendar', value: calendarTrigger, repeats };\n }\n}\n\nfunction isDailyTriggerInput(\n trigger: DailyTriggerInput | CalendarTriggerInput | TimeIntervalTriggerInput\n): trigger is DailyTriggerInput {\n return (\n Object.keys(trigger).length === 3 &&\n 'hour' in trigger &&\n 'minute' in trigger &&\n 'repeats' in trigger &&\n trigger.repeats === true\n );\n}\n\nfunction isSecondsPropertyMisusedInCalendarTriggerInput(\n trigger: TimeIntervalTriggerInput | CalendarTriggerInput\n) {\n return (\n // eg. { seconds: ..., repeats: ..., hour: ... }\n ('seconds' in trigger && 'repeats' in trigger && Object.keys(trigger).length > 2) ||\n // eg. { seconds: ..., hour: ... }\n ('seconds' in trigger && !('repeats' in trigger) && Object.keys(trigger).length > 1)\n );\n}\n"]} \ No newline at end of file +{"version":3,"file":"scheduleNotificationAsync.js","sourceRoot":"","sources":["../src/scheduleNotificationAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAU5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,yBAAyB,CACrD,OAAiC;IAEjC,IAAI,CAAC,qBAAqB,CAAC,yBAAyB,EAAE;QACpD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAAC;KAC7E;IAED,OAAO,MAAM,qBAAqB,CAAC,yBAAyB,CAC1D,OAAO,CAAC,UAAU,IAAI,MAAM,EAAE,EAC9B,OAAO,CAAC,OAAO,EACf,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAC9B,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,iBAA2C;IAC/D,IAAI,iBAAiB,KAAK,IAAI,EAAE;QAC9B,OAAO,IAAI,CAAC;KACb;IAED,IAAI,iBAAiB,KAAK,SAAS,EAAE;QACnC,MAAM,IAAI,SAAS,CACjB,yIAAyI,CAC1I,CAAC;KACH;IAED,IAAI,iBAAiB,YAAY,IAAI,EAAE;QACrC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,CAAC,OAAO,EAAE,EAAE,CAAC;KACjE;SAAM,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;QAChD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;KACvD;SAAM,IAAI,mBAAmB,CAAC,iBAAiB,CAAC,EAAE;QACjD,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC;QACpC,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC;QACxC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,IAAI,IAAI,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,IAAI,IAAI,EAAE;YAChF,MAAM,IAAI,SAAS,CAAC,iEAAiE,CAAC,CAAC;SACxF;QACD,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,EAAE,EAAE;YACzB,MAAM,IAAI,UAAU,CAAC,2DAA2D,IAAI,EAAE,CAAC,CAAC;SACzF;QACD,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,EAAE,EAAE;YAC7B,MAAM,IAAI,UAAU,CAAC,6DAA6D,MAAM,EAAE,CAAC,CAAC;SAC7F;QACD,OAAO;YACL,IAAI,EAAE,OAAO;YACb,IAAI;YACJ,MAAM;SACP,CAAC;KACH;SAAM,IAAI,8CAA8C,CAAC,iBAAiB,CAAC,EAAE;QAC5E,MAAM,IAAI,SAAS,CACjB,4NAA4N,CAC7N,CAAC;KACH;SAAM,IAAI,SAAS,IAAI,iBAAiB,EAAE;QACzC,OAAO;YACL,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,iBAAiB,CAAC,OAAO;YAClC,OAAO,EAAE,iBAAiB,CAAC,OAAO,IAAI,KAAK;SAC5C,CAAC;KACH;SAAM;QACL,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe,EAAE,GAAG,iBAAiB,CAAC;QAC1D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;KAC9D;AACH,CAAC;AAED,SAAS,mBAAmB,CAC1B,OAA4E;IAE5E,OAAO,CACL,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC;QACjC,MAAM,IAAI,OAAO;QACjB,QAAQ,IAAI,OAAO;QACnB,SAAS,IAAI,OAAO;QACpB,OAAO,CAAC,OAAO,KAAK,IAAI,CACzB,CAAC;AACJ,CAAC;AAED,SAAS,8CAA8C,CACrD,OAAwD;IAExD,OAAO;IACL,gDAAgD;IAChD,CAAC,SAAS,IAAI,OAAO,IAAI,SAAS,IAAI,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QACjF,kCAAkC;QAClC,CAAC,SAAS,IAAI,OAAO,IAAI,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CACrF,CAAC;AACJ,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\nimport uuidv4 from 'uuid/v4';\n\nimport NotificationScheduler from './NotificationScheduler';\nimport { NotificationTriggerInput as NativeNotificationTriggerInput } from './NotificationScheduler.types';\nimport {\n NotificationRequestInput,\n NotificationTriggerInput,\n DailyTriggerInput,\n CalendarTriggerInput,\n TimeIntervalTriggerInput,\n} from './Notifications.types';\n\nexport default async function scheduleNotificationAsync(\n request: NotificationRequestInput\n): Promise {\n if (!NotificationScheduler.scheduleNotificationAsync) {\n throw new UnavailabilityError('Notifications', 'scheduleNotificationAsync');\n }\n\n return await NotificationScheduler.scheduleNotificationAsync(\n request.identifier ?? uuidv4(),\n request.content,\n parseTrigger(request.trigger)\n );\n}\n\nfunction parseTrigger(userFacingTrigger: NotificationTriggerInput): NativeNotificationTriggerInput {\n if (userFacingTrigger === null) {\n return null;\n }\n\n if (userFacingTrigger === undefined) {\n throw new TypeError(\n 'Encountered an `undefined` notification trigger. If you want to trigger the notification immediately, pass in an explicit `null` value.'\n );\n }\n\n if (userFacingTrigger instanceof Date) {\n return { type: 'date', timestamp: userFacingTrigger.getTime() };\n } else if (typeof userFacingTrigger === 'number') {\n return { type: 'date', timestamp: userFacingTrigger };\n } else if (isDailyTriggerInput(userFacingTrigger)) {\n const hour = userFacingTrigger.hour;\n const minute = userFacingTrigger.minute;\n if (hour === undefined || hour == null || minute === undefined || minute == null) {\n throw new TypeError('Both hour and minute need to have valid values. Found undefined');\n }\n if (hour < 0 || hour > 23) {\n throw new RangeError(`The hour parameter needs to be between 0 and 23. Found: ${hour}`);\n }\n if (minute < 0 || minute > 59) {\n throw new RangeError(`The minute parameter needs to be between 0 and 59. Found: ${minute}`);\n }\n return {\n type: 'daily',\n hour,\n minute,\n };\n } else if (isSecondsPropertyMisusedInCalendarTriggerInput(userFacingTrigger)) {\n throw new TypeError(\n '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`.'\n );\n } else if ('seconds' in userFacingTrigger) {\n return {\n type: 'timeInterval',\n seconds: userFacingTrigger.seconds,\n repeats: userFacingTrigger.repeats ?? false,\n };\n } else {\n const { repeats, ...calendarTrigger } = userFacingTrigger;\n return { type: 'calendar', value: calendarTrigger, repeats };\n }\n}\n\nfunction isDailyTriggerInput(\n trigger: DailyTriggerInput | CalendarTriggerInput | TimeIntervalTriggerInput\n): trigger is DailyTriggerInput {\n return (\n Object.keys(trigger).length === 3 &&\n 'hour' in trigger &&\n 'minute' in trigger &&\n 'repeats' in trigger &&\n trigger.repeats === true\n );\n}\n\nfunction isSecondsPropertyMisusedInCalendarTriggerInput(\n trigger: TimeIntervalTriggerInput | CalendarTriggerInput\n) {\n return (\n // eg. { seconds: ..., repeats: ..., hour: ... }\n ('seconds' in trigger && 'repeats' in trigger && Object.keys(trigger).length > 2) ||\n // eg. { seconds: ..., hour: ... }\n ('seconds' in trigger && !('repeats' in trigger) && Object.keys(trigger).length > 1)\n );\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/NotificationScheduler.ts b/packages/expo-notifications/src/NotificationScheduler.ts index ac2058683337e..bf9f2833d587c 100644 --- a/packages/expo-notifications/src/NotificationScheduler.ts +++ b/packages/expo-notifications/src/NotificationScheduler.ts @@ -1,17 +1,5 @@ -import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core'; +import { NativeModulesProxy } from '@unimodules/core'; -import { NotificationTriggerInput } from './NotificationScheduler.types'; -import { NotificationRequest, NotificationContentInput } from './Notifications.types'; - -export interface NotificationSchedulerModule extends ProxyNativeModule { - getAllScheduledNotificationsAsync: () => Promise; - scheduleNotificationAsync: ( - identifier: string, - notificationContent: NotificationContentInput, - trigger: NotificationTriggerInput - ) => Promise; - cancelScheduledNotificationAsync: (identifier: string) => Promise; - cancelAllScheduledNotificationsAsync: () => Promise; -} +import { NotificationSchedulerModule } from './NotificationScheduler.types'; export default (NativeModulesProxy.ExpoNotificationScheduler as any) as NotificationSchedulerModule; diff --git a/packages/expo-notifications/src/NotificationScheduler.types.ts b/packages/expo-notifications/src/NotificationScheduler.types.ts index e240ded25c60b..6cadfd1692acf 100644 --- a/packages/expo-notifications/src/NotificationScheduler.types.ts +++ b/packages/expo-notifications/src/NotificationScheduler.types.ts @@ -1,3 +1,18 @@ +import { ProxyNativeModule } from '@unimodules/core'; + +import { NotificationRequest, NotificationContentInput } from './Notifications.types'; + +export interface NotificationSchedulerModule extends ProxyNativeModule { + getAllScheduledNotificationsAsync?: () => Promise; + scheduleNotificationAsync?: ( + identifier: string, + notificationContent: NotificationContentInput, + trigger: NotificationTriggerInput + ) => Promise; + cancelScheduledNotificationAsync?: (identifier: string) => Promise; + cancelAllScheduledNotificationsAsync?: () => Promise; +} + // ISO8601 calendar pattern-matching export interface CalendarTriggerInput { type: 'calendar'; diff --git a/packages/expo-notifications/src/cancelAllScheduledNotificationsAsync.ts b/packages/expo-notifications/src/cancelAllScheduledNotificationsAsync.ts index 89ea7836ba2c9..221691756cbfd 100644 --- a/packages/expo-notifications/src/cancelAllScheduledNotificationsAsync.ts +++ b/packages/expo-notifications/src/cancelAllScheduledNotificationsAsync.ts @@ -3,8 +3,8 @@ import { UnavailabilityError } from '@unimodules/core'; import NotificationScheduler from './NotificationScheduler'; export default async function cancelScheduledNotificationAsync(): Promise { - if (!NotificationScheduler.cancelScheduledNotificationAsync) { - throw new UnavailabilityError('Notifications', 'cancelScheduledNotificationAsync'); + if (!NotificationScheduler.cancelAllScheduledNotificationsAsync) { + throw new UnavailabilityError('Notifications', 'cancelAllScheduledNotificationsAsync'); } return await NotificationScheduler.cancelAllScheduledNotificationsAsync(); diff --git a/packages/expo-notifications/src/getAllScheduledNotificationsAsync.ts b/packages/expo-notifications/src/getAllScheduledNotificationsAsync.ts index 32bfb632faf05..df6d058172e28 100644 --- a/packages/expo-notifications/src/getAllScheduledNotificationsAsync.ts +++ b/packages/expo-notifications/src/getAllScheduledNotificationsAsync.ts @@ -1,6 +1,12 @@ +import { UnavailabilityError } from '@unimodules/core'; + import NotificationScheduler from './NotificationScheduler'; import { NotificationRequest } from './Notifications.types'; export default async function getAllScheduledNotificationsAsync(): Promise { + if (!NotificationScheduler.getAllScheduledNotificationsAsync) { + throw new UnavailabilityError('Notifications', 'getAllScheduledNotificationsAsync'); + } + return await NotificationScheduler.getAllScheduledNotificationsAsync(); } diff --git a/packages/expo-notifications/src/scheduleNotificationAsync.ts b/packages/expo-notifications/src/scheduleNotificationAsync.ts index 743a2c37c78f1..dcdc7b97b6ee7 100644 --- a/packages/expo-notifications/src/scheduleNotificationAsync.ts +++ b/packages/expo-notifications/src/scheduleNotificationAsync.ts @@ -1,3 +1,4 @@ +import { UnavailabilityError } from '@unimodules/core'; import uuidv4 from 'uuid/v4'; import NotificationScheduler from './NotificationScheduler'; @@ -13,6 +14,10 @@ import { export default async function scheduleNotificationAsync( request: NotificationRequestInput ): Promise { + if (!NotificationScheduler.scheduleNotificationAsync) { + throw new UnavailabilityError('Notifications', 'scheduleNotificationAsync'); + } + return await NotificationScheduler.scheduleNotificationAsync( request.identifier ?? uuidv4(), request.content, From 3ca75594fe7412d5da60c6f314f73d9f9fa68adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 15:48:34 +0200 Subject: [PATCH 02/17] [expo-notifications] Fix types and add web support for NotificationsHandler --- .../build/NotificationsHandler.js | 8 +++++++- .../build/NotificationsHandler.js.map | 2 +- .../build/NotificationsHandlerModule.d.ts | 6 +----- .../build/NotificationsHandlerModule.js.map | 2 +- .../build/NotificationsHandlerModule.types.d.ts | 5 +++++ .../build/NotificationsHandlerModule.types.js | 1 + .../build/NotificationsHandlerModule.types.js.map | 1 + .../build/NotificationsHandlerModule.web.d.ts | 3 +++ .../build/NotificationsHandlerModule.web.js | 11 +++++++++++ .../build/NotificationsHandlerModule.web.js.map | 1 + .../src/NotificationsHandler.ts | 12 +++++++++++- .../src/NotificationsHandlerModule.ts | 11 ++--------- .../src/NotificationsHandlerModule.types.ts | 10 ++++++++++ .../src/NotificationsHandlerModule.web.ts | 15 +++++++++++++++ 14 files changed, 70 insertions(+), 18 deletions(-) create mode 100644 packages/expo-notifications/build/NotificationsHandlerModule.types.d.ts create mode 100644 packages/expo-notifications/build/NotificationsHandlerModule.types.js create mode 100644 packages/expo-notifications/build/NotificationsHandlerModule.types.js.map create mode 100644 packages/expo-notifications/build/NotificationsHandlerModule.web.d.ts create mode 100644 packages/expo-notifications/build/NotificationsHandlerModule.web.js create mode 100644 packages/expo-notifications/build/NotificationsHandlerModule.web.js.map create mode 100644 packages/expo-notifications/src/NotificationsHandlerModule.types.ts create mode 100644 packages/expo-notifications/src/NotificationsHandlerModule.web.ts diff --git a/packages/expo-notifications/build/NotificationsHandler.js b/packages/expo-notifications/build/NotificationsHandler.js index 022f75adb505a..ca7e44ea1d22e 100644 --- a/packages/expo-notifications/build/NotificationsHandler.js +++ b/packages/expo-notifications/build/NotificationsHandler.js @@ -1,4 +1,4 @@ -import { EventEmitter, CodedError } from '@unimodules/core'; +import { EventEmitter, CodedError, UnavailabilityError } from '@unimodules/core'; import NotificationsHandlerModule from './NotificationsHandlerModule'; export class NotificationTimeoutError extends CodedError { constructor(notificationId, notification) { @@ -23,6 +23,12 @@ export function setNotificationHandler(handler) { } if (handler) { handleSubscription = notificationEmitter.addListener(handleNotificationEventName, async ({ id, notification }) => { + if (!NotificationsHandlerModule.handleNotificationAsync) { + // TODO: Remove eslint-disable once we upgrade to a version that supports ?. notation. + // eslint-disable-next-line + handler.handleError?.(id, new UnavailabilityError('Notifications', 'handleNotificationAsync')); + return; + } try { const behavior = await handler.handleNotification(notification); await NotificationsHandlerModule.handleNotificationAsync(id, behavior); diff --git a/packages/expo-notifications/build/NotificationsHandler.js.map b/packages/expo-notifications/build/NotificationsHandler.js.map index e04e575ed991b..699b9d65a56ac 100644 --- a/packages/expo-notifications/build/NotificationsHandler.js.map +++ b/packages/expo-notifications/build/NotificationsHandler.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationsHandler.js","sourceRoot":"","sources":["../src/NotificationsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG1E,OAAO,0BAA0B,MAAM,8BAA8B,CAAC;AAEtE,MAAM,OAAO,wBAAyB,SAAQ,UAAU;IAEtD,YAAY,cAAsB,EAAE,YAA0B;QAC5D,KAAK,CAAC,0BAA0B,EAAE,0CAA0C,cAAc,GAAG,CAAC,CAAC;QAC/F,IAAI,CAAC,IAAI,GAAG,EAAE,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;IACnD,CAAC;CACF;AAiBD,iCAAiC;AACjC,MAAM,mBAAmB,GAAG,IAAI,YAAY,CAAC,0BAA0B,CAAC,CAAC;AAEzE,MAAM,2BAA2B,GAAG,sBAAsB,CAAC;AAC3D,MAAM,kCAAkC,GAAG,6BAA6B,CAAC;AAEzE,IAAI,kBAAkB,GAAwB,IAAI,CAAC;AACnD,IAAI,yBAAyB,GAAwB,IAAI,CAAC;AAE1D,MAAM,UAAU,sBAAsB,CAAC,OAAmC;IACxE,IAAI,kBAAkB,EAAE;QACtB,kBAAkB,CAAC,MAAM,EAAE,CAAC;QAC5B,kBAAkB,GAAG,IAAI,CAAC;KAC3B;IACD,IAAI,yBAAyB,EAAE;QAC7B,yBAAyB,CAAC,MAAM,EAAE,CAAC;QACnC,yBAAyB,GAAG,IAAI,CAAC;KAClC;IAED,IAAI,OAAO,EAAE;QACX,kBAAkB,GAAG,mBAAmB,CAAC,WAAW,CAClD,2BAA2B,EAC3B,KAAK,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;YAC7B,IAAI;gBACF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;gBAChE,MAAM,0BAA0B,CAAC,uBAAuB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;gBACvE,sFAAsF;gBACtF,2BAA2B;gBAC3B,OAAO,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC;aAC7B;YAAC,OAAO,KAAK,EAAE;gBACd,sFAAsF;gBACtF,2BAA2B;gBAC3B,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;aAClC;QACH,CAAC,CACF,CAAC;QAEF,yBAAyB,GAAG,mBAAmB,CAAC,WAAW,CACzD,kCAAkC,EAClC,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CACvB,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,IAAI,wBAAwB,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC,CAC5E,CAAC;KACH;AACH,CAAC","sourcesContent":["import { EventEmitter, Subscription, CodedError } from '@unimodules/core';\n\nimport { Notification, NotificationBehavior } from './Notifications.types';\nimport NotificationsHandlerModule from './NotificationsHandlerModule';\n\nexport class NotificationTimeoutError extends CodedError {\n info: { notification: Notification; id: string };\n constructor(notificationId: string, notification: Notification) {\n super('ERR_NOTIFICATION_TIMEOUT', `Notification handling timed out for ID ${notificationId}.`);\n this.info = { id: notificationId, notification };\n }\n}\n\nexport type NotificationHandlingError = NotificationTimeoutError | Error;\n\nexport interface NotificationHandler {\n handleNotification: (notification: Notification) => Promise;\n handleSuccess?: (notificationId: string) => void;\n handleError?: (notificationId: string, error: NotificationHandlingError) => void;\n}\n\ntype HandleNotificationEvent = {\n id: string;\n notification: Notification;\n};\n\ntype HandleNotificationTimeoutEvent = HandleNotificationEvent;\n\n// Web uses SyntheticEventEmitter\nconst notificationEmitter = new EventEmitter(NotificationsHandlerModule);\n\nconst handleNotificationEventName = 'onHandleNotification';\nconst handleNotificationTimeoutEventName = 'onHandleNotificationTimeout';\n\nlet handleSubscription: Subscription | null = null;\nlet handleTimeoutSubscription: Subscription | null = null;\n\nexport function setNotificationHandler(handler: NotificationHandler | null): void {\n if (handleSubscription) {\n handleSubscription.remove();\n handleSubscription = null;\n }\n if (handleTimeoutSubscription) {\n handleTimeoutSubscription.remove();\n handleTimeoutSubscription = null;\n }\n\n if (handler) {\n handleSubscription = notificationEmitter.addListener(\n handleNotificationEventName,\n async ({ id, notification }) => {\n try {\n const behavior = await handler.handleNotification(notification);\n await NotificationsHandlerModule.handleNotificationAsync(id, behavior);\n // TODO: Remove eslint-disable once we upgrade to a version that supports ?. notation.\n // eslint-disable-next-line\n handler.handleSuccess?.(id);\n } catch (error) {\n // TODO: Remove eslint-disable once we upgrade to a version that supports ?. notation.\n // eslint-disable-next-line\n handler.handleError?.(id, error);\n }\n }\n );\n\n handleTimeoutSubscription = notificationEmitter.addListener(\n handleNotificationTimeoutEventName,\n ({ id, notification }) =>\n handler.handleError?.(id, new NotificationTimeoutError(id, notification))\n );\n }\n}\n"]} \ No newline at end of file +{"version":3,"file":"NotificationsHandler.js","sourceRoot":"","sources":["../src/NotificationsHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,UAAU,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG/F,OAAO,0BAA0B,MAAM,8BAA8B,CAAC;AAEtE,MAAM,OAAO,wBAAyB,SAAQ,UAAU;IAEtD,YAAY,cAAsB,EAAE,YAA0B;QAC5D,KAAK,CAAC,0BAA0B,EAAE,0CAA0C,cAAc,GAAG,CAAC,CAAC;QAC/F,IAAI,CAAC,IAAI,GAAG,EAAE,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;IACnD,CAAC;CACF;AAiBD,iCAAiC;AACjC,MAAM,mBAAmB,GAAG,IAAI,YAAY,CAAC,0BAA0B,CAAC,CAAC;AAEzE,MAAM,2BAA2B,GAAG,sBAAsB,CAAC;AAC3D,MAAM,kCAAkC,GAAG,6BAA6B,CAAC;AAEzE,IAAI,kBAAkB,GAAwB,IAAI,CAAC;AACnD,IAAI,yBAAyB,GAAwB,IAAI,CAAC;AAE1D,MAAM,UAAU,sBAAsB,CAAC,OAAmC;IACxE,IAAI,kBAAkB,EAAE;QACtB,kBAAkB,CAAC,MAAM,EAAE,CAAC;QAC5B,kBAAkB,GAAG,IAAI,CAAC;KAC3B;IACD,IAAI,yBAAyB,EAAE;QAC7B,yBAAyB,CAAC,MAAM,EAAE,CAAC;QACnC,yBAAyB,GAAG,IAAI,CAAC;KAClC;IAED,IAAI,OAAO,EAAE;QACX,kBAAkB,GAAG,mBAAmB,CAAC,WAAW,CAClD,2BAA2B,EAC3B,KAAK,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;YAC7B,IAAI,CAAC,0BAA0B,CAAC,uBAAuB,EAAE;gBACvD,sFAAsF;gBACtF,2BAA2B;gBAC3B,OAAO,CAAC,WAAW,EAAE,CACnB,EAAE,EACF,IAAI,mBAAmB,CAAC,eAAe,EAAE,yBAAyB,CAAC,CACpE,CAAC;gBACF,OAAO;aACR;YAED,IAAI;gBACF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;gBAChE,MAAM,0BAA0B,CAAC,uBAAuB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;gBACvE,sFAAsF;gBACtF,2BAA2B;gBAC3B,OAAO,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC,CAAC;aAC7B;YAAC,OAAO,KAAK,EAAE;gBACd,sFAAsF;gBACtF,2BAA2B;gBAC3B,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;aAClC;QACH,CAAC,CACF,CAAC;QAEF,yBAAyB,GAAG,mBAAmB,CAAC,WAAW,CACzD,kCAAkC,EAClC,CAAC,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CACvB,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,EAAE,IAAI,wBAAwB,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC,CAC5E,CAAC;KACH;AACH,CAAC","sourcesContent":["import { EventEmitter, Subscription, CodedError, UnavailabilityError } from '@unimodules/core';\n\nimport { Notification, NotificationBehavior } from './Notifications.types';\nimport NotificationsHandlerModule from './NotificationsHandlerModule';\n\nexport class NotificationTimeoutError extends CodedError {\n info: { notification: Notification; id: string };\n constructor(notificationId: string, notification: Notification) {\n super('ERR_NOTIFICATION_TIMEOUT', `Notification handling timed out for ID ${notificationId}.`);\n this.info = { id: notificationId, notification };\n }\n}\n\nexport type NotificationHandlingError = NotificationTimeoutError | Error;\n\nexport interface NotificationHandler {\n handleNotification: (notification: Notification) => Promise;\n handleSuccess?: (notificationId: string) => void;\n handleError?: (notificationId: string, error: NotificationHandlingError) => void;\n}\n\ntype HandleNotificationEvent = {\n id: string;\n notification: Notification;\n};\n\ntype HandleNotificationTimeoutEvent = HandleNotificationEvent;\n\n// Web uses SyntheticEventEmitter\nconst notificationEmitter = new EventEmitter(NotificationsHandlerModule);\n\nconst handleNotificationEventName = 'onHandleNotification';\nconst handleNotificationTimeoutEventName = 'onHandleNotificationTimeout';\n\nlet handleSubscription: Subscription | null = null;\nlet handleTimeoutSubscription: Subscription | null = null;\n\nexport function setNotificationHandler(handler: NotificationHandler | null): void {\n if (handleSubscription) {\n handleSubscription.remove();\n handleSubscription = null;\n }\n if (handleTimeoutSubscription) {\n handleTimeoutSubscription.remove();\n handleTimeoutSubscription = null;\n }\n\n if (handler) {\n handleSubscription = notificationEmitter.addListener(\n handleNotificationEventName,\n async ({ id, notification }) => {\n if (!NotificationsHandlerModule.handleNotificationAsync) {\n // TODO: Remove eslint-disable once we upgrade to a version that supports ?. notation.\n // eslint-disable-next-line\n handler.handleError?.(\n id,\n new UnavailabilityError('Notifications', 'handleNotificationAsync')\n );\n return;\n }\n\n try {\n const behavior = await handler.handleNotification(notification);\n await NotificationsHandlerModule.handleNotificationAsync(id, behavior);\n // TODO: Remove eslint-disable once we upgrade to a version that supports ?. notation.\n // eslint-disable-next-line\n handler.handleSuccess?.(id);\n } catch (error) {\n // TODO: Remove eslint-disable once we upgrade to a version that supports ?. notation.\n // eslint-disable-next-line\n handler.handleError?.(id, error);\n }\n }\n );\n\n handleTimeoutSubscription = notificationEmitter.addListener(\n handleNotificationTimeoutEventName,\n ({ id, notification }) =>\n handler.handleError?.(id, new NotificationTimeoutError(id, notification))\n );\n }\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.d.ts b/packages/expo-notifications/build/NotificationsHandlerModule.d.ts index bd962062cd8a9..4c64d8489ca04 100644 --- a/packages/expo-notifications/build/NotificationsHandlerModule.d.ts +++ b/packages/expo-notifications/build/NotificationsHandlerModule.d.ts @@ -1,7 +1,3 @@ -import { ProxyNativeModule } from '@unimodules/core'; -import { NotificationBehavior } from './Notifications.types'; -export interface NotificationsHandlerModule extends ProxyNativeModule { - handleNotificationAsync: (notificationId: string, notificationBehavior: NotificationBehavior) => Promise; -} +import { NotificationsHandlerModule } from './NotificationsHandlerModule.types'; declare const _default: NotificationsHandlerModule; export default _default; diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.js.map b/packages/expo-notifications/build/NotificationsHandlerModule.js.map index 6f5c652350b3b..b53c0096317be 100644 --- a/packages/expo-notifications/build/NotificationsHandlerModule.js.map +++ b/packages/expo-notifications/build/NotificationsHandlerModule.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationsHandlerModule.js","sourceRoot":"","sources":["../src/NotificationsHandlerModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,kBAAkB,CAAC;AAWzE,eAAgB,kBAAkB,CAAC,8BAAoE,CAAC","sourcesContent":["import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core';\n\nimport { NotificationBehavior } from './Notifications.types';\n\nexport interface NotificationsHandlerModule extends ProxyNativeModule {\n handleNotificationAsync: (\n notificationId: string,\n notificationBehavior: NotificationBehavior\n ) => Promise;\n}\n\nexport default (NativeModulesProxy.ExpoNotificationsHandlerModule as any) as NotificationsHandlerModule;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationsHandlerModule.js","sourceRoot":"","sources":["../src/NotificationsHandlerModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,8BAAoE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationsHandlerModule } from './NotificationsHandlerModule.types';\n\nexport default (NativeModulesProxy.ExpoNotificationsHandlerModule as any) as NotificationsHandlerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.types.d.ts b/packages/expo-notifications/build/NotificationsHandlerModule.types.d.ts new file mode 100644 index 0000000000000..41650bbdc3db3 --- /dev/null +++ b/packages/expo-notifications/build/NotificationsHandlerModule.types.d.ts @@ -0,0 +1,5 @@ +import { ProxyNativeModule } from '@unimodules/core'; +import { NotificationBehavior } from './Notifications.types'; +export interface NotificationsHandlerModule extends ProxyNativeModule { + handleNotificationAsync?: (notificationId: string, notificationBehavior: NotificationBehavior) => Promise; +} diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.types.js b/packages/expo-notifications/build/NotificationsHandlerModule.types.js new file mode 100644 index 0000000000000..fb5259225cfbf --- /dev/null +++ b/packages/expo-notifications/build/NotificationsHandlerModule.types.js @@ -0,0 +1 @@ +//# sourceMappingURL=NotificationsHandlerModule.types.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.types.js.map b/packages/expo-notifications/build/NotificationsHandlerModule.types.js.map new file mode 100644 index 0000000000000..c71c466403a31 --- /dev/null +++ b/packages/expo-notifications/build/NotificationsHandlerModule.types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationsHandlerModule.types.js","sourceRoot":"","sources":["../src/NotificationsHandlerModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\n\nimport { NotificationBehavior } from './Notifications.types';\n\nexport interface NotificationsHandlerModule extends ProxyNativeModule {\n handleNotificationAsync?: (\n notificationId: string,\n notificationBehavior: NotificationBehavior\n ) => Promise;\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.web.d.ts b/packages/expo-notifications/build/NotificationsHandlerModule.web.d.ts new file mode 100644 index 0000000000000..4c64d8489ca04 --- /dev/null +++ b/packages/expo-notifications/build/NotificationsHandlerModule.web.d.ts @@ -0,0 +1,3 @@ +import { NotificationsHandlerModule } from './NotificationsHandlerModule.types'; +declare const _default: NotificationsHandlerModule; +export default _default; diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.web.js b/packages/expo-notifications/build/NotificationsHandlerModule.web.js new file mode 100644 index 0000000000000..d44deff665905 --- /dev/null +++ b/packages/expo-notifications/build/NotificationsHandlerModule.web.js @@ -0,0 +1,11 @@ +let warningHasBeenShown = false; +export default { + addListener: () => { + if (!warningHasBeenShown) { + console.warn('[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.'); + warningHasBeenShown = true; + } + }, + removeListeners: () => { }, +}; +//# sourceMappingURL=NotificationsHandlerModule.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.web.js.map b/packages/expo-notifications/build/NotificationsHandlerModule.web.js.map new file mode 100644 index 0000000000000..b2d579b220993 --- /dev/null +++ b/packages/expo-notifications/build/NotificationsHandlerModule.web.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationsHandlerModule.web.js","sourceRoot":"","sources":["../src/NotificationsHandlerModule.web.ts"],"names":[],"mappings":"AAEA,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,eAAe;IACb,WAAW,EAAE,GAAG,EAAE;QAChB,IAAI,CAAC,mBAAmB,EAAE;YACxB,OAAO,CAAC,IAAI,CACV,4HAA4H,CAC7H,CAAC;YACF,mBAAmB,GAAG,IAAI,CAAC;SAC5B;IACH,CAAC;IACD,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACI,CAAC","sourcesContent":["import { NotificationsHandlerModule } from './NotificationsHandlerModule.types';\n\nlet warningHasBeenShown = false;\n\nexport default {\n addListener: () => {\n if (!warningHasBeenShown) {\n console.warn(\n '[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.'\n );\n warningHasBeenShown = true;\n }\n },\n removeListeners: () => {},\n} as NotificationsHandlerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/NotificationsHandler.ts b/packages/expo-notifications/src/NotificationsHandler.ts index cb67ea82134b8..47064c8c62ab6 100644 --- a/packages/expo-notifications/src/NotificationsHandler.ts +++ b/packages/expo-notifications/src/NotificationsHandler.ts @@ -1,4 +1,4 @@ -import { EventEmitter, Subscription, CodedError } from '@unimodules/core'; +import { EventEmitter, Subscription, CodedError, UnavailabilityError } from '@unimodules/core'; import { Notification, NotificationBehavior } from './Notifications.types'; import NotificationsHandlerModule from './NotificationsHandlerModule'; @@ -49,6 +49,16 @@ export function setNotificationHandler(handler: NotificationHandler | null): voi handleSubscription = notificationEmitter.addListener( handleNotificationEventName, async ({ id, notification }) => { + if (!NotificationsHandlerModule.handleNotificationAsync) { + // TODO: Remove eslint-disable once we upgrade to a version that supports ?. notation. + // eslint-disable-next-line + handler.handleError?.( + id, + new UnavailabilityError('Notifications', 'handleNotificationAsync') + ); + return; + } + try { const behavior = await handler.handleNotification(notification); await NotificationsHandlerModule.handleNotificationAsync(id, behavior); diff --git a/packages/expo-notifications/src/NotificationsHandlerModule.ts b/packages/expo-notifications/src/NotificationsHandlerModule.ts index 8b432c1b71ae1..a30f587e6c75b 100644 --- a/packages/expo-notifications/src/NotificationsHandlerModule.ts +++ b/packages/expo-notifications/src/NotificationsHandlerModule.ts @@ -1,12 +1,5 @@ -import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core'; +import { NativeModulesProxy } from '@unimodules/core'; -import { NotificationBehavior } from './Notifications.types'; - -export interface NotificationsHandlerModule extends ProxyNativeModule { - handleNotificationAsync: ( - notificationId: string, - notificationBehavior: NotificationBehavior - ) => Promise; -} +import { NotificationsHandlerModule } from './NotificationsHandlerModule.types'; export default (NativeModulesProxy.ExpoNotificationsHandlerModule as any) as NotificationsHandlerModule; diff --git a/packages/expo-notifications/src/NotificationsHandlerModule.types.ts b/packages/expo-notifications/src/NotificationsHandlerModule.types.ts new file mode 100644 index 0000000000000..f0b4a72e685ab --- /dev/null +++ b/packages/expo-notifications/src/NotificationsHandlerModule.types.ts @@ -0,0 +1,10 @@ +import { ProxyNativeModule } from '@unimodules/core'; + +import { NotificationBehavior } from './Notifications.types'; + +export interface NotificationsHandlerModule extends ProxyNativeModule { + handleNotificationAsync?: ( + notificationId: string, + notificationBehavior: NotificationBehavior + ) => Promise; +} diff --git a/packages/expo-notifications/src/NotificationsHandlerModule.web.ts b/packages/expo-notifications/src/NotificationsHandlerModule.web.ts new file mode 100644 index 0000000000000..4b4392f460683 --- /dev/null +++ b/packages/expo-notifications/src/NotificationsHandlerModule.web.ts @@ -0,0 +1,15 @@ +import { NotificationsHandlerModule } from './NotificationsHandlerModule.types'; + +let warningHasBeenShown = false; + +export default { + addListener: () => { + if (!warningHasBeenShown) { + console.warn( + '[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.' + ); + warningHasBeenShown = true; + } + }, + removeListeners: () => {}, +} as NotificationsHandlerModule; From 1f4b6b1f26c8f11462eb22481ea5f8ba844900b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 15:50:50 +0200 Subject: [PATCH 03/17] [expo-notifications] Fix types and add web support for NotificationChannelGroupManager --- .../build/NotificationChannelGroupManager.d.ts | 9 +-------- .../NotificationChannelGroupManager.js.map | 2 +- .../NotificationChannelGroupManager.types.d.ts | 7 +++++++ ...NotificationChannelGroupManager.types.js.map | 2 +- .../NotificationChannelGroupManager.web.d.ts | 3 +++ .../NotificationChannelGroupManager.web.js | 5 +++++ .../NotificationChannelGroupManager.web.js.map | 1 + .../src/NotificationChannelGroupManager.ts | 17 ++--------------- .../NotificationChannelGroupManager.types.ts | 12 ++++++++++++ .../src/NotificationChannelGroupManager.web.ts | 6 ++++++ 10 files changed, 39 insertions(+), 25 deletions(-) create mode 100644 packages/expo-notifications/build/NotificationChannelGroupManager.web.d.ts create mode 100644 packages/expo-notifications/build/NotificationChannelGroupManager.web.js create mode 100644 packages/expo-notifications/build/NotificationChannelGroupManager.web.js.map create mode 100644 packages/expo-notifications/src/NotificationChannelGroupManager.web.ts diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.d.ts b/packages/expo-notifications/build/NotificationChannelGroupManager.d.ts index 5bf240d175952..5258dcea99778 100644 --- a/packages/expo-notifications/build/NotificationChannelGroupManager.d.ts +++ b/packages/expo-notifications/build/NotificationChannelGroupManager.d.ts @@ -1,10 +1,3 @@ -import { ProxyNativeModule } from '@unimodules/core'; -import { NotificationChannelGroup, NotificationChannelGroupInput } from './NotificationChannelGroupManager.types'; -export interface NotificationChannelGroupManager extends ProxyNativeModule { - getNotificationChannelGroupsAsync: () => Promise; - getNotificationChannelGroupAsync: (groupId: string) => Promise; - setNotificationChannelGroupAsync: (groupId: string, group: NotificationChannelGroupInput) => Promise; - deleteNotificationChannelGroupAsync: (groupId: string) => Promise; -} +import { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types'; declare const _default: NotificationChannelGroupManager; export default _default; diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.js.map b/packages/expo-notifications/build/NotificationChannelGroupManager.js.map index 667dc960b07dd..bf370fc9d4759 100644 --- a/packages/expo-notifications/build/NotificationChannelGroupManager.js.map +++ b/packages/expo-notifications/build/NotificationChannelGroupManager.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationChannelGroupManager.js","sourceRoot":"","sources":["../src/NotificationChannelGroupManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,kBAAkB,CAAC;AAiBzE,eAAgB,kBAAkB,CAAC,mCAA8E,CAAC","sourcesContent":["import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core';\n\nimport {\n NotificationChannelGroup,\n NotificationChannelGroupInput,\n} from './NotificationChannelGroupManager.types';\n\nexport interface NotificationChannelGroupManager extends ProxyNativeModule {\n getNotificationChannelGroupsAsync: () => Promise;\n getNotificationChannelGroupAsync: (groupId: string) => Promise;\n setNotificationChannelGroupAsync: (\n groupId: string,\n group: NotificationChannelGroupInput\n ) => Promise;\n deleteNotificationChannelGroupAsync: (groupId: string) => Promise;\n}\n\nexport default (NativeModulesProxy.ExpoNotificationChannelGroupManager as any) as NotificationChannelGroupManager;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationChannelGroupManager.js","sourceRoot":"","sources":["../src/NotificationChannelGroupManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,mCAA8E,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types';\n\nexport default (NativeModulesProxy.ExpoNotificationChannelGroupManager as any) as NotificationChannelGroupManager;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.types.d.ts b/packages/expo-notifications/build/NotificationChannelGroupManager.types.d.ts index d9f67113d6724..ebedba36c3096 100644 --- a/packages/expo-notifications/build/NotificationChannelGroupManager.types.d.ts +++ b/packages/expo-notifications/build/NotificationChannelGroupManager.types.d.ts @@ -1,3 +1,4 @@ +import { ProxyNativeModule } from '@unimodules/core'; import { NotificationChannel } from './NotificationChannelManager.types'; export interface NotificationChannelGroup { id: string; @@ -10,3 +11,9 @@ export interface NotificationChannelGroupInput { name: string | null; description?: string | null; } +export interface NotificationChannelGroupManager extends ProxyNativeModule { + getNotificationChannelGroupsAsync?: () => Promise; + getNotificationChannelGroupAsync?: (groupId: string) => Promise; + setNotificationChannelGroupAsync?: (groupId: string, group: NotificationChannelGroupInput) => Promise; + deleteNotificationChannelGroupAsync?: (groupId: string) => Promise; +} diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.types.js.map b/packages/expo-notifications/build/NotificationChannelGroupManager.types.js.map index 9e18bce3080a0..e78d0f8d6e48f 100644 --- a/packages/expo-notifications/build/NotificationChannelGroupManager.types.js.map +++ b/packages/expo-notifications/build/NotificationChannelGroupManager.types.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationChannelGroupManager.types.js","sourceRoot":"","sources":["../src/NotificationChannelGroupManager.types.ts"],"names":[],"mappings":"","sourcesContent":["import { NotificationChannel } from './NotificationChannelManager.types';\n\nexport interface NotificationChannelGroup {\n id: string;\n name: string | null;\n description?: string | null;\n isBlocked?: boolean;\n channels: NotificationChannel[];\n}\n\nexport interface NotificationChannelGroupInput {\n name: string | null;\n description?: string | null;\n}\n"]} \ No newline at end of file +{"version":3,"file":"NotificationChannelGroupManager.types.js","sourceRoot":"","sources":["../src/NotificationChannelGroupManager.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\n\nimport { NotificationChannel } from './NotificationChannelManager.types';\n\nexport interface NotificationChannelGroup {\n id: string;\n name: string | null;\n description?: string | null;\n isBlocked?: boolean;\n channels: NotificationChannel[];\n}\n\nexport interface NotificationChannelGroupInput {\n name: string | null;\n description?: string | null;\n}\n\nexport interface NotificationChannelGroupManager extends ProxyNativeModule {\n getNotificationChannelGroupsAsync?: () => Promise;\n getNotificationChannelGroupAsync?: (groupId: string) => Promise;\n setNotificationChannelGroupAsync?: (\n groupId: string,\n group: NotificationChannelGroupInput\n ) => Promise;\n deleteNotificationChannelGroupAsync?: (groupId: string) => Promise;\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.web.d.ts b/packages/expo-notifications/build/NotificationChannelGroupManager.web.d.ts new file mode 100644 index 0000000000000..5258dcea99778 --- /dev/null +++ b/packages/expo-notifications/build/NotificationChannelGroupManager.web.d.ts @@ -0,0 +1,3 @@ +import { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types'; +declare const _default: NotificationChannelGroupManager; +export default _default; diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.web.js b/packages/expo-notifications/build/NotificationChannelGroupManager.web.js new file mode 100644 index 0000000000000..1e94cdf4d48ac --- /dev/null +++ b/packages/expo-notifications/build/NotificationChannelGroupManager.web.js @@ -0,0 +1,5 @@ +export default { + addListener: () => { }, + removeListeners: () => { }, +}; +//# sourceMappingURL=NotificationChannelGroupManager.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.web.js.map b/packages/expo-notifications/build/NotificationChannelGroupManager.web.js.map new file mode 100644 index 0000000000000..adc5d042b94c2 --- /dev/null +++ b/packages/expo-notifications/build/NotificationChannelGroupManager.web.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationChannelGroupManager.web.js","sourceRoot":"","sources":["../src/NotificationChannelGroupManager.web.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACS,CAAC","sourcesContent":["import { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationChannelGroupManager;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/NotificationChannelGroupManager.ts b/packages/expo-notifications/src/NotificationChannelGroupManager.ts index 28c3d03db2086..1eb22c9484868 100644 --- a/packages/expo-notifications/src/NotificationChannelGroupManager.ts +++ b/packages/expo-notifications/src/NotificationChannelGroupManager.ts @@ -1,18 +1,5 @@ -import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core'; +import { NativeModulesProxy } from '@unimodules/core'; -import { - NotificationChannelGroup, - NotificationChannelGroupInput, -} from './NotificationChannelGroupManager.types'; - -export interface NotificationChannelGroupManager extends ProxyNativeModule { - getNotificationChannelGroupsAsync: () => Promise; - getNotificationChannelGroupAsync: (groupId: string) => Promise; - setNotificationChannelGroupAsync: ( - groupId: string, - group: NotificationChannelGroupInput - ) => Promise; - deleteNotificationChannelGroupAsync: (groupId: string) => Promise; -} +import { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types'; export default (NativeModulesProxy.ExpoNotificationChannelGroupManager as any) as NotificationChannelGroupManager; diff --git a/packages/expo-notifications/src/NotificationChannelGroupManager.types.ts b/packages/expo-notifications/src/NotificationChannelGroupManager.types.ts index f9523d18f4ace..7d64ed5c24a5f 100644 --- a/packages/expo-notifications/src/NotificationChannelGroupManager.types.ts +++ b/packages/expo-notifications/src/NotificationChannelGroupManager.types.ts @@ -1,3 +1,5 @@ +import { ProxyNativeModule } from '@unimodules/core'; + import { NotificationChannel } from './NotificationChannelManager.types'; export interface NotificationChannelGroup { @@ -12,3 +14,13 @@ export interface NotificationChannelGroupInput { name: string | null; description?: string | null; } + +export interface NotificationChannelGroupManager extends ProxyNativeModule { + getNotificationChannelGroupsAsync?: () => Promise; + getNotificationChannelGroupAsync?: (groupId: string) => Promise; + setNotificationChannelGroupAsync?: ( + groupId: string, + group: NotificationChannelGroupInput + ) => Promise; + deleteNotificationChannelGroupAsync?: (groupId: string) => Promise; +} diff --git a/packages/expo-notifications/src/NotificationChannelGroupManager.web.ts b/packages/expo-notifications/src/NotificationChannelGroupManager.web.ts new file mode 100644 index 0000000000000..edc8ad1300206 --- /dev/null +++ b/packages/expo-notifications/src/NotificationChannelGroupManager.web.ts @@ -0,0 +1,6 @@ +import { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types'; + +export default { + addListener: () => {}, + removeListeners: () => {}, +} as NotificationChannelGroupManager; From 87bbf56f7e258f91899a61b29d117f598c8afe36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 15:52:38 +0200 Subject: [PATCH 04/17] [expo-notifications] Fix types and add web support for NotificationChannelManager --- .../build/NotificationChannelManager.d.ts | 9 +-------- .../build/NotificationChannelManager.js.map | 2 +- .../build/NotificationChannelManager.types.d.ts | 7 +++++++ .../build/NotificationChannelManager.types.js.map | 2 +- .../build/NotificationChannelManager.web.d.ts | 3 +++ .../build/NotificationChannelManager.web.js | 5 +++++ .../build/NotificationChannelManager.web.js.map | 1 + .../src/NotificationChannelManager.ts | 14 ++------------ .../src/NotificationChannelManager.types.ts | 12 ++++++++++++ .../src/NotificationChannelManager.web.ts | 6 ++++++ 10 files changed, 39 insertions(+), 22 deletions(-) create mode 100644 packages/expo-notifications/build/NotificationChannelManager.web.d.ts create mode 100644 packages/expo-notifications/build/NotificationChannelManager.web.js create mode 100644 packages/expo-notifications/build/NotificationChannelManager.web.js.map create mode 100644 packages/expo-notifications/src/NotificationChannelManager.web.ts diff --git a/packages/expo-notifications/build/NotificationChannelManager.d.ts b/packages/expo-notifications/build/NotificationChannelManager.d.ts index e4a9c15085849..13ada51bc20e6 100644 --- a/packages/expo-notifications/build/NotificationChannelManager.d.ts +++ b/packages/expo-notifications/build/NotificationChannelManager.d.ts @@ -1,10 +1,3 @@ -import { ProxyNativeModule } from '@unimodules/core'; -import { NotificationChannel, NotificationChannelInput } from './NotificationChannelManager.types'; -export interface NotificationChannelManager extends ProxyNativeModule { - getNotificationChannelsAsync: () => Promise; - getNotificationChannelAsync: (channelId: string) => Promise; - setNotificationChannelAsync: (channelId: string, channelConfiguration: NotificationChannelInput) => Promise; - deleteNotificationChannelAsync: (channelId: string) => Promise; -} +import { NotificationChannelManager } from './NotificationChannelManager.types'; declare const _default: NotificationChannelManager; export default _default; diff --git a/packages/expo-notifications/build/NotificationChannelManager.js.map b/packages/expo-notifications/build/NotificationChannelManager.js.map index 234be77be09d7..ba946f32797bd 100644 --- a/packages/expo-notifications/build/NotificationChannelManager.js.map +++ b/packages/expo-notifications/build/NotificationChannelManager.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationChannelManager.js","sourceRoot":"","sources":["../src/NotificationChannelManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,kBAAkB,CAAC;AAczE,eAAgB,kBAAkB,CAAC,8BAAoE,CAAC","sourcesContent":["import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core';\n\nimport { NotificationChannel, NotificationChannelInput } from './NotificationChannelManager.types';\n\nexport interface NotificationChannelManager extends ProxyNativeModule {\n getNotificationChannelsAsync: () => Promise;\n getNotificationChannelAsync: (channelId: string) => Promise;\n setNotificationChannelAsync: (\n channelId: string,\n channelConfiguration: NotificationChannelInput\n ) => Promise;\n deleteNotificationChannelAsync: (channelId: string) => Promise;\n}\n\nexport default (NativeModulesProxy.ExpoNotificationChannelManager as any) as NotificationChannelManager;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationChannelManager.js","sourceRoot":"","sources":["../src/NotificationChannelManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,8BAAoE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationChannelManager } from './NotificationChannelManager.types';\n\nexport default (NativeModulesProxy.ExpoNotificationChannelManager as any) as NotificationChannelManager;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelManager.types.d.ts b/packages/expo-notifications/build/NotificationChannelManager.types.d.ts index 3c78811738f1b..d3f95c447b36a 100644 --- a/packages/expo-notifications/build/NotificationChannelManager.types.d.ts +++ b/packages/expo-notifications/build/NotificationChannelManager.types.d.ts @@ -1,3 +1,4 @@ +import { ProxyNativeModule } from '@unimodules/core'; export declare enum AndroidNotificationVisibility { UNKNOWN = 0, PUBLIC = 1, @@ -70,4 +71,10 @@ export declare type NotificationChannelInput = RequiredBy; +export interface NotificationChannelManager extends ProxyNativeModule { + getNotificationChannelsAsync?: () => Promise; + getNotificationChannelAsync?: (channelId: string) => Promise; + setNotificationChannelAsync?: (channelId: string, channelConfiguration: NotificationChannelInput) => Promise; + deleteNotificationChannelAsync?: (channelId: string) => Promise; +} export {}; diff --git a/packages/expo-notifications/build/NotificationChannelManager.types.js.map b/packages/expo-notifications/build/NotificationChannelManager.types.js.map index ac2a90e9ee76c..e613b35e8f5ac 100644 --- a/packages/expo-notifications/build/NotificationChannelManager.types.js.map +++ b/packages/expo-notifications/build/NotificationChannelManager.types.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationChannelManager.types.js","sourceRoot":"","sources":["../src/NotificationChannelManager.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,6BAKX;AALD,WAAY,6BAA6B;IACvC,uFAAW,CAAA;IACX,qFAAU,CAAA;IACV,uFAAW,CAAA;IACX,qFAAU,CAAA;AACZ,CAAC,EALW,6BAA6B,KAA7B,6BAA6B,QAKxC;AAED,MAAM,CAAN,IAAY,uBAMX;AAND,WAAY,uBAAuB;IACjC,2EAAW,CAAA;IACX,yEAAU,CAAA;IACV,uEAAS,CAAA;IACT,uEAAS,CAAA;IACT,qFAAgB,CAAA;AAClB,CAAC,EANW,uBAAuB,KAAvB,uBAAuB,QAMlC;AAED,MAAM,CAAN,IAAY,iBAWX;AAXD,WAAY,iBAAiB;IAC3B,+DAAW,CAAA;IACX,uEAAe,CAAA;IACf,yDAAQ,CAAA;IACR,uDAAO,CAAA;IACP,uDAAO,CAAA;IACP,+DAAW,CAAA;IACX,sCAAsC;IACtC,iEAAY,CAAA;IACZ,yDAAQ,CAAA;IACR,uDAAO,CAAA;AACT,CAAC,EAXW,iBAAiB,KAAjB,iBAAiB,QAW5B;AAED,MAAM,CAAN,IAAY,iBAgBX;AAhBD,WAAY,iBAAiB;IAC3B,+DAAW,CAAA;IACX,2DAAS,CAAA;IACT,uFAAuB,CAAA;IACvB,6GAAkC,CAAA;IAClC,2DAAS,CAAA;IACT,yEAAgB,CAAA;IAChB,2FAAyB,CAAA;IACzB,qHAAsC,CAAA;IACtC,qHAAsC,CAAA;IACtC,qHAAsC,CAAA;IACtC,sFAAuB,CAAA;IACvB,kGAA6B,CAAA;IAC7B,8GAAmC,CAAA;IACnC,gGAA4B,CAAA;IAC5B,0DAAS,CAAA;AACX,CAAC,EAhBW,iBAAiB,KAAjB,iBAAiB,QAgB5B","sourcesContent":["export enum AndroidNotificationVisibility {\n UNKNOWN = 0,\n PUBLIC = 1,\n PRIVATE = 2,\n SECRET = 3,\n}\n\nexport enum AndroidAudioContentType {\n UNKNOWN = 0,\n SPEECH = 1,\n MUSIC = 2,\n MOVIE = 3,\n SONIFICATION = 4,\n}\n\nexport enum AndroidImportance {\n UNKNOWN = 0,\n UNSPECIFIED = 1,\n NONE = 2,\n MIN = 3,\n LOW = 4,\n DEFAULT = 5,\n /** @deprecated use DEFAULT instead */\n DEEFAULT = 5,\n HIGH = 6,\n MAX = 7,\n}\n\nexport enum AndroidAudioUsage {\n UNKNOWN = 0,\n MEDIA = 1,\n VOICE_COMMUNICATION = 2,\n VOICE_COMMUNICATION_SIGNALLING = 3,\n ALARM = 4,\n NOTIFICATION = 5,\n NOTIFICATION_RINGTONE = 6,\n NOTIFICATION_COMMUNICATION_REQUEST = 7,\n NOTIFICATION_COMMUNICATION_INSTANT = 8,\n NOTIFICATION_COMMUNICATION_DELAYED = 9,\n NOTIFICATION_EVENT = 10,\n ASSISTANCE_ACCESSIBILITY = 11,\n ASSISTANCE_NAVIGATION_GUIDANCE = 12,\n ASSISTANCE_SONIFICATION = 13,\n GAME = 14,\n}\n\nexport interface AudioAttributes {\n usage: AndroidAudioUsage;\n contentType: AndroidAudioContentType;\n flags: {\n enforceAudibility: boolean;\n requestHardwareAudioVideoSynchronization: boolean;\n };\n}\n\n// We're making inner flags required to set intentionally.\n// Not providing `true` for a flag makes it false, it doesn't make sense\n// to let it be left undefined.\nexport type AudioAttributesInput = Partial;\n\nexport interface NotificationChannel {\n id: string;\n name: string | null;\n importance: AndroidImportance;\n bypassDnd: boolean;\n description: string | null;\n groupId?: string | null;\n lightColor: string;\n lockscreenVisibility: AndroidNotificationVisibility;\n showBadge: boolean;\n sound: 'default' | 'custom' | null;\n audioAttributes: AudioAttributes;\n vibrationPattern: number[] | null;\n enableLights: boolean;\n enableVibrate: boolean;\n}\n\ntype RequiredBy = Partial> & Required>;\n\nexport type NotificationChannelInput = RequiredBy<\n Omit<\n NotificationChannel,\n | 'id' // id is handled separately as a function argument\n | 'audioAttributes' // need to make it AudioAttributesInput\n | 'sound'\n > & { audioAttributes?: AudioAttributesInput; sound?: string | null },\n 'name' | 'importance'\n>;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationChannelManager.types.js","sourceRoot":"","sources":["../src/NotificationChannelManager.types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,6BAKX;AALD,WAAY,6BAA6B;IACvC,uFAAW,CAAA;IACX,qFAAU,CAAA;IACV,uFAAW,CAAA;IACX,qFAAU,CAAA;AACZ,CAAC,EALW,6BAA6B,KAA7B,6BAA6B,QAKxC;AAED,MAAM,CAAN,IAAY,uBAMX;AAND,WAAY,uBAAuB;IACjC,2EAAW,CAAA;IACX,yEAAU,CAAA;IACV,uEAAS,CAAA;IACT,uEAAS,CAAA;IACT,qFAAgB,CAAA;AAClB,CAAC,EANW,uBAAuB,KAAvB,uBAAuB,QAMlC;AAED,MAAM,CAAN,IAAY,iBAWX;AAXD,WAAY,iBAAiB;IAC3B,+DAAW,CAAA;IACX,uEAAe,CAAA;IACf,yDAAQ,CAAA;IACR,uDAAO,CAAA;IACP,uDAAO,CAAA;IACP,+DAAW,CAAA;IACX,sCAAsC;IACtC,iEAAY,CAAA;IACZ,yDAAQ,CAAA;IACR,uDAAO,CAAA;AACT,CAAC,EAXW,iBAAiB,KAAjB,iBAAiB,QAW5B;AAED,MAAM,CAAN,IAAY,iBAgBX;AAhBD,WAAY,iBAAiB;IAC3B,+DAAW,CAAA;IACX,2DAAS,CAAA;IACT,uFAAuB,CAAA;IACvB,6GAAkC,CAAA;IAClC,2DAAS,CAAA;IACT,yEAAgB,CAAA;IAChB,2FAAyB,CAAA;IACzB,qHAAsC,CAAA;IACtC,qHAAsC,CAAA;IACtC,qHAAsC,CAAA;IACtC,sFAAuB,CAAA;IACvB,kGAA6B,CAAA;IAC7B,8GAAmC,CAAA;IACnC,gGAA4B,CAAA;IAC5B,0DAAS,CAAA;AACX,CAAC,EAhBW,iBAAiB,KAAjB,iBAAiB,QAgB5B","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\n\nexport enum AndroidNotificationVisibility {\n UNKNOWN = 0,\n PUBLIC = 1,\n PRIVATE = 2,\n SECRET = 3,\n}\n\nexport enum AndroidAudioContentType {\n UNKNOWN = 0,\n SPEECH = 1,\n MUSIC = 2,\n MOVIE = 3,\n SONIFICATION = 4,\n}\n\nexport enum AndroidImportance {\n UNKNOWN = 0,\n UNSPECIFIED = 1,\n NONE = 2,\n MIN = 3,\n LOW = 4,\n DEFAULT = 5,\n /** @deprecated use DEFAULT instead */\n DEEFAULT = 5,\n HIGH = 6,\n MAX = 7,\n}\n\nexport enum AndroidAudioUsage {\n UNKNOWN = 0,\n MEDIA = 1,\n VOICE_COMMUNICATION = 2,\n VOICE_COMMUNICATION_SIGNALLING = 3,\n ALARM = 4,\n NOTIFICATION = 5,\n NOTIFICATION_RINGTONE = 6,\n NOTIFICATION_COMMUNICATION_REQUEST = 7,\n NOTIFICATION_COMMUNICATION_INSTANT = 8,\n NOTIFICATION_COMMUNICATION_DELAYED = 9,\n NOTIFICATION_EVENT = 10,\n ASSISTANCE_ACCESSIBILITY = 11,\n ASSISTANCE_NAVIGATION_GUIDANCE = 12,\n ASSISTANCE_SONIFICATION = 13,\n GAME = 14,\n}\n\nexport interface AudioAttributes {\n usage: AndroidAudioUsage;\n contentType: AndroidAudioContentType;\n flags: {\n enforceAudibility: boolean;\n requestHardwareAudioVideoSynchronization: boolean;\n };\n}\n\n// We're making inner flags required to set intentionally.\n// Not providing `true` for a flag makes it false, it doesn't make sense\n// to let it be left undefined.\nexport type AudioAttributesInput = Partial;\n\nexport interface NotificationChannel {\n id: string;\n name: string | null;\n importance: AndroidImportance;\n bypassDnd: boolean;\n description: string | null;\n groupId?: string | null;\n lightColor: string;\n lockscreenVisibility: AndroidNotificationVisibility;\n showBadge: boolean;\n sound: 'default' | 'custom' | null;\n audioAttributes: AudioAttributes;\n vibrationPattern: number[] | null;\n enableLights: boolean;\n enableVibrate: boolean;\n}\n\ntype RequiredBy = Partial> & Required>;\n\nexport type NotificationChannelInput = RequiredBy<\n Omit<\n NotificationChannel,\n | 'id' // id is handled separately as a function argument\n | 'audioAttributes' // need to make it AudioAttributesInput\n | 'sound'\n > & { audioAttributes?: AudioAttributesInput; sound?: string | null },\n 'name' | 'importance'\n>;\n\nexport interface NotificationChannelManager extends ProxyNativeModule {\n getNotificationChannelsAsync?: () => Promise;\n getNotificationChannelAsync?: (channelId: string) => Promise;\n setNotificationChannelAsync?: (\n channelId: string,\n channelConfiguration: NotificationChannelInput\n ) => Promise;\n deleteNotificationChannelAsync?: (channelId: string) => Promise;\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelManager.web.d.ts b/packages/expo-notifications/build/NotificationChannelManager.web.d.ts new file mode 100644 index 0000000000000..13ada51bc20e6 --- /dev/null +++ b/packages/expo-notifications/build/NotificationChannelManager.web.d.ts @@ -0,0 +1,3 @@ +import { NotificationChannelManager } from './NotificationChannelManager.types'; +declare const _default: NotificationChannelManager; +export default _default; diff --git a/packages/expo-notifications/build/NotificationChannelManager.web.js b/packages/expo-notifications/build/NotificationChannelManager.web.js new file mode 100644 index 0000000000000..b1676b47d7625 --- /dev/null +++ b/packages/expo-notifications/build/NotificationChannelManager.web.js @@ -0,0 +1,5 @@ +export default { + addListener: () => { }, + removeListeners: () => { }, +}; +//# sourceMappingURL=NotificationChannelManager.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelManager.web.js.map b/packages/expo-notifications/build/NotificationChannelManager.web.js.map new file mode 100644 index 0000000000000..b8fe94b4c41e8 --- /dev/null +++ b/packages/expo-notifications/build/NotificationChannelManager.web.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationChannelManager.web.js","sourceRoot":"","sources":["../src/NotificationChannelManager.web.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACI,CAAC","sourcesContent":["import { NotificationChannelManager } from './NotificationChannelManager.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationChannelManager;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/NotificationChannelManager.ts b/packages/expo-notifications/src/NotificationChannelManager.ts index cce7c685f2161..6caa1dcdd09e4 100644 --- a/packages/expo-notifications/src/NotificationChannelManager.ts +++ b/packages/expo-notifications/src/NotificationChannelManager.ts @@ -1,15 +1,5 @@ -import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core'; +import { NativeModulesProxy } from '@unimodules/core'; -import { NotificationChannel, NotificationChannelInput } from './NotificationChannelManager.types'; - -export interface NotificationChannelManager extends ProxyNativeModule { - getNotificationChannelsAsync: () => Promise; - getNotificationChannelAsync: (channelId: string) => Promise; - setNotificationChannelAsync: ( - channelId: string, - channelConfiguration: NotificationChannelInput - ) => Promise; - deleteNotificationChannelAsync: (channelId: string) => Promise; -} +import { NotificationChannelManager } from './NotificationChannelManager.types'; export default (NativeModulesProxy.ExpoNotificationChannelManager as any) as NotificationChannelManager; diff --git a/packages/expo-notifications/src/NotificationChannelManager.types.ts b/packages/expo-notifications/src/NotificationChannelManager.types.ts index 39a0f59b77061..42a889a70ccfc 100644 --- a/packages/expo-notifications/src/NotificationChannelManager.types.ts +++ b/packages/expo-notifications/src/NotificationChannelManager.types.ts @@ -1,3 +1,5 @@ +import { ProxyNativeModule } from '@unimodules/core'; + export enum AndroidNotificationVisibility { UNKNOWN = 0, PUBLIC = 1, @@ -86,3 +88,13 @@ export type NotificationChannelInput = RequiredBy< > & { audioAttributes?: AudioAttributesInput; sound?: string | null }, 'name' | 'importance' >; + +export interface NotificationChannelManager extends ProxyNativeModule { + getNotificationChannelsAsync?: () => Promise; + getNotificationChannelAsync?: (channelId: string) => Promise; + setNotificationChannelAsync?: ( + channelId: string, + channelConfiguration: NotificationChannelInput + ) => Promise; + deleteNotificationChannelAsync?: (channelId: string) => Promise; +} diff --git a/packages/expo-notifications/src/NotificationChannelManager.web.ts b/packages/expo-notifications/src/NotificationChannelManager.web.ts new file mode 100644 index 0000000000000..987deff10cd09 --- /dev/null +++ b/packages/expo-notifications/src/NotificationChannelManager.web.ts @@ -0,0 +1,6 @@ +import { NotificationChannelManager } from './NotificationChannelManager.types'; + +export default { + addListener: () => {}, + removeListeners: () => {}, +} as NotificationChannelManager; From e0f7852687e0f7638e10a47bf8d2a6fb5df3cd26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 15:55:51 +0200 Subject: [PATCH 05/17] [expo-notifications] Fix types and add web support for NotificationPermissions --- .../build/NotificationPermissions.js | 8 +++++++- .../build/NotificationPermissions.js.map | 2 +- .../build/NotificationPermissionsModule.d.ts | 7 +------ .../build/NotificationPermissionsModule.js.map | 2 +- .../build/NotificationPermissionsModule.types.d.ts | 6 ++++++ .../build/NotificationPermissionsModule.types.js | 1 + .../NotificationPermissionsModule.types.js.map | 1 + .../build/NotificationPermissionsModule.web.d.ts | 3 +++ .../build/NotificationPermissionsModule.web.js | 5 +++++ .../build/NotificationPermissionsModule.web.js.map | 1 + .../src/NotificationPermissions.ts | 10 +++++++++- .../src/NotificationPermissionsModule.ts | 14 ++------------ .../src/NotificationPermissionsModule.types.ts | 13 +++++++++++++ .../src/NotificationPermissionsModule.web.ts | 6 ++++++ 14 files changed, 57 insertions(+), 22 deletions(-) create mode 100644 packages/expo-notifications/build/NotificationPermissionsModule.types.d.ts create mode 100644 packages/expo-notifications/build/NotificationPermissionsModule.types.js create mode 100644 packages/expo-notifications/build/NotificationPermissionsModule.types.js.map create mode 100644 packages/expo-notifications/build/NotificationPermissionsModule.web.d.ts create mode 100644 packages/expo-notifications/build/NotificationPermissionsModule.web.js create mode 100644 packages/expo-notifications/build/NotificationPermissionsModule.web.js.map create mode 100644 packages/expo-notifications/src/NotificationPermissionsModule.types.ts create mode 100644 packages/expo-notifications/src/NotificationPermissionsModule.web.ts diff --git a/packages/expo-notifications/build/NotificationPermissions.js b/packages/expo-notifications/build/NotificationPermissions.js index eefd2e87f136c..198001cbfbc45 100644 --- a/packages/expo-notifications/build/NotificationPermissions.js +++ b/packages/expo-notifications/build/NotificationPermissions.js @@ -1,9 +1,15 @@ -import { Platform } from '@unimodules/core'; +import { Platform, UnavailabilityError } from '@unimodules/core'; import NotificationPermissionsModule from './NotificationPermissionsModule'; export async function getPermissionsAsync() { + if (!NotificationPermissionsModule.getPermissionsAsync) { + throw new UnavailabilityError('Notifications', 'getPermissionsAsync'); + } return await NotificationPermissionsModule.getPermissionsAsync(); } export async function requestPermissionsAsync(permissions) { + if (!NotificationPermissionsModule.requestPermissionsAsync) { + throw new UnavailabilityError('Notifications', 'requestPermissionsAsync'); + } const requestedPermissions = permissions ?? { ios: { allowAlert: true, diff --git a/packages/expo-notifications/build/NotificationPermissions.js.map b/packages/expo-notifications/build/NotificationPermissions.js.map index 13704cad3b992..d3fe147b1bc58 100644 --- a/packages/expo-notifications/build/NotificationPermissions.js.map +++ b/packages/expo-notifications/build/NotificationPermissions.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationPermissions.js","sourceRoot":"","sources":["../src/NotificationPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,6BAA6B,MAAM,iCAAiC,CAAC;AAE5E,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,OAAO,MAAM,6BAA6B,CAAC,mBAAmB,EAAE,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,WAA4C;IACxF,MAAM,oBAAoB,GAAG,WAAW,IAAI;QAC1C,GAAG,EAAE;YACH,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB;KACF,CAAC;IACF,MAAM,4BAA4B,GAAG,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvE,OAAO,MAAM,6BAA6B,CAAC,uBAAuB,CAAC,4BAA4B,CAAC,CAAC;AACnG,CAAC","sourcesContent":["import { Platform } from '@unimodules/core';\n\nimport { NotificationPermissionsRequest } from './NotificationPermissions.types';\nimport NotificationPermissionsModule from './NotificationPermissionsModule';\n\nexport async function getPermissionsAsync() {\n return await NotificationPermissionsModule.getPermissionsAsync();\n}\n\nexport async function requestPermissionsAsync(permissions?: NotificationPermissionsRequest) {\n const requestedPermissions = permissions ?? {\n ios: {\n allowAlert: true,\n allowBadge: true,\n allowSound: true,\n },\n };\n const requestedPlatformPermissions = requestedPermissions[Platform.OS];\n return await NotificationPermissionsModule.requestPermissionsAsync(requestedPlatformPermissions);\n}\n"]} \ No newline at end of file +{"version":3,"file":"NotificationPermissions.js","sourceRoot":"","sources":["../src/NotificationPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGjE,OAAO,6BAA6B,MAAM,iCAAiC,CAAC;AAE5E,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC,6BAA6B,CAAC,mBAAmB,EAAE;QACtD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;KACvE;IAED,OAAO,MAAM,6BAA6B,CAAC,mBAAmB,EAAE,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,WAA4C;IACxF,IAAI,CAAC,6BAA6B,CAAC,uBAAuB,EAAE;QAC1D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;KAC3E;IAED,MAAM,oBAAoB,GAAG,WAAW,IAAI;QAC1C,GAAG,EAAE;YACH,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;SACjB;KACF,CAAC;IACF,MAAM,4BAA4B,GAAG,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvE,OAAO,MAAM,6BAA6B,CAAC,uBAAuB,CAAC,4BAA4B,CAAC,CAAC;AACnG,CAAC","sourcesContent":["import { Platform, UnavailabilityError } from '@unimodules/core';\n\nimport { NotificationPermissionsRequest } from './NotificationPermissions.types';\nimport NotificationPermissionsModule from './NotificationPermissionsModule';\n\nexport async function getPermissionsAsync() {\n if (!NotificationPermissionsModule.getPermissionsAsync) {\n throw new UnavailabilityError('Notifications', 'getPermissionsAsync');\n }\n\n return await NotificationPermissionsModule.getPermissionsAsync();\n}\n\nexport async function requestPermissionsAsync(permissions?: NotificationPermissionsRequest) {\n if (!NotificationPermissionsModule.requestPermissionsAsync) {\n throw new UnavailabilityError('Notifications', 'requestPermissionsAsync');\n }\n\n const requestedPermissions = permissions ?? {\n ios: {\n allowAlert: true,\n allowBadge: true,\n allowSound: true,\n },\n };\n const requestedPlatformPermissions = requestedPermissions[Platform.OS];\n return await NotificationPermissionsModule.requestPermissionsAsync(requestedPlatformPermissions);\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.d.ts b/packages/expo-notifications/build/NotificationPermissionsModule.d.ts index 868cb788a5a5f..26dd8cc94eaa6 100644 --- a/packages/expo-notifications/build/NotificationPermissionsModule.d.ts +++ b/packages/expo-notifications/build/NotificationPermissionsModule.d.ts @@ -1,8 +1,3 @@ -import { ProxyNativeModule } from '@unimodules/core'; -import { NotificationPermissionsStatus, NativeNotificationPermissionsRequest } from './NotificationPermissions.types'; -export interface NotificationPermissionsModule extends ProxyNativeModule { - getPermissionsAsync: () => Promise; - requestPermissionsAsync: (request: NativeNotificationPermissionsRequest) => Promise; -} +import { NotificationPermissionsModule } from './NotificationPermissionsModule.types'; declare const _default: NotificationPermissionsModule; export default _default; diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.js.map b/packages/expo-notifications/build/NotificationPermissionsModule.js.map index b642f5e5dd0ce..9ee38156e8466 100644 --- a/packages/expo-notifications/build/NotificationPermissionsModule.js.map +++ b/packages/expo-notifications/build/NotificationPermissionsModule.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationPermissionsModule.js","sourceRoot":"","sources":["../src/NotificationPermissionsModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,kBAAkB,CAAC;AAczE,eAAgB,kBAAkB,CAAC,iCAA0E,CAAC","sourcesContent":["import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core';\n\nimport {\n NotificationPermissionsStatus,\n NativeNotificationPermissionsRequest,\n} from './NotificationPermissions.types';\n\nexport interface NotificationPermissionsModule extends ProxyNativeModule {\n getPermissionsAsync: () => Promise;\n requestPermissionsAsync: (\n request: NativeNotificationPermissionsRequest\n ) => Promise;\n}\n\nexport default (NativeModulesProxy.ExpoNotificationPermissionsModule as any) as NotificationPermissionsModule;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationPermissionsModule.js","sourceRoot":"","sources":["../src/NotificationPermissionsModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,iCAA0E,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationPermissionsModule } from './NotificationPermissionsModule.types';\n\nexport default (NativeModulesProxy.ExpoNotificationPermissionsModule as any) as NotificationPermissionsModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.types.d.ts b/packages/expo-notifications/build/NotificationPermissionsModule.types.d.ts new file mode 100644 index 0000000000000..c2e1999cc39e6 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPermissionsModule.types.d.ts @@ -0,0 +1,6 @@ +import { ProxyNativeModule } from '@unimodules/core'; +import { NotificationPermissionsStatus, NativeNotificationPermissionsRequest } from './NotificationPermissions.types'; +export interface NotificationPermissionsModule extends ProxyNativeModule { + getPermissionsAsync?: () => Promise; + requestPermissionsAsync?: (request: NativeNotificationPermissionsRequest) => Promise; +} diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.types.js b/packages/expo-notifications/build/NotificationPermissionsModule.types.js new file mode 100644 index 0000000000000..c7425951d42f2 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPermissionsModule.types.js @@ -0,0 +1 @@ +//# sourceMappingURL=NotificationPermissionsModule.types.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.types.js.map b/packages/expo-notifications/build/NotificationPermissionsModule.types.js.map new file mode 100644 index 0000000000000..4fe1919e6c867 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPermissionsModule.types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationPermissionsModule.types.js","sourceRoot":"","sources":["../src/NotificationPermissionsModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\n\nimport {\n NotificationPermissionsStatus,\n NativeNotificationPermissionsRequest,\n} from './NotificationPermissions.types';\n\nexport interface NotificationPermissionsModule extends ProxyNativeModule {\n getPermissionsAsync?: () => Promise;\n requestPermissionsAsync?: (\n request: NativeNotificationPermissionsRequest\n ) => Promise;\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.web.d.ts b/packages/expo-notifications/build/NotificationPermissionsModule.web.d.ts new file mode 100644 index 0000000000000..26dd8cc94eaa6 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPermissionsModule.web.d.ts @@ -0,0 +1,3 @@ +import { NotificationPermissionsModule } from './NotificationPermissionsModule.types'; +declare const _default: NotificationPermissionsModule; +export default _default; diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.web.js b/packages/expo-notifications/build/NotificationPermissionsModule.web.js new file mode 100644 index 0000000000000..e9a00e15927c6 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPermissionsModule.web.js @@ -0,0 +1,5 @@ +export default { + addListener: () => { }, + removeListeners: () => { }, +}; +//# sourceMappingURL=NotificationPermissionsModule.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.web.js.map b/packages/expo-notifications/build/NotificationPermissionsModule.web.js.map new file mode 100644 index 0000000000000..295f6f4613a9f --- /dev/null +++ b/packages/expo-notifications/build/NotificationPermissionsModule.web.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationPermissionsModule.web.js","sourceRoot":"","sources":["../src/NotificationPermissionsModule.web.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACO,CAAC","sourcesContent":["import { NotificationPermissionsModule } from './NotificationPermissionsModule.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationPermissionsModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/NotificationPermissions.ts b/packages/expo-notifications/src/NotificationPermissions.ts index 133fa8f37cb47..5675b2e5b1b32 100644 --- a/packages/expo-notifications/src/NotificationPermissions.ts +++ b/packages/expo-notifications/src/NotificationPermissions.ts @@ -1,13 +1,21 @@ -import { Platform } from '@unimodules/core'; +import { Platform, UnavailabilityError } from '@unimodules/core'; import { NotificationPermissionsRequest } from './NotificationPermissions.types'; import NotificationPermissionsModule from './NotificationPermissionsModule'; export async function getPermissionsAsync() { + if (!NotificationPermissionsModule.getPermissionsAsync) { + throw new UnavailabilityError('Notifications', 'getPermissionsAsync'); + } + return await NotificationPermissionsModule.getPermissionsAsync(); } export async function requestPermissionsAsync(permissions?: NotificationPermissionsRequest) { + if (!NotificationPermissionsModule.requestPermissionsAsync) { + throw new UnavailabilityError('Notifications', 'requestPermissionsAsync'); + } + const requestedPermissions = permissions ?? { ios: { allowAlert: true, diff --git a/packages/expo-notifications/src/NotificationPermissionsModule.ts b/packages/expo-notifications/src/NotificationPermissionsModule.ts index e379ef8dc37ce..ee56d2cf3fbb0 100644 --- a/packages/expo-notifications/src/NotificationPermissionsModule.ts +++ b/packages/expo-notifications/src/NotificationPermissionsModule.ts @@ -1,15 +1,5 @@ -import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core'; +import { NativeModulesProxy } from '@unimodules/core'; -import { - NotificationPermissionsStatus, - NativeNotificationPermissionsRequest, -} from './NotificationPermissions.types'; - -export interface NotificationPermissionsModule extends ProxyNativeModule { - getPermissionsAsync: () => Promise; - requestPermissionsAsync: ( - request: NativeNotificationPermissionsRequest - ) => Promise; -} +import { NotificationPermissionsModule } from './NotificationPermissionsModule.types'; export default (NativeModulesProxy.ExpoNotificationPermissionsModule as any) as NotificationPermissionsModule; diff --git a/packages/expo-notifications/src/NotificationPermissionsModule.types.ts b/packages/expo-notifications/src/NotificationPermissionsModule.types.ts new file mode 100644 index 0000000000000..f8b2c4fe35755 --- /dev/null +++ b/packages/expo-notifications/src/NotificationPermissionsModule.types.ts @@ -0,0 +1,13 @@ +import { ProxyNativeModule } from '@unimodules/core'; + +import { + NotificationPermissionsStatus, + NativeNotificationPermissionsRequest, +} from './NotificationPermissions.types'; + +export interface NotificationPermissionsModule extends ProxyNativeModule { + getPermissionsAsync?: () => Promise; + requestPermissionsAsync?: ( + request: NativeNotificationPermissionsRequest + ) => Promise; +} diff --git a/packages/expo-notifications/src/NotificationPermissionsModule.web.ts b/packages/expo-notifications/src/NotificationPermissionsModule.web.ts new file mode 100644 index 0000000000000..6ce6c5f758b98 --- /dev/null +++ b/packages/expo-notifications/src/NotificationPermissionsModule.web.ts @@ -0,0 +1,6 @@ +import { NotificationPermissionsModule } from './NotificationPermissionsModule.types'; + +export default { + addListener: () => {}, + removeListeners: () => {}, +} as NotificationPermissionsModule; From 6f5324ffb7144dd98a654397dcab29eb996b732f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 15:57:15 +0200 Subject: [PATCH 06/17] =?UTF-8?q?[expo-notifications]=20Rename=20Notificat?= =?UTF-8?q?ionPresenter=20to=20=E2=80=A6Module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/expo-notifications/build/NotificationPresenter.js.map | 1 - ...ificationPresenter.d.ts => NotificationPresenterModule.d.ts} | 0 ...{NotificationPresenter.js => NotificationPresenterModule.js} | 2 +- .../expo-notifications/build/NotificationPresenterModule.js.map | 1 + .../expo-notifications/build/dismissAllNotificationsAsync.js | 2 +- .../build/dismissAllNotificationsAsync.js.map | 2 +- packages/expo-notifications/build/dismissNotificationAsync.js | 2 +- .../expo-notifications/build/dismissNotificationAsync.js.map | 2 +- .../expo-notifications/build/getPresentedNotificationsAsync.js | 2 +- .../build/getPresentedNotificationsAsync.js.map | 2 +- packages/expo-notifications/build/presentNotificationAsync.js | 2 +- .../expo-notifications/build/presentNotificationAsync.js.map | 2 +- ...{NotificationPresenter.ts => NotificationPresenterModule.ts} | 0 packages/expo-notifications/src/dismissAllNotificationsAsync.ts | 2 +- packages/expo-notifications/src/dismissNotificationAsync.ts | 2 +- .../expo-notifications/src/getPresentedNotificationsAsync.ts | 2 +- packages/expo-notifications/src/presentNotificationAsync.ts | 2 +- 17 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 packages/expo-notifications/build/NotificationPresenter.js.map rename packages/expo-notifications/build/{NotificationPresenter.d.ts => NotificationPresenterModule.d.ts} (100%) rename packages/expo-notifications/build/{NotificationPresenter.js => NotificationPresenterModule.js} (67%) create mode 100644 packages/expo-notifications/build/NotificationPresenterModule.js.map rename packages/expo-notifications/src/{NotificationPresenter.ts => NotificationPresenterModule.ts} (100%) diff --git a/packages/expo-notifications/build/NotificationPresenter.js.map b/packages/expo-notifications/build/NotificationPresenter.js.map deleted file mode 100644 index 3d3527ee14de3..0000000000000 --- a/packages/expo-notifications/build/NotificationPresenter.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"NotificationPresenter.js","sourceRoot":"","sources":["../src/NotificationPresenter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,kBAAkB,CAAC;AAczE,eAAgB,kBAAkB,CAAC,yBAAgE,CAAC","sourcesContent":["import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core';\n\nimport { Notification, NotificationContentInput } from './Notifications.types';\n\nexport interface NotificationPresenterModule extends ProxyNativeModule {\n getPresentedNotificationsAsync: () => Promise;\n presentNotificationAsync: (\n identifier: string,\n content: NotificationContentInput\n ) => Promise;\n dismissNotificationAsync: (identifier: string) => Promise;\n dismissAllNotificationsAsync: () => Promise;\n}\n\nexport default (NativeModulesProxy.ExpoNotificationPresenter as any) as NotificationPresenterModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenter.d.ts b/packages/expo-notifications/build/NotificationPresenterModule.d.ts similarity index 100% rename from packages/expo-notifications/build/NotificationPresenter.d.ts rename to packages/expo-notifications/build/NotificationPresenterModule.d.ts diff --git a/packages/expo-notifications/build/NotificationPresenter.js b/packages/expo-notifications/build/NotificationPresenterModule.js similarity index 67% rename from packages/expo-notifications/build/NotificationPresenter.js rename to packages/expo-notifications/build/NotificationPresenterModule.js index 8fcd8b5e0dee9..85f838c53b6a9 100644 --- a/packages/expo-notifications/build/NotificationPresenter.js +++ b/packages/expo-notifications/build/NotificationPresenterModule.js @@ -1,3 +1,3 @@ import { NativeModulesProxy } from '@unimodules/core'; export default NativeModulesProxy.ExpoNotificationPresenter; -//# sourceMappingURL=NotificationPresenter.js.map \ No newline at end of file +//# sourceMappingURL=NotificationPresenterModule.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenterModule.js.map b/packages/expo-notifications/build/NotificationPresenterModule.js.map new file mode 100644 index 0000000000000..7f161609cf294 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPresenterModule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationPresenterModule.js","sourceRoot":"","sources":["../src/NotificationPresenterModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,kBAAkB,CAAC;AAczE,eAAgB,kBAAkB,CAAC,yBAAgE,CAAC","sourcesContent":["import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core';\n\nimport { Notification, NotificationContentInput } from './Notifications.types';\n\nexport interface NotificationPresenterModule extends ProxyNativeModule {\n getPresentedNotificationsAsync: () => Promise;\n presentNotificationAsync: (\n identifier: string,\n content: NotificationContentInput\n ) => Promise;\n dismissNotificationAsync: (identifier: string) => Promise;\n dismissAllNotificationsAsync: () => Promise;\n}\n\nexport default (NativeModulesProxy.ExpoNotificationPresenter as any) as NotificationPresenterModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/dismissAllNotificationsAsync.js b/packages/expo-notifications/build/dismissAllNotificationsAsync.js index 1f6128bc20c7d..c54cac59377dd 100644 --- a/packages/expo-notifications/build/dismissAllNotificationsAsync.js +++ b/packages/expo-notifications/build/dismissAllNotificationsAsync.js @@ -1,5 +1,5 @@ import { UnavailabilityError } from '@unimodules/core'; -import NotificationPresenter from './NotificationPresenter'; +import NotificationPresenter from './NotificationPresenterModule'; export default async function dismissAllNotificationsAsync() { if (!NotificationPresenter.dismissAllNotificationsAsync) { throw new UnavailabilityError('Notifications', 'dismissAllNotificationsAsync'); diff --git a/packages/expo-notifications/build/dismissAllNotificationsAsync.js.map b/packages/expo-notifications/build/dismissAllNotificationsAsync.js.map index 2550682733c1b..f3a573109d04e 100644 --- a/packages/expo-notifications/build/dismissAllNotificationsAsync.js.map +++ b/packages/expo-notifications/build/dismissAllNotificationsAsync.js.map @@ -1 +1 @@ -{"version":3,"file":"dismissAllNotificationsAsync.js","sourceRoot":"","sources":["../src/dismissAllNotificationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,4BAA4B;IACxD,IAAI,CAAC,qBAAqB,CAAC,4BAA4B,EAAE;QACvD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,8BAA8B,CAAC,CAAC;KAChF;IAED,OAAO,MAAM,qBAAqB,CAAC,4BAA4B,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport NotificationPresenter from './NotificationPresenter';\n\nexport default async function dismissAllNotificationsAsync(): Promise {\n if (!NotificationPresenter.dismissAllNotificationsAsync) {\n throw new UnavailabilityError('Notifications', 'dismissAllNotificationsAsync');\n }\n\n return await NotificationPresenter.dismissAllNotificationsAsync();\n}\n"]} \ No newline at end of file +{"version":3,"file":"dismissAllNotificationsAsync.js","sourceRoot":"","sources":["../src/dismissAllNotificationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAElE,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,4BAA4B;IACxD,IAAI,CAAC,qBAAqB,CAAC,4BAA4B,EAAE;QACvD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,8BAA8B,CAAC,CAAC;KAChF;IAED,OAAO,MAAM,qBAAqB,CAAC,4BAA4B,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport NotificationPresenter from './NotificationPresenterModule';\n\nexport default async function dismissAllNotificationsAsync(): Promise {\n if (!NotificationPresenter.dismissAllNotificationsAsync) {\n throw new UnavailabilityError('Notifications', 'dismissAllNotificationsAsync');\n }\n\n return await NotificationPresenter.dismissAllNotificationsAsync();\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/dismissNotificationAsync.js b/packages/expo-notifications/build/dismissNotificationAsync.js index 776ae51d58d59..11e6b75e5046f 100644 --- a/packages/expo-notifications/build/dismissNotificationAsync.js +++ b/packages/expo-notifications/build/dismissNotificationAsync.js @@ -1,5 +1,5 @@ import { UnavailabilityError } from '@unimodules/core'; -import NotificationPresenter from './NotificationPresenter'; +import NotificationPresenter from './NotificationPresenterModule'; export default async function dismissNotificationAsync(notificationIdentifier) { if (!NotificationPresenter.dismissNotificationAsync) { throw new UnavailabilityError('Notifications', 'dismissNotificationAsync'); diff --git a/packages/expo-notifications/build/dismissNotificationAsync.js.map b/packages/expo-notifications/build/dismissNotificationAsync.js.map index 4d8191dbe915b..f1d112969d323 100644 --- a/packages/expo-notifications/build/dismissNotificationAsync.js.map +++ b/packages/expo-notifications/build/dismissNotificationAsync.js.map @@ -1 +1 @@ -{"version":3,"file":"dismissNotificationAsync.js","sourceRoot":"","sources":["../src/dismissNotificationAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,wBAAwB,CACpD,sBAA8B;IAE9B,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,EAAE;QACnD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAC;KAC5E;IAED,OAAO,MAAM,qBAAqB,CAAC,wBAAwB,CAAC,sBAAsB,CAAC,CAAC;AACtF,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport NotificationPresenter from './NotificationPresenter';\n\nexport default async function dismissNotificationAsync(\n notificationIdentifier: string\n): Promise {\n if (!NotificationPresenter.dismissNotificationAsync) {\n throw new UnavailabilityError('Notifications', 'dismissNotificationAsync');\n }\n\n return await NotificationPresenter.dismissNotificationAsync(notificationIdentifier);\n}\n"]} \ No newline at end of file +{"version":3,"file":"dismissNotificationAsync.js","sourceRoot":"","sources":["../src/dismissNotificationAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAElE,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,wBAAwB,CACpD,sBAA8B;IAE9B,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,EAAE;QACnD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAC;KAC5E;IAED,OAAO,MAAM,qBAAqB,CAAC,wBAAwB,CAAC,sBAAsB,CAAC,CAAC;AACtF,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport NotificationPresenter from './NotificationPresenterModule';\n\nexport default async function dismissNotificationAsync(\n notificationIdentifier: string\n): Promise {\n if (!NotificationPresenter.dismissNotificationAsync) {\n throw new UnavailabilityError('Notifications', 'dismissNotificationAsync');\n }\n\n return await NotificationPresenter.dismissNotificationAsync(notificationIdentifier);\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/getPresentedNotificationsAsync.js b/packages/expo-notifications/build/getPresentedNotificationsAsync.js index ffd2e422e033b..560f130b4b73e 100644 --- a/packages/expo-notifications/build/getPresentedNotificationsAsync.js +++ b/packages/expo-notifications/build/getPresentedNotificationsAsync.js @@ -1,5 +1,5 @@ import { UnavailabilityError } from '@unimodules/core'; -import NotificationPresenter from './NotificationPresenter'; +import NotificationPresenter from './NotificationPresenterModule'; export default async function getPresentedNotificationsAsync() { if (!NotificationPresenter.getPresentedNotificationsAsync) { throw new UnavailabilityError('Notifications', 'getPresentedNotificationsAsync'); diff --git a/packages/expo-notifications/build/getPresentedNotificationsAsync.js.map b/packages/expo-notifications/build/getPresentedNotificationsAsync.js.map index 947a7fb6d7ef9..b7bdf3c0c404d 100644 --- a/packages/expo-notifications/build/getPresentedNotificationsAsync.js.map +++ b/packages/expo-notifications/build/getPresentedNotificationsAsync.js.map @@ -1 +1 @@ -{"version":3,"file":"getPresentedNotificationsAsync.js","sourceRoot":"","sources":["../src/getPresentedNotificationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAG5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,8BAA8B;IAC1D,IAAI,CAAC,qBAAqB,CAAC,8BAA8B,EAAE;QACzD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,gCAAgC,CAAC,CAAC;KAClF;IAED,OAAO,MAAM,qBAAqB,CAAC,8BAA8B,EAAE,CAAC;AACtE,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport NotificationPresenter from './NotificationPresenter';\nimport { Notification } from './Notifications.types';\n\nexport default async function getPresentedNotificationsAsync(): Promise {\n if (!NotificationPresenter.getPresentedNotificationsAsync) {\n throw new UnavailabilityError('Notifications', 'getPresentedNotificationsAsync');\n }\n\n return await NotificationPresenter.getPresentedNotificationsAsync();\n}\n"]} \ No newline at end of file +{"version":3,"file":"getPresentedNotificationsAsync.js","sourceRoot":"","sources":["../src/getPresentedNotificationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAGlE,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,8BAA8B;IAC1D,IAAI,CAAC,qBAAqB,CAAC,8BAA8B,EAAE;QACzD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,gCAAgC,CAAC,CAAC;KAClF;IAED,OAAO,MAAM,qBAAqB,CAAC,8BAA8B,EAAE,CAAC;AACtE,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport NotificationPresenter from './NotificationPresenterModule';\nimport { Notification } from './Notifications.types';\n\nexport default async function getPresentedNotificationsAsync(): Promise {\n if (!NotificationPresenter.getPresentedNotificationsAsync) {\n throw new UnavailabilityError('Notifications', 'getPresentedNotificationsAsync');\n }\n\n return await NotificationPresenter.getPresentedNotificationsAsync();\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/presentNotificationAsync.js b/packages/expo-notifications/build/presentNotificationAsync.js index 6fcdd9dd6f4ef..7d9c1163dea4e 100644 --- a/packages/expo-notifications/build/presentNotificationAsync.js +++ b/packages/expo-notifications/build/presentNotificationAsync.js @@ -1,5 +1,5 @@ import uuidv4 from 'uuid/v4'; -import NotificationPresenter from './NotificationPresenter'; +import NotificationPresenter from './NotificationPresenterModule'; let warningMessageShown = false; export default async function presentNotificationAsync(content, identifier = uuidv4()) { if (__DEV__ && !warningMessageShown) { diff --git a/packages/expo-notifications/build/presentNotificationAsync.js.map b/packages/expo-notifications/build/presentNotificationAsync.js.map index 1376c61d39693..ba12cd1cf58f5 100644 --- a/packages/expo-notifications/build/presentNotificationAsync.js.map +++ b/packages/expo-notifications/build/presentNotificationAsync.js.map @@ -1 +1 @@ -{"version":3,"file":"presentNotificationAsync.js","sourceRoot":"","sources":["../src/presentNotificationAsync.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAG5D,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,wBAAwB,CACpD,OAAiC,EACjC,aAAqB,MAAM,EAAE;IAE7B,IAAI,OAAO,IAAI,CAAC,mBAAmB,EAAE;QACnC,OAAO,CAAC,IAAI,CACV,qMAAqM,CACtM,CAAC;QACF,mBAAmB,GAAG,IAAI,CAAC;KAC5B;IACD,OAAO,MAAM,qBAAqB,CAAC,wBAAwB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import uuidv4 from 'uuid/v4';\n\nimport NotificationPresenter from './NotificationPresenter';\nimport { NotificationContentInput } from './Notifications.types';\n\nlet warningMessageShown = false;\n\nexport default async function presentNotificationAsync(\n content: NotificationContentInput,\n identifier: string = uuidv4()\n): Promise {\n if (__DEV__ && !warningMessageShown) {\n console.warn(\n '`presentNotificationAsync` has been deprecated in favor of using `scheduleNotificationAsync` + an explicit notification handler. Read more at https://expo.fyi/presenting-notifications-deprecated.'\n );\n warningMessageShown = true;\n }\n return await NotificationPresenter.presentNotificationAsync(identifier, content);\n}\n"]} \ No newline at end of file +{"version":3,"file":"presentNotificationAsync.js","sourceRoot":"","sources":["../src/presentNotificationAsync.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAGlE,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,wBAAwB,CACpD,OAAiC,EACjC,aAAqB,MAAM,EAAE;IAE7B,IAAI,OAAO,IAAI,CAAC,mBAAmB,EAAE;QACnC,OAAO,CAAC,IAAI,CACV,qMAAqM,CACtM,CAAC;QACF,mBAAmB,GAAG,IAAI,CAAC;KAC5B;IACD,OAAO,MAAM,qBAAqB,CAAC,wBAAwB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import uuidv4 from 'uuid/v4';\n\nimport NotificationPresenter from './NotificationPresenterModule';\nimport { NotificationContentInput } from './Notifications.types';\n\nlet warningMessageShown = false;\n\nexport default async function presentNotificationAsync(\n content: NotificationContentInput,\n identifier: string = uuidv4()\n): Promise {\n if (__DEV__ && !warningMessageShown) {\n console.warn(\n '`presentNotificationAsync` has been deprecated in favor of using `scheduleNotificationAsync` + an explicit notification handler. Read more at https://expo.fyi/presenting-notifications-deprecated.'\n );\n warningMessageShown = true;\n }\n return await NotificationPresenter.presentNotificationAsync(identifier, content);\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/NotificationPresenter.ts b/packages/expo-notifications/src/NotificationPresenterModule.ts similarity index 100% rename from packages/expo-notifications/src/NotificationPresenter.ts rename to packages/expo-notifications/src/NotificationPresenterModule.ts diff --git a/packages/expo-notifications/src/dismissAllNotificationsAsync.ts b/packages/expo-notifications/src/dismissAllNotificationsAsync.ts index 5b7704386d494..bd138caf3f40b 100644 --- a/packages/expo-notifications/src/dismissAllNotificationsAsync.ts +++ b/packages/expo-notifications/src/dismissAllNotificationsAsync.ts @@ -1,6 +1,6 @@ import { UnavailabilityError } from '@unimodules/core'; -import NotificationPresenter from './NotificationPresenter'; +import NotificationPresenter from './NotificationPresenterModule'; export default async function dismissAllNotificationsAsync(): Promise { if (!NotificationPresenter.dismissAllNotificationsAsync) { diff --git a/packages/expo-notifications/src/dismissNotificationAsync.ts b/packages/expo-notifications/src/dismissNotificationAsync.ts index 2c273990fec31..eea5351e1c12f 100644 --- a/packages/expo-notifications/src/dismissNotificationAsync.ts +++ b/packages/expo-notifications/src/dismissNotificationAsync.ts @@ -1,6 +1,6 @@ import { UnavailabilityError } from '@unimodules/core'; -import NotificationPresenter from './NotificationPresenter'; +import NotificationPresenter from './NotificationPresenterModule'; export default async function dismissNotificationAsync( notificationIdentifier: string diff --git a/packages/expo-notifications/src/getPresentedNotificationsAsync.ts b/packages/expo-notifications/src/getPresentedNotificationsAsync.ts index 1bf5a9b8fbba0..9036a85ebd493 100644 --- a/packages/expo-notifications/src/getPresentedNotificationsAsync.ts +++ b/packages/expo-notifications/src/getPresentedNotificationsAsync.ts @@ -1,6 +1,6 @@ import { UnavailabilityError } from '@unimodules/core'; -import NotificationPresenter from './NotificationPresenter'; +import NotificationPresenter from './NotificationPresenterModule'; import { Notification } from './Notifications.types'; export default async function getPresentedNotificationsAsync(): Promise { diff --git a/packages/expo-notifications/src/presentNotificationAsync.ts b/packages/expo-notifications/src/presentNotificationAsync.ts index 8caefb34b6791..0645b9950f3ff 100644 --- a/packages/expo-notifications/src/presentNotificationAsync.ts +++ b/packages/expo-notifications/src/presentNotificationAsync.ts @@ -1,6 +1,6 @@ import uuidv4 from 'uuid/v4'; -import NotificationPresenter from './NotificationPresenter'; +import NotificationPresenter from './NotificationPresenterModule'; import { NotificationContentInput } from './Notifications.types'; let warningMessageShown = false; From e2766e1803120d52268c8b4259209d0ea6b65313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 16:01:21 +0200 Subject: [PATCH 07/17] [expo-notifications] Fix types and add web support for NotificationPresenter --- .../build/NotificationPresenterModule.d.ts | 9 +-------- .../build/NotificationPresenterModule.js.map | 2 +- .../build/NotificationPresenterModule.types.d.ts | 8 ++++++++ .../build/NotificationPresenterModule.types.js | 1 + .../build/NotificationPresenterModule.types.js.map | 1 + .../build/NotificationPresenterModule.web.d.ts | 3 +++ .../build/NotificationPresenterModule.web.js | 5 +++++ .../build/NotificationPresenterModule.web.js.map | 1 + .../build/presentNotificationAsync.js | 4 ++++ .../build/presentNotificationAsync.js.map | 2 +- .../src/NotificationPresenterModule.ts | 14 ++------------ .../src/NotificationPresenterModule.types.ts | 13 +++++++++++++ .../src/NotificationPresenterModule.web.ts | 6 ++++++ .../src/presentNotificationAsync.ts | 6 ++++++ 14 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 packages/expo-notifications/build/NotificationPresenterModule.types.d.ts create mode 100644 packages/expo-notifications/build/NotificationPresenterModule.types.js create mode 100644 packages/expo-notifications/build/NotificationPresenterModule.types.js.map create mode 100644 packages/expo-notifications/build/NotificationPresenterModule.web.d.ts create mode 100644 packages/expo-notifications/build/NotificationPresenterModule.web.js create mode 100644 packages/expo-notifications/build/NotificationPresenterModule.web.js.map create mode 100644 packages/expo-notifications/src/NotificationPresenterModule.types.ts create mode 100644 packages/expo-notifications/src/NotificationPresenterModule.web.ts diff --git a/packages/expo-notifications/build/NotificationPresenterModule.d.ts b/packages/expo-notifications/build/NotificationPresenterModule.d.ts index 17460f9ee3a37..d63efb20c57af 100644 --- a/packages/expo-notifications/build/NotificationPresenterModule.d.ts +++ b/packages/expo-notifications/build/NotificationPresenterModule.d.ts @@ -1,10 +1,3 @@ -import { ProxyNativeModule } from '@unimodules/core'; -import { Notification, NotificationContentInput } from './Notifications.types'; -export interface NotificationPresenterModule extends ProxyNativeModule { - getPresentedNotificationsAsync: () => Promise; - presentNotificationAsync: (identifier: string, content: NotificationContentInput) => Promise; - dismissNotificationAsync: (identifier: string) => Promise; - dismissAllNotificationsAsync: () => Promise; -} +import { NotificationPresenterModule } from './NotificationPresenterModule.types'; declare const _default: NotificationPresenterModule; export default _default; diff --git a/packages/expo-notifications/build/NotificationPresenterModule.js.map b/packages/expo-notifications/build/NotificationPresenterModule.js.map index 7f161609cf294..160367c036061 100644 --- a/packages/expo-notifications/build/NotificationPresenterModule.js.map +++ b/packages/expo-notifications/build/NotificationPresenterModule.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationPresenterModule.js","sourceRoot":"","sources":["../src/NotificationPresenterModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,kBAAkB,CAAC;AAczE,eAAgB,kBAAkB,CAAC,yBAAgE,CAAC","sourcesContent":["import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core';\n\nimport { Notification, NotificationContentInput } from './Notifications.types';\n\nexport interface NotificationPresenterModule extends ProxyNativeModule {\n getPresentedNotificationsAsync: () => Promise;\n presentNotificationAsync: (\n identifier: string,\n content: NotificationContentInput\n ) => Promise;\n dismissNotificationAsync: (identifier: string) => Promise;\n dismissAllNotificationsAsync: () => Promise;\n}\n\nexport default (NativeModulesProxy.ExpoNotificationPresenter as any) as NotificationPresenterModule;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationPresenterModule.js","sourceRoot":"","sources":["../src/NotificationPresenterModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,yBAAgE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationPresenterModule } from './NotificationPresenterModule.types';\n\nexport default (NativeModulesProxy.ExpoNotificationPresenter as any) as NotificationPresenterModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenterModule.types.d.ts b/packages/expo-notifications/build/NotificationPresenterModule.types.d.ts new file mode 100644 index 0000000000000..fc1c1fedd1ea3 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPresenterModule.types.d.ts @@ -0,0 +1,8 @@ +import { ProxyNativeModule } from '@unimodules/core'; +import { Notification, NotificationContentInput } from './Notifications.types'; +export interface NotificationPresenterModule extends ProxyNativeModule { + getPresentedNotificationsAsync?: () => Promise; + presentNotificationAsync?: (identifier: string, content: NotificationContentInput) => Promise; + dismissNotificationAsync?: (identifier: string) => Promise; + dismissAllNotificationsAsync?: () => Promise; +} diff --git a/packages/expo-notifications/build/NotificationPresenterModule.types.js b/packages/expo-notifications/build/NotificationPresenterModule.types.js new file mode 100644 index 0000000000000..12d39984d04f0 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPresenterModule.types.js @@ -0,0 +1 @@ +//# sourceMappingURL=NotificationPresenterModule.types.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenterModule.types.js.map b/packages/expo-notifications/build/NotificationPresenterModule.types.js.map new file mode 100644 index 0000000000000..a125bcb00a65e --- /dev/null +++ b/packages/expo-notifications/build/NotificationPresenterModule.types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationPresenterModule.types.js","sourceRoot":"","sources":["../src/NotificationPresenterModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\n\nimport { Notification, NotificationContentInput } from './Notifications.types';\n\nexport interface NotificationPresenterModule extends ProxyNativeModule {\n getPresentedNotificationsAsync?: () => Promise;\n presentNotificationAsync?: (\n identifier: string,\n content: NotificationContentInput\n ) => Promise;\n dismissNotificationAsync?: (identifier: string) => Promise;\n dismissAllNotificationsAsync?: () => Promise;\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenterModule.web.d.ts b/packages/expo-notifications/build/NotificationPresenterModule.web.d.ts new file mode 100644 index 0000000000000..d63efb20c57af --- /dev/null +++ b/packages/expo-notifications/build/NotificationPresenterModule.web.d.ts @@ -0,0 +1,3 @@ +import { NotificationPresenterModule } from './NotificationPresenterModule.types'; +declare const _default: NotificationPresenterModule; +export default _default; diff --git a/packages/expo-notifications/build/NotificationPresenterModule.web.js b/packages/expo-notifications/build/NotificationPresenterModule.web.js new file mode 100644 index 0000000000000..f568187888519 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPresenterModule.web.js @@ -0,0 +1,5 @@ +export default { + addListener: () => { }, + removeListeners: () => { }, +}; +//# sourceMappingURL=NotificationPresenterModule.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenterModule.web.js.map b/packages/expo-notifications/build/NotificationPresenterModule.web.js.map new file mode 100644 index 0000000000000..ab5327738b023 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPresenterModule.web.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationPresenterModule.web.js","sourceRoot":"","sources":["../src/NotificationPresenterModule.web.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACK,CAAC","sourcesContent":["import { NotificationPresenterModule } from './NotificationPresenterModule.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationPresenterModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/presentNotificationAsync.js b/packages/expo-notifications/build/presentNotificationAsync.js index 7d9c1163dea4e..9da0086be791e 100644 --- a/packages/expo-notifications/build/presentNotificationAsync.js +++ b/packages/expo-notifications/build/presentNotificationAsync.js @@ -1,3 +1,4 @@ +import { UnavailabilityError } from '@unimodules/core'; import uuidv4 from 'uuid/v4'; import NotificationPresenter from './NotificationPresenterModule'; let warningMessageShown = false; @@ -6,6 +7,9 @@ export default async function presentNotificationAsync(content, identifier = uui console.warn('`presentNotificationAsync` has been deprecated in favor of using `scheduleNotificationAsync` + an explicit notification handler. Read more at https://expo.fyi/presenting-notifications-deprecated.'); warningMessageShown = true; } + if (!NotificationPresenter.presentNotificationAsync) { + throw new UnavailabilityError('Notifications', 'presentNotificationAsync'); + } return await NotificationPresenter.presentNotificationAsync(identifier, content); } //# sourceMappingURL=presentNotificationAsync.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/presentNotificationAsync.js.map b/packages/expo-notifications/build/presentNotificationAsync.js.map index ba12cd1cf58f5..d1ef9862d638b 100644 --- a/packages/expo-notifications/build/presentNotificationAsync.js.map +++ b/packages/expo-notifications/build/presentNotificationAsync.js.map @@ -1 +1 @@ -{"version":3,"file":"presentNotificationAsync.js","sourceRoot":"","sources":["../src/presentNotificationAsync.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAGlE,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,wBAAwB,CACpD,OAAiC,EACjC,aAAqB,MAAM,EAAE;IAE7B,IAAI,OAAO,IAAI,CAAC,mBAAmB,EAAE;QACnC,OAAO,CAAC,IAAI,CACV,qMAAqM,CACtM,CAAC;QACF,mBAAmB,GAAG,IAAI,CAAC;KAC5B;IACD,OAAO,MAAM,qBAAqB,CAAC,wBAAwB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import uuidv4 from 'uuid/v4';\n\nimport NotificationPresenter from './NotificationPresenterModule';\nimport { NotificationContentInput } from './Notifications.types';\n\nlet warningMessageShown = false;\n\nexport default async function presentNotificationAsync(\n content: NotificationContentInput,\n identifier: string = uuidv4()\n): Promise {\n if (__DEV__ && !warningMessageShown) {\n console.warn(\n '`presentNotificationAsync` has been deprecated in favor of using `scheduleNotificationAsync` + an explicit notification handler. Read more at https://expo.fyi/presenting-notifications-deprecated.'\n );\n warningMessageShown = true;\n }\n return await NotificationPresenter.presentNotificationAsync(identifier, content);\n}\n"]} \ No newline at end of file +{"version":3,"file":"presentNotificationAsync.js","sourceRoot":"","sources":["../src/presentNotificationAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,MAAM,MAAM,SAAS,CAAC;AAE7B,OAAO,qBAAqB,MAAM,+BAA+B,CAAC;AAGlE,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,wBAAwB,CACpD,OAAiC,EACjC,aAAqB,MAAM,EAAE;IAE7B,IAAI,OAAO,IAAI,CAAC,mBAAmB,EAAE;QACnC,OAAO,CAAC,IAAI,CACV,qMAAqM,CACtM,CAAC;QACF,mBAAmB,GAAG,IAAI,CAAC;KAC5B;IAED,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,EAAE;QACnD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAC;KAC5E;IAED,OAAO,MAAM,qBAAqB,CAAC,wBAAwB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\nimport uuidv4 from 'uuid/v4';\n\nimport NotificationPresenter from './NotificationPresenterModule';\nimport { NotificationContentInput } from './Notifications.types';\n\nlet warningMessageShown = false;\n\nexport default async function presentNotificationAsync(\n content: NotificationContentInput,\n identifier: string = uuidv4()\n): Promise {\n if (__DEV__ && !warningMessageShown) {\n console.warn(\n '`presentNotificationAsync` has been deprecated in favor of using `scheduleNotificationAsync` + an explicit notification handler. Read more at https://expo.fyi/presenting-notifications-deprecated.'\n );\n warningMessageShown = true;\n }\n\n if (!NotificationPresenter.presentNotificationAsync) {\n throw new UnavailabilityError('Notifications', 'presentNotificationAsync');\n }\n\n return await NotificationPresenter.presentNotificationAsync(identifier, content);\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/NotificationPresenterModule.ts b/packages/expo-notifications/src/NotificationPresenterModule.ts index fcf7d486569c0..41742a7df2d2b 100644 --- a/packages/expo-notifications/src/NotificationPresenterModule.ts +++ b/packages/expo-notifications/src/NotificationPresenterModule.ts @@ -1,15 +1,5 @@ -import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core'; +import { NativeModulesProxy } from '@unimodules/core'; -import { Notification, NotificationContentInput } from './Notifications.types'; - -export interface NotificationPresenterModule extends ProxyNativeModule { - getPresentedNotificationsAsync: () => Promise; - presentNotificationAsync: ( - identifier: string, - content: NotificationContentInput - ) => Promise; - dismissNotificationAsync: (identifier: string) => Promise; - dismissAllNotificationsAsync: () => Promise; -} +import { NotificationPresenterModule } from './NotificationPresenterModule.types'; export default (NativeModulesProxy.ExpoNotificationPresenter as any) as NotificationPresenterModule; diff --git a/packages/expo-notifications/src/NotificationPresenterModule.types.ts b/packages/expo-notifications/src/NotificationPresenterModule.types.ts new file mode 100644 index 0000000000000..139fa62daa344 --- /dev/null +++ b/packages/expo-notifications/src/NotificationPresenterModule.types.ts @@ -0,0 +1,13 @@ +import { ProxyNativeModule } from '@unimodules/core'; + +import { Notification, NotificationContentInput } from './Notifications.types'; + +export interface NotificationPresenterModule extends ProxyNativeModule { + getPresentedNotificationsAsync?: () => Promise; + presentNotificationAsync?: ( + identifier: string, + content: NotificationContentInput + ) => Promise; + dismissNotificationAsync?: (identifier: string) => Promise; + dismissAllNotificationsAsync?: () => Promise; +} diff --git a/packages/expo-notifications/src/NotificationPresenterModule.web.ts b/packages/expo-notifications/src/NotificationPresenterModule.web.ts new file mode 100644 index 0000000000000..26c1451640436 --- /dev/null +++ b/packages/expo-notifications/src/NotificationPresenterModule.web.ts @@ -0,0 +1,6 @@ +import { NotificationPresenterModule } from './NotificationPresenterModule.types'; + +export default { + addListener: () => {}, + removeListeners: () => {}, +} as NotificationPresenterModule; diff --git a/packages/expo-notifications/src/presentNotificationAsync.ts b/packages/expo-notifications/src/presentNotificationAsync.ts index 0645b9950f3ff..aa9f4eb316a07 100644 --- a/packages/expo-notifications/src/presentNotificationAsync.ts +++ b/packages/expo-notifications/src/presentNotificationAsync.ts @@ -1,3 +1,4 @@ +import { UnavailabilityError } from '@unimodules/core'; import uuidv4 from 'uuid/v4'; import NotificationPresenter from './NotificationPresenterModule'; @@ -15,5 +16,10 @@ export default async function presentNotificationAsync( ); warningMessageShown = true; } + + if (!NotificationPresenter.presentNotificationAsync) { + throw new UnavailabilityError('Notifications', 'presentNotificationAsync'); + } + return await NotificationPresenter.presentNotificationAsync(identifier, content); } From ab425d6eff15dd483f4e6cdbd369cdced8beac6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 17:48:21 +0200 Subject: [PATCH 08/17] [expo-notifications] Fix types and add web support for PushTokenManager --- .../build/PushTokenManager.d.ts | 5 +---- .../build/PushTokenManager.js.map | 2 +- .../build/PushTokenManager.types.d.ts | 4 ++++ .../build/PushTokenManager.types.js | 1 + .../build/PushTokenManager.types.js.map | 1 + .../build/PushTokenManager.web.d.ts | 3 ++- .../build/PushTokenManager.web.js | 12 ++++++++++-- .../build/PushTokenManager.web.js.map | 2 +- .../expo-notifications/src/PushTokenManager.ts | 6 ++---- .../src/PushTokenManager.types.ts | 5 +++++ .../src/PushTokenManager.web.ts | 17 +++++++++++++++-- 11 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 packages/expo-notifications/build/PushTokenManager.types.d.ts create mode 100644 packages/expo-notifications/build/PushTokenManager.types.js create mode 100644 packages/expo-notifications/build/PushTokenManager.types.js.map create mode 100644 packages/expo-notifications/src/PushTokenManager.types.ts diff --git a/packages/expo-notifications/build/PushTokenManager.d.ts b/packages/expo-notifications/build/PushTokenManager.d.ts index a3fa8fa236837..fdc527070a008 100644 --- a/packages/expo-notifications/build/PushTokenManager.d.ts +++ b/packages/expo-notifications/build/PushTokenManager.d.ts @@ -1,6 +1,3 @@ -import { ProxyNativeModule } from '@unimodules/core'; -export interface PushTokenManagerModule extends ProxyNativeModule { - getDevicePushTokenAsync: () => Promise; -} +import { PushTokenManagerModule } from './PushTokenManager.types'; declare const _default: PushTokenManagerModule; export default _default; diff --git a/packages/expo-notifications/build/PushTokenManager.js.map b/packages/expo-notifications/build/PushTokenManager.js.map index a6448c1db57c6..0be719d7b1b78 100644 --- a/packages/expo-notifications/build/PushTokenManager.js.map +++ b/packages/expo-notifications/build/PushTokenManager.js.map @@ -1 +1 @@ -{"version":3,"file":"PushTokenManager.js","sourceRoot":"","sources":["../src/PushTokenManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,kBAAkB,CAAC;AAMzE,eAAgB,kBAAkB,CAAC,oBAAsD,CAAC","sourcesContent":["import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core';\n\nexport interface PushTokenManagerModule extends ProxyNativeModule {\n getDevicePushTokenAsync: () => Promise;\n}\n\nexport default (NativeModulesProxy.ExpoPushTokenManager as any) as PushTokenManagerModule;\n"]} \ No newline at end of file +{"version":3,"file":"PushTokenManager.js","sourceRoot":"","sources":["../src/PushTokenManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,oBAAsD,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { PushTokenManagerModule } from './PushTokenManager.types';\n\nexport default (NativeModulesProxy.ExpoPushTokenManager as any) as PushTokenManagerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/PushTokenManager.types.d.ts b/packages/expo-notifications/build/PushTokenManager.types.d.ts new file mode 100644 index 0000000000000..556e067eeed5d --- /dev/null +++ b/packages/expo-notifications/build/PushTokenManager.types.d.ts @@ -0,0 +1,4 @@ +import { ProxyNativeModule } from '@unimodules/core'; +export interface PushTokenManagerModule extends ProxyNativeModule { + getDevicePushTokenAsync?: () => Promise; +} diff --git a/packages/expo-notifications/build/PushTokenManager.types.js b/packages/expo-notifications/build/PushTokenManager.types.js new file mode 100644 index 0000000000000..b4420a57257cb --- /dev/null +++ b/packages/expo-notifications/build/PushTokenManager.types.js @@ -0,0 +1 @@ +//# sourceMappingURL=PushTokenManager.types.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/PushTokenManager.types.js.map b/packages/expo-notifications/build/PushTokenManager.types.js.map new file mode 100644 index 0000000000000..919be8b140a64 --- /dev/null +++ b/packages/expo-notifications/build/PushTokenManager.types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PushTokenManager.types.js","sourceRoot":"","sources":["../src/PushTokenManager.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\n\nexport interface PushTokenManagerModule extends ProxyNativeModule {\n getDevicePushTokenAsync?: () => Promise;\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/PushTokenManager.web.d.ts b/packages/expo-notifications/build/PushTokenManager.web.d.ts index d87c48512f1ad..fdc527070a008 100644 --- a/packages/expo-notifications/build/PushTokenManager.web.d.ts +++ b/packages/expo-notifications/build/PushTokenManager.web.d.ts @@ -1,2 +1,3 @@ -declare const _default: {}; +import { PushTokenManagerModule } from './PushTokenManager.types'; +declare const _default: PushTokenManagerModule; export default _default; diff --git a/packages/expo-notifications/build/PushTokenManager.web.js b/packages/expo-notifications/build/PushTokenManager.web.js index 7f3bc873d8e03..5e49d8633da19 100644 --- a/packages/expo-notifications/build/PushTokenManager.web.js +++ b/packages/expo-notifications/build/PushTokenManager.web.js @@ -1,3 +1,11 @@ -// mock -export default {}; +let warningHasBeenShown = false; +export default { + addListener: () => { + if (!warningHasBeenShown) { + console.warn('[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.'); + warningHasBeenShown = true; + } + }, + removeListeners: () => { }, +}; //# sourceMappingURL=PushTokenManager.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/PushTokenManager.web.js.map b/packages/expo-notifications/build/PushTokenManager.web.js.map index 96255ad408f63..2fbe662b5e039 100644 --- a/packages/expo-notifications/build/PushTokenManager.web.js.map +++ b/packages/expo-notifications/build/PushTokenManager.web.js.map @@ -1 +1 @@ -{"version":3,"file":"PushTokenManager.web.js","sourceRoot":"","sources":["../src/PushTokenManager.web.ts"],"names":[],"mappings":"AAAA,OAAO;AACP,eAAe,EAAE,CAAC","sourcesContent":["// mock\nexport default {};\n"]} \ No newline at end of file +{"version":3,"file":"PushTokenManager.web.js","sourceRoot":"","sources":["../src/PushTokenManager.web.ts"],"names":[],"mappings":"AAEA,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,eAAe;IACb,WAAW,EAAE,GAAG,EAAE;QAChB,IAAI,CAAC,mBAAmB,EAAE;YACxB,OAAO,CAAC,IAAI,CACV,4HAA4H,CAC7H,CAAC;YACF,mBAAmB,GAAG,IAAI,CAAC;SAC5B;IACH,CAAC;IACD,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACA,CAAC","sourcesContent":["import { PushTokenManagerModule } from './PushTokenManager.types';\n\nlet warningHasBeenShown = false;\n\nexport default {\n addListener: () => {\n if (!warningHasBeenShown) {\n console.warn(\n '[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.'\n );\n warningHasBeenShown = true;\n }\n },\n removeListeners: () => {},\n} as PushTokenManagerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/PushTokenManager.ts b/packages/expo-notifications/src/PushTokenManager.ts index 4130bb9003796..1644dc1f9090e 100644 --- a/packages/expo-notifications/src/PushTokenManager.ts +++ b/packages/expo-notifications/src/PushTokenManager.ts @@ -1,7 +1,5 @@ -import { NativeModulesProxy, ProxyNativeModule } from '@unimodules/core'; +import { NativeModulesProxy } from '@unimodules/core'; -export interface PushTokenManagerModule extends ProxyNativeModule { - getDevicePushTokenAsync: () => Promise; -} +import { PushTokenManagerModule } from './PushTokenManager.types'; export default (NativeModulesProxy.ExpoPushTokenManager as any) as PushTokenManagerModule; diff --git a/packages/expo-notifications/src/PushTokenManager.types.ts b/packages/expo-notifications/src/PushTokenManager.types.ts new file mode 100644 index 0000000000000..298128888910e --- /dev/null +++ b/packages/expo-notifications/src/PushTokenManager.types.ts @@ -0,0 +1,5 @@ +import { ProxyNativeModule } from '@unimodules/core'; + +export interface PushTokenManagerModule extends ProxyNativeModule { + getDevicePushTokenAsync?: () => Promise; +} diff --git a/packages/expo-notifications/src/PushTokenManager.web.ts b/packages/expo-notifications/src/PushTokenManager.web.ts index 82f90c737146b..54214ff476b6e 100644 --- a/packages/expo-notifications/src/PushTokenManager.web.ts +++ b/packages/expo-notifications/src/PushTokenManager.web.ts @@ -1,2 +1,15 @@ -// mock -export default {}; +import { PushTokenManagerModule } from './PushTokenManager.types'; + +let warningHasBeenShown = false; + +export default { + addListener: () => { + if (!warningHasBeenShown) { + console.warn( + '[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.' + ); + warningHasBeenShown = true; + } + }, + removeListeners: () => {}, +} as PushTokenManagerModule; From 822e1abb85f127178052b855669f7da9b2289be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 17:50:31 +0200 Subject: [PATCH 09/17] [expo-notifications] Fix types and add web support for NotificaitonScheduler --- .../expo-notifications/build/NotificationScheduler.web.d.ts | 3 +++ .../expo-notifications/build/NotificationScheduler.web.js | 5 +++++ .../build/NotificationScheduler.web.js.map | 1 + .../expo-notifications/src/NotificationScheduler.web.ts | 6 ++++++ 4 files changed, 15 insertions(+) create mode 100644 packages/expo-notifications/build/NotificationScheduler.web.d.ts create mode 100644 packages/expo-notifications/build/NotificationScheduler.web.js create mode 100644 packages/expo-notifications/build/NotificationScheduler.web.js.map create mode 100644 packages/expo-notifications/src/NotificationScheduler.web.ts diff --git a/packages/expo-notifications/build/NotificationScheduler.web.d.ts b/packages/expo-notifications/build/NotificationScheduler.web.d.ts new file mode 100644 index 0000000000000..5d8ed08a573d0 --- /dev/null +++ b/packages/expo-notifications/build/NotificationScheduler.web.d.ts @@ -0,0 +1,3 @@ +import { NotificationSchedulerModule } from './NotificationScheduler.types'; +declare const _default: NotificationSchedulerModule; +export default _default; diff --git a/packages/expo-notifications/build/NotificationScheduler.web.js b/packages/expo-notifications/build/NotificationScheduler.web.js new file mode 100644 index 0000000000000..0013b5c06e3a6 --- /dev/null +++ b/packages/expo-notifications/build/NotificationScheduler.web.js @@ -0,0 +1,5 @@ +export default { + addListener: () => { }, + removeListeners: () => { }, +}; +//# sourceMappingURL=NotificationScheduler.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationScheduler.web.js.map b/packages/expo-notifications/build/NotificationScheduler.web.js.map new file mode 100644 index 0000000000000..533ef250d2d4e --- /dev/null +++ b/packages/expo-notifications/build/NotificationScheduler.web.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationScheduler.web.js","sourceRoot":"","sources":["../src/NotificationScheduler.web.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACK,CAAC","sourcesContent":["import { NotificationSchedulerModule } from './NotificationScheduler.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationSchedulerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/NotificationScheduler.web.ts b/packages/expo-notifications/src/NotificationScheduler.web.ts new file mode 100644 index 0000000000000..76abeb76a7a86 --- /dev/null +++ b/packages/expo-notifications/src/NotificationScheduler.web.ts @@ -0,0 +1,6 @@ +import { NotificationSchedulerModule } from './NotificationScheduler.types'; + +export default { + addListener: () => {}, + removeListeners: () => {}, +} as NotificationSchedulerModule; From a603e9aee24dc55d21a631da6976998cb2acc358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 17:51:27 +0200 Subject: [PATCH 10/17] [expo-notifications] Fix a copy-paste typo --- .../build/cancelAllScheduledNotificationsAsync.d.ts | 2 +- .../build/cancelAllScheduledNotificationsAsync.js | 2 +- .../build/cancelAllScheduledNotificationsAsync.js.map | 2 +- .../src/cancelAllScheduledNotificationsAsync.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.d.ts b/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.d.ts index 2121c9210c93f..f40313f9bd5fd 100644 --- a/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.d.ts +++ b/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.d.ts @@ -1 +1 @@ -export default function cancelScheduledNotificationAsync(): Promise; +export default function cancelAllScheduledNotificationsAsync(): Promise; diff --git a/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js b/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js index f2527940b66a6..225d3abacb4c0 100644 --- a/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js +++ b/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js @@ -1,6 +1,6 @@ import { UnavailabilityError } from '@unimodules/core'; import NotificationScheduler from './NotificationScheduler'; -export default async function cancelScheduledNotificationAsync() { +export default async function cancelAllScheduledNotificationsAsync() { if (!NotificationScheduler.cancelAllScheduledNotificationsAsync) { throw new UnavailabilityError('Notifications', 'cancelAllScheduledNotificationsAsync'); } diff --git a/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js.map b/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js.map index 41ddc6e2f188a..78f1ddcf37153 100644 --- a/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js.map +++ b/packages/expo-notifications/build/cancelAllScheduledNotificationsAsync.js.map @@ -1 +1 @@ -{"version":3,"file":"cancelAllScheduledNotificationsAsync.js","sourceRoot":"","sources":["../src/cancelAllScheduledNotificationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gCAAgC;IAC5D,IAAI,CAAC,qBAAqB,CAAC,oCAAoC,EAAE;QAC/D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,sCAAsC,CAAC,CAAC;KACxF;IAED,OAAO,MAAM,qBAAqB,CAAC,oCAAoC,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport NotificationScheduler from './NotificationScheduler';\n\nexport default async function cancelScheduledNotificationAsync(): Promise {\n if (!NotificationScheduler.cancelAllScheduledNotificationsAsync) {\n throw new UnavailabilityError('Notifications', 'cancelAllScheduledNotificationsAsync');\n }\n\n return await NotificationScheduler.cancelAllScheduledNotificationsAsync();\n}\n"]} \ No newline at end of file +{"version":3,"file":"cancelAllScheduledNotificationsAsync.js","sourceRoot":"","sources":["../src/cancelAllScheduledNotificationsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,oCAAoC;IAChE,IAAI,CAAC,qBAAqB,CAAC,oCAAoC,EAAE;QAC/D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,sCAAsC,CAAC,CAAC;KACxF;IAED,OAAO,MAAM,qBAAqB,CAAC,oCAAoC,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport NotificationScheduler from './NotificationScheduler';\n\nexport default async function cancelAllScheduledNotificationsAsync(): Promise {\n if (!NotificationScheduler.cancelAllScheduledNotificationsAsync) {\n throw new UnavailabilityError('Notifications', 'cancelAllScheduledNotificationsAsync');\n }\n\n return await NotificationScheduler.cancelAllScheduledNotificationsAsync();\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/cancelAllScheduledNotificationsAsync.ts b/packages/expo-notifications/src/cancelAllScheduledNotificationsAsync.ts index 221691756cbfd..9112e0eb0adef 100644 --- a/packages/expo-notifications/src/cancelAllScheduledNotificationsAsync.ts +++ b/packages/expo-notifications/src/cancelAllScheduledNotificationsAsync.ts @@ -2,7 +2,7 @@ import { UnavailabilityError } from '@unimodules/core'; import NotificationScheduler from './NotificationScheduler'; -export default async function cancelScheduledNotificationAsync(): Promise { +export default async function cancelAllScheduledNotificationsAsync(): Promise { if (!NotificationScheduler.cancelAllScheduledNotificationsAsync) { throw new UnavailabilityError('Notifications', 'cancelAllScheduledNotificationsAsync'); } From 75038016654412b76dc7a07c5914119f385e8dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 17:55:22 +0200 Subject: [PATCH 11/17] [changelog] Add changelog entry --- packages/expo-notifications/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/expo-notifications/CHANGELOG.md b/packages/expo-notifications/CHANGELOG.md index e38605b4024d9..fee888569cf5c 100644 --- a/packages/expo-notifications/CHANGELOG.md +++ b/packages/expo-notifications/CHANGELOG.md @@ -8,6 +8,8 @@ ### 🐛 Bug fixes +- Fixed total incompatibility with the web platform – calling unsupported methods will now throw a readable `UnavailabilityError`. ([#8853](https://github.com/expo/expo/pull/8853) by [@sjchmiela](https://github.com/sjchmiela)) + ## 0.3.2 — 2020-06-10 ### 🐛 Bug fixes From f277a24115e0e2d32f57400efbec9fdb350387e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Wed, 17 Jun 2020 22:55:15 +0200 Subject: [PATCH 12/17] [expo-notifications] Fix the warning message when adding a push token change listener on web --- packages/expo-notifications/build/PushTokenManager.web.js | 2 +- packages/expo-notifications/build/PushTokenManager.web.js.map | 2 +- packages/expo-notifications/src/PushTokenManager.web.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/expo-notifications/build/PushTokenManager.web.js b/packages/expo-notifications/build/PushTokenManager.web.js index 5e49d8633da19..3ff24a3014eea 100644 --- a/packages/expo-notifications/build/PushTokenManager.web.js +++ b/packages/expo-notifications/build/PushTokenManager.web.js @@ -2,7 +2,7 @@ let warningHasBeenShown = false; export default { addListener: () => { if (!warningHasBeenShown) { - console.warn('[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.'); + console.warn('[expo-notifications] Listening to push token changes is not yet fully supported on web. Adding a listener will have no effect.'); warningHasBeenShown = true; } }, diff --git a/packages/expo-notifications/build/PushTokenManager.web.js.map b/packages/expo-notifications/build/PushTokenManager.web.js.map index 2fbe662b5e039..81cffe2dc7f49 100644 --- a/packages/expo-notifications/build/PushTokenManager.web.js.map +++ b/packages/expo-notifications/build/PushTokenManager.web.js.map @@ -1 +1 @@ -{"version":3,"file":"PushTokenManager.web.js","sourceRoot":"","sources":["../src/PushTokenManager.web.ts"],"names":[],"mappings":"AAEA,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,eAAe;IACb,WAAW,EAAE,GAAG,EAAE;QAChB,IAAI,CAAC,mBAAmB,EAAE;YACxB,OAAO,CAAC,IAAI,CACV,4HAA4H,CAC7H,CAAC;YACF,mBAAmB,GAAG,IAAI,CAAC;SAC5B;IACH,CAAC;IACD,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACA,CAAC","sourcesContent":["import { PushTokenManagerModule } from './PushTokenManager.types';\n\nlet warningHasBeenShown = false;\n\nexport default {\n addListener: () => {\n if (!warningHasBeenShown) {\n console.warn(\n '[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.'\n );\n warningHasBeenShown = true;\n }\n },\n removeListeners: () => {},\n} as PushTokenManagerModule;\n"]} \ No newline at end of file +{"version":3,"file":"PushTokenManager.web.js","sourceRoot":"","sources":["../src/PushTokenManager.web.ts"],"names":[],"mappings":"AAEA,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,eAAe;IACb,WAAW,EAAE,GAAG,EAAE;QAChB,IAAI,CAAC,mBAAmB,EAAE;YACxB,OAAO,CAAC,IAAI,CACV,gIAAgI,CACjI,CAAC;YACF,mBAAmB,GAAG,IAAI,CAAC;SAC5B;IACH,CAAC;IACD,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACA,CAAC","sourcesContent":["import { PushTokenManagerModule } from './PushTokenManager.types';\n\nlet warningHasBeenShown = false;\n\nexport default {\n addListener: () => {\n if (!warningHasBeenShown) {\n console.warn(\n '[expo-notifications] Listening to push token changes is not yet fully supported on web. Adding a listener will have no effect.'\n );\n warningHasBeenShown = true;\n }\n },\n removeListeners: () => {},\n} as PushTokenManagerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/PushTokenManager.web.ts b/packages/expo-notifications/src/PushTokenManager.web.ts index 54214ff476b6e..824d016c3944a 100644 --- a/packages/expo-notifications/src/PushTokenManager.web.ts +++ b/packages/expo-notifications/src/PushTokenManager.web.ts @@ -6,7 +6,7 @@ export default { addListener: () => { if (!warningHasBeenShown) { console.warn( - '[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.' + '[expo-notifications] Listening to push token changes is not yet fully supported on web. Adding a listener will have no effect.' ); warningHasBeenShown = true; } From 3b305b5789365391c91ad84500b699ebb9979c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 18 Jun 2020 09:53:33 +0200 Subject: [PATCH 13/17] [expo-notifications] Swap web and native and provide empty fallback for other platforms --- packages/expo-notifications/build/BadgeModule.js | 10 ++-------- .../expo-notifications/build/BadgeModule.js.map | 2 +- .../build/BadgeModule.native.d.ts | 3 +++ .../expo-notifications/build/BadgeModule.native.js | 11 +++++++++++ .../build/BadgeModule.native.js.map | 1 + .../expo-notifications/build/BadgeModule.types.d.ts | 4 ++-- .../build/BadgeModule.types.js.map | 2 +- .../expo-notifications/src/BadgeModule.native.ts | 13 +++++++++++++ packages/expo-notifications/src/BadgeModule.ts | 11 ++--------- .../expo-notifications/src/BadgeModule.types.ts | 4 ++-- 10 files changed, 38 insertions(+), 23 deletions(-) create mode 100644 packages/expo-notifications/build/BadgeModule.native.d.ts create mode 100644 packages/expo-notifications/build/BadgeModule.native.js create mode 100644 packages/expo-notifications/build/BadgeModule.native.js.map create mode 100644 packages/expo-notifications/src/BadgeModule.native.ts diff --git a/packages/expo-notifications/build/BadgeModule.js b/packages/expo-notifications/build/BadgeModule.js index 9cd492f03832c..4abbdec1e0617 100644 --- a/packages/expo-notifications/build/BadgeModule.js +++ b/packages/expo-notifications/build/BadgeModule.js @@ -1,11 +1,5 @@ -import { NativeModulesProxy } from '@unimodules/core'; export default { - ...NativeModulesProxy.ExpoBadgeModule, - // We overwrite setBadgeCountAsync to omit - // an obsolete options argument when calling - // the native function. - setBadgeCountAsync: async (badgeCount, options) => { - return await NativeModulesProxy.ExpoBadgeModule.setBadgeCountAsync(badgeCount); - }, + addListener: () => { }, + removeListeners: () => { }, }; //# sourceMappingURL=BadgeModule.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/BadgeModule.js.map b/packages/expo-notifications/build/BadgeModule.js.map index 07c35decf005b..a91ded6e4aa50 100644 --- a/packages/expo-notifications/build/BadgeModule.js.map +++ b/packages/expo-notifications/build/BadgeModule.js.map @@ -1 +1 @@ -{"version":3,"file":"BadgeModule.js","sourceRoot":"","sources":["../src/BadgeModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAe;IACb,GAAG,kBAAkB,CAAC,eAAe;IACrC,0CAA0C;IAC1C,4CAA4C;IAC5C,uBAAuB;IACvB,kBAAkB,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;QAChD,OAAO,MAAM,kBAAkB,CAAC,eAAe,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACjF,CAAC;CACa,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { BadgeModule } from './BadgeModule.types';\n\nexport default {\n ...NativeModulesProxy.ExpoBadgeModule,\n // We overwrite setBadgeCountAsync to omit\n // an obsolete options argument when calling\n // the native function.\n setBadgeCountAsync: async (badgeCount, options) => {\n return await NativeModulesProxy.ExpoBadgeModule.setBadgeCountAsync(badgeCount);\n },\n} as BadgeModule;\n"]} \ No newline at end of file +{"version":3,"file":"BadgeModule.js","sourceRoot":"","sources":["../src/BadgeModule.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACX,CAAC","sourcesContent":["import { BadgeModule } from './BadgeModule.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as BadgeModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/BadgeModule.native.d.ts b/packages/expo-notifications/build/BadgeModule.native.d.ts new file mode 100644 index 0000000000000..73aa20f0621f1 --- /dev/null +++ b/packages/expo-notifications/build/BadgeModule.native.d.ts @@ -0,0 +1,3 @@ +import { BadgeModule } from './BadgeModule.types'; +declare const _default: BadgeModule; +export default _default; diff --git a/packages/expo-notifications/build/BadgeModule.native.js b/packages/expo-notifications/build/BadgeModule.native.js new file mode 100644 index 0000000000000..f3b65e75019d3 --- /dev/null +++ b/packages/expo-notifications/build/BadgeModule.native.js @@ -0,0 +1,11 @@ +import { NativeModulesProxy } from '@unimodules/core'; +export default { + ...NativeModulesProxy.ExpoBadgeModule, + // We overwrite setBadgeCountAsync to omit + // an obsolete options argument when calling + // the native function. + setBadgeCountAsync: async (badgeCount, options) => { + return await NativeModulesProxy.ExpoBadgeModule.setBadgeCountAsync(badgeCount); + }, +}; +//# sourceMappingURL=BadgeModule.native.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/BadgeModule.native.js.map b/packages/expo-notifications/build/BadgeModule.native.js.map new file mode 100644 index 0000000000000..15a1384ab4872 --- /dev/null +++ b/packages/expo-notifications/build/BadgeModule.native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"BadgeModule.native.js","sourceRoot":"","sources":["../src/BadgeModule.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAe;IACb,GAAG,kBAAkB,CAAC,eAAe;IACrC,0CAA0C;IAC1C,4CAA4C;IAC5C,uBAAuB;IACvB,kBAAkB,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;QAChD,OAAO,MAAM,kBAAkB,CAAC,eAAe,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACjF,CAAC;CACa,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { BadgeModule } from './BadgeModule.types';\n\nexport default {\n ...NativeModulesProxy.ExpoBadgeModule,\n // We overwrite setBadgeCountAsync to omit\n // an obsolete options argument when calling\n // the native function.\n setBadgeCountAsync: async (badgeCount, options) => {\n return await NativeModulesProxy.ExpoBadgeModule.setBadgeCountAsync(badgeCount);\n },\n} as BadgeModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/BadgeModule.types.d.ts b/packages/expo-notifications/build/BadgeModule.types.d.ts index b4bceee63ef69..8709523b66a19 100644 --- a/packages/expo-notifications/build/BadgeModule.types.d.ts +++ b/packages/expo-notifications/build/BadgeModule.types.d.ts @@ -3,7 +3,7 @@ import { Options as BadginOptions } from 'badgin'; export declare type WebSetBadgeCountOptions = BadginOptions; declare type SetBadgeCountOptions = WebSetBadgeCountOptions | undefined; export interface BadgeModule extends ProxyNativeModule { - getBadgeCountAsync: () => Promise; - setBadgeCountAsync: (badgeCount: number, options: SetBadgeCountOptions) => Promise; + getBadgeCountAsync?: () => Promise; + setBadgeCountAsync?: (badgeCount: number, options: SetBadgeCountOptions) => Promise; } export {}; diff --git a/packages/expo-notifications/build/BadgeModule.types.js.map b/packages/expo-notifications/build/BadgeModule.types.js.map index 76ceca0afc9dd..958caa3de22d1 100644 --- a/packages/expo-notifications/build/BadgeModule.types.js.map +++ b/packages/expo-notifications/build/BadgeModule.types.js.map @@ -1 +1 @@ -{"version":3,"file":"BadgeModule.types.js","sourceRoot":"","sources":["../src/BadgeModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\nimport { Options as BadginOptions } from 'badgin';\n\nexport type WebSetBadgeCountOptions = BadginOptions;\ntype SetBadgeCountOptions = WebSetBadgeCountOptions | undefined;\n\nexport interface BadgeModule extends ProxyNativeModule {\n getBadgeCountAsync: () => Promise;\n setBadgeCountAsync: (badgeCount: number, options: SetBadgeCountOptions) => Promise;\n}\n"]} \ No newline at end of file +{"version":3,"file":"BadgeModule.types.js","sourceRoot":"","sources":["../src/BadgeModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\nimport { Options as BadginOptions } from 'badgin';\n\nexport type WebSetBadgeCountOptions = BadginOptions;\ntype SetBadgeCountOptions = WebSetBadgeCountOptions | undefined;\n\nexport interface BadgeModule extends ProxyNativeModule {\n getBadgeCountAsync?: () => Promise;\n setBadgeCountAsync?: (badgeCount: number, options: SetBadgeCountOptions) => Promise;\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/BadgeModule.native.ts b/packages/expo-notifications/src/BadgeModule.native.ts new file mode 100644 index 0000000000000..14d6fba7fce42 --- /dev/null +++ b/packages/expo-notifications/src/BadgeModule.native.ts @@ -0,0 +1,13 @@ +import { NativeModulesProxy } from '@unimodules/core'; + +import { BadgeModule } from './BadgeModule.types'; + +export default { + ...NativeModulesProxy.ExpoBadgeModule, + // We overwrite setBadgeCountAsync to omit + // an obsolete options argument when calling + // the native function. + setBadgeCountAsync: async (badgeCount, options) => { + return await NativeModulesProxy.ExpoBadgeModule.setBadgeCountAsync(badgeCount); + }, +} as BadgeModule; diff --git a/packages/expo-notifications/src/BadgeModule.ts b/packages/expo-notifications/src/BadgeModule.ts index 14d6fba7fce42..63cc797fd9f61 100644 --- a/packages/expo-notifications/src/BadgeModule.ts +++ b/packages/expo-notifications/src/BadgeModule.ts @@ -1,13 +1,6 @@ -import { NativeModulesProxy } from '@unimodules/core'; - import { BadgeModule } from './BadgeModule.types'; export default { - ...NativeModulesProxy.ExpoBadgeModule, - // We overwrite setBadgeCountAsync to omit - // an obsolete options argument when calling - // the native function. - setBadgeCountAsync: async (badgeCount, options) => { - return await NativeModulesProxy.ExpoBadgeModule.setBadgeCountAsync(badgeCount); - }, + addListener: () => {}, + removeListeners: () => {}, } as BadgeModule; diff --git a/packages/expo-notifications/src/BadgeModule.types.ts b/packages/expo-notifications/src/BadgeModule.types.ts index 72a714f12e700..9d940c1a7f6d1 100644 --- a/packages/expo-notifications/src/BadgeModule.types.ts +++ b/packages/expo-notifications/src/BadgeModule.types.ts @@ -5,6 +5,6 @@ export type WebSetBadgeCountOptions = BadginOptions; type SetBadgeCountOptions = WebSetBadgeCountOptions | undefined; export interface BadgeModule extends ProxyNativeModule { - getBadgeCountAsync: () => Promise; - setBadgeCountAsync: (badgeCount: number, options: SetBadgeCountOptions) => Promise; + getBadgeCountAsync?: () => Promise; + setBadgeCountAsync?: (badgeCount: number, options: SetBadgeCountOptions) => Promise; } From 836a4913d4f9fb61ffd552186ae8e2c5bcd76bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 18 Jun 2020 10:02:28 +0200 Subject: [PATCH 14/17] [expo-notifications] Fix types and add non-supported fallback for getExpoPushToken and InstallationIdProvider --- .../expo-notifications/build/InstallationIdProvider.js | 6 ++++-- .../expo-notifications/build/InstallationIdProvider.js.map | 2 +- .../build/InstallationIdProvider.native.d.ts | 3 +++ .../build/InstallationIdProvider.native.js | 3 +++ .../build/InstallationIdProvider.native.js.map | 1 + .../build/InstallationIdProvider.types.d.ts | 2 +- .../build/InstallationIdProvider.types.js.map | 2 +- packages/expo-notifications/build/getExpoPushTokenAsync.js | 5 ++++- .../expo-notifications/build/getExpoPushTokenAsync.js.map | 2 +- .../src/InstallationIdProvider.native.ts | 5 +++++ packages/expo-notifications/src/InstallationIdProvider.ts | 7 ++++--- .../expo-notifications/src/InstallationIdProvider.types.ts | 2 +- packages/expo-notifications/src/getExpoPushTokenAsync.ts | 6 +++++- 13 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 packages/expo-notifications/build/InstallationIdProvider.native.d.ts create mode 100644 packages/expo-notifications/build/InstallationIdProvider.native.js create mode 100644 packages/expo-notifications/build/InstallationIdProvider.native.js.map create mode 100644 packages/expo-notifications/src/InstallationIdProvider.native.ts diff --git a/packages/expo-notifications/build/InstallationIdProvider.js b/packages/expo-notifications/build/InstallationIdProvider.js index 84e73533f73e6..b97500e26d0db 100644 --- a/packages/expo-notifications/build/InstallationIdProvider.js +++ b/packages/expo-notifications/build/InstallationIdProvider.js @@ -1,3 +1,5 @@ -import { NativeModulesProxy } from '@unimodules/core'; -export default NativeModulesProxy.NotificationsInstallationIdProvider; +export default { + addListener: () => { }, + removeListeners: () => { }, +}; //# sourceMappingURL=InstallationIdProvider.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/InstallationIdProvider.js.map b/packages/expo-notifications/build/InstallationIdProvider.js.map index 9733b4d1ff431..b3e391e4c7dd7 100644 --- a/packages/expo-notifications/build/InstallationIdProvider.js.map +++ b/packages/expo-notifications/build/InstallationIdProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"InstallationIdProvider.js","sourceRoot":"","sources":["../src/InstallationIdProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,mCAAqE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { InstallationIdProvider } from './InstallationIdProvider.types';\n\nexport default (NativeModulesProxy.NotificationsInstallationIdProvider as any) as InstallationIdProvider;\n"]} \ No newline at end of file +{"version":3,"file":"InstallationIdProvider.js","sourceRoot":"","sources":["../src/InstallationIdProvider.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACA,CAAC","sourcesContent":["import { InstallationIdProvider } from './InstallationIdProvider.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as InstallationIdProvider;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/InstallationIdProvider.native.d.ts b/packages/expo-notifications/build/InstallationIdProvider.native.d.ts new file mode 100644 index 0000000000000..7518d57bfb8e2 --- /dev/null +++ b/packages/expo-notifications/build/InstallationIdProvider.native.d.ts @@ -0,0 +1,3 @@ +import { InstallationIdProvider } from './InstallationIdProvider.types'; +declare const _default: InstallationIdProvider; +export default _default; diff --git a/packages/expo-notifications/build/InstallationIdProvider.native.js b/packages/expo-notifications/build/InstallationIdProvider.native.js new file mode 100644 index 0000000000000..32fac85d82d1c --- /dev/null +++ b/packages/expo-notifications/build/InstallationIdProvider.native.js @@ -0,0 +1,3 @@ +import { NativeModulesProxy } from '@unimodules/core'; +export default NativeModulesProxy.NotificationsInstallationIdProvider; +//# sourceMappingURL=InstallationIdProvider.native.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/InstallationIdProvider.native.js.map b/packages/expo-notifications/build/InstallationIdProvider.native.js.map new file mode 100644 index 0000000000000..771eac9068c93 --- /dev/null +++ b/packages/expo-notifications/build/InstallationIdProvider.native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"InstallationIdProvider.native.js","sourceRoot":"","sources":["../src/InstallationIdProvider.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,mCAAqE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { InstallationIdProvider } from './InstallationIdProvider.types';\n\nexport default (NativeModulesProxy.NotificationsInstallationIdProvider as any) as InstallationIdProvider;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/InstallationIdProvider.types.d.ts b/packages/expo-notifications/build/InstallationIdProvider.types.d.ts index e525c72839d99..36ffda4bf7539 100644 --- a/packages/expo-notifications/build/InstallationIdProvider.types.d.ts +++ b/packages/expo-notifications/build/InstallationIdProvider.types.d.ts @@ -1,4 +1,4 @@ import { ProxyNativeModule } from '@unimodules/core'; export interface InstallationIdProvider extends ProxyNativeModule { - getInstallationIdAsync: () => Promise; + getInstallationIdAsync?: () => Promise; } diff --git a/packages/expo-notifications/build/InstallationIdProvider.types.js.map b/packages/expo-notifications/build/InstallationIdProvider.types.js.map index 4118f5eba1bc1..d84f3a49efcc4 100644 --- a/packages/expo-notifications/build/InstallationIdProvider.types.js.map +++ b/packages/expo-notifications/build/InstallationIdProvider.types.js.map @@ -1 +1 @@ -{"version":3,"file":"InstallationIdProvider.types.js","sourceRoot":"","sources":["../src/InstallationIdProvider.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\n\nexport interface InstallationIdProvider extends ProxyNativeModule {\n getInstallationIdAsync: () => Promise;\n}\n"]} \ No newline at end of file +{"version":3,"file":"InstallationIdProvider.types.js","sourceRoot":"","sources":["../src/InstallationIdProvider.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\n\nexport interface InstallationIdProvider extends ProxyNativeModule {\n getInstallationIdAsync?: () => Promise;\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/getExpoPushTokenAsync.js b/packages/expo-notifications/build/getExpoPushTokenAsync.js index c236f1c8bcfc9..e741edfb0f65b 100644 --- a/packages/expo-notifications/build/getExpoPushTokenAsync.js +++ b/packages/expo-notifications/build/getExpoPushTokenAsync.js @@ -1,4 +1,4 @@ -import { Platform, CodedError } from '@unimodules/core'; +import { Platform, CodedError, UnavailabilityError } from '@unimodules/core'; import * as Application from 'expo-application'; import Constants from 'expo-constants'; import InstallationIdProvider from './InstallationIdProvider'; @@ -75,6 +75,9 @@ function getExpoPushToken(data) { } async function getDeviceIdAsync() { try { + if (!InstallationIdProvider.getInstallationIdAsync) { + throw new UnavailabilityError('InstallationIdProvider', 'getInstallationIdAsync'); + } return await InstallationIdProvider.getInstallationIdAsync(); } catch (e) { diff --git a/packages/expo-notifications/build/getExpoPushTokenAsync.js.map b/packages/expo-notifications/build/getExpoPushTokenAsync.js.map index 551610054e11a..2dc95044f838a 100644 --- a/packages/expo-notifications/build/getExpoPushTokenAsync.js.map +++ b/packages/expo-notifications/build/getExpoPushTokenAsync.js.map @@ -1 +1 @@ -{"version":3,"file":"getExpoPushTokenAsync.js","sourceRoot":"","sources":["../src/getExpoPushTokenAsync.ts"],"names":[],"mappings":"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","sourcesContent":["import { Platform, CodedError } from '@unimodules/core';\nimport * as Application from 'expo-application';\nimport Constants from 'expo-constants';\n\nimport InstallationIdProvider from './InstallationIdProvider';\nimport { DevicePushToken, ExpoPushToken } from './Tokens.types';\nimport getDevicePushTokenAsync from './getDevicePushTokenAsync';\n\nconst productionBaseUrl = 'https://exp.host/--/api/v2/';\n\ninterface Options {\n // Endpoint URL override\n baseUrl?: string;\n\n // Request URL override\n url?: string;\n\n // Request body overrides\n type?: string;\n deviceId?: string;\n development?: boolean;\n experienceId?: string;\n applicationId?: string;\n devicePushToken?: DevicePushToken;\n}\n\nexport default async function getExpoPushTokenAsync(options: Options = {}): Promise {\n const devicePushToken = options.devicePushToken || (await getDevicePushTokenAsync());\n\n const deviceId = options.deviceId || (await getDeviceIdAsync());\n\n const experienceId = options.experienceId || (Constants.manifest && Constants.manifest.id);\n\n if (!experienceId) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_NO_EXPERIENCE_ID',\n \"No experienceId found. If it can't be inferred from the manifest (eg. in bare workflow), you have to pass it in yourself.\"\n );\n }\n\n const applicationId = options.applicationId || Application.applicationId;\n if (!applicationId) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_NO_APPLICATION_ID',\n \"No applicationId found. If it can't be inferred from native configuration by expo-application, you have to pass it in yourself.\"\n );\n }\n const type = options.type || getTypeOfToken(devicePushToken);\n const development = options.development || (await shouldUseDevelopmentNotificationService());\n\n const url = options.url || `${options.baseUrl || productionBaseUrl}push/getExpoPushToken`;\n\n const body = {\n type,\n deviceId,\n development,\n experienceId,\n appId: applicationId,\n deviceToken: getDeviceToken(devicePushToken),\n };\n\n const response = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(body),\n }).catch(error => {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_NETWORK_ERROR',\n `Error encountered while fetching Expo token: ${error}.`\n );\n });\n\n if (!response.ok) {\n const statusInfo = response.statusText || response.status;\n let body: string | undefined = undefined;\n try {\n body = await response.text();\n } catch (error) {\n // do nothing\n }\n throw new CodedError(\n 'ERR_NOTIFICATIONS_SERVER_ERROR',\n `Error encountered while fetching Expo token, expected an OK response, received: ${statusInfo} (body: \"${body}\").`\n );\n }\n\n const expoPushToken = getExpoPushToken(await parseResponse(response));\n\n return {\n type: 'expo',\n data: expoPushToken,\n };\n}\n\nasync function parseResponse(response: Response) {\n try {\n return await response.json();\n } catch (error) {\n try {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_SERVER_ERROR',\n `Expected a JSON response from server when fetching Expo token, received body: ${JSON.stringify(\n await response.text()\n )}.`\n );\n } catch (innerError) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_SERVER_ERROR',\n `Expected a JSON response from server when fetching Expo token, received response: ${JSON.stringify(\n response\n )}.`\n );\n }\n }\n}\n\nfunction getExpoPushToken(data: any) {\n if (\n !data ||\n !(typeof data === 'object') ||\n !data.data ||\n !(typeof data.data === 'object') ||\n !data.data.expoPushToken ||\n !(typeof data.data.expoPushToken === 'string')\n ) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_SERVER_ERROR',\n `Malformed response from server, expected \"{ data: { expoPushToken: string } }\", received: ${JSON.stringify(\n data,\n null,\n 2\n )}.`\n );\n }\n\n return data.data.expoPushToken as string;\n}\n\nasync function getDeviceIdAsync() {\n try {\n return await InstallationIdProvider.getInstallationIdAsync();\n } catch (e) {\n throw new CodedError(\n 'ERR_NOTIF_DEVICE_ID',\n `Could not have fetched installation ID of the application: ${e}.`\n );\n }\n}\n\nfunction getDeviceToken(devicePushToken: DevicePushToken) {\n if (typeof devicePushToken.data === 'string') {\n return devicePushToken.data;\n }\n\n return JSON.stringify(devicePushToken.data);\n}\n\nasync function shouldUseDevelopmentNotificationService() {\n if (Platform.OS === 'ios') {\n try {\n const notificationServiceEnvironment = await Application.getIosPushNotificationServiceEnvironmentAsync();\n if (notificationServiceEnvironment === 'development') {\n return true;\n }\n } catch (e) {\n // We can't do anything here, we'll fallback to false then.\n }\n }\n\n return false;\n}\n\nfunction getTypeOfToken(devicePushToken: DevicePushToken) {\n switch (devicePushToken.type) {\n case 'ios':\n return 'apns';\n case 'android':\n return 'fcm';\n // This probably will error on server, but let's make this function future-safe.\n default:\n return devicePushToken.type;\n }\n}\n"]} \ No newline at end of file +{"version":3,"file":"getExpoPushTokenAsync.js","sourceRoot":"","sources":["../src/getExpoPushTokenAsync.ts"],"names":[],"mappings":"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","sourcesContent":["import { Platform, CodedError, UnavailabilityError } from '@unimodules/core';\nimport * as Application from 'expo-application';\nimport Constants from 'expo-constants';\n\nimport InstallationIdProvider from './InstallationIdProvider';\nimport { DevicePushToken, ExpoPushToken } from './Tokens.types';\nimport getDevicePushTokenAsync from './getDevicePushTokenAsync';\n\nconst productionBaseUrl = 'https://exp.host/--/api/v2/';\n\ninterface Options {\n // Endpoint URL override\n baseUrl?: string;\n\n // Request URL override\n url?: string;\n\n // Request body overrides\n type?: string;\n deviceId?: string;\n development?: boolean;\n experienceId?: string;\n applicationId?: string;\n devicePushToken?: DevicePushToken;\n}\n\nexport default async function getExpoPushTokenAsync(options: Options = {}): Promise {\n const devicePushToken = options.devicePushToken || (await getDevicePushTokenAsync());\n\n const deviceId = options.deviceId || (await getDeviceIdAsync());\n\n const experienceId = options.experienceId || (Constants.manifest && Constants.manifest.id);\n\n if (!experienceId) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_NO_EXPERIENCE_ID',\n \"No experienceId found. If it can't be inferred from the manifest (eg. in bare workflow), you have to pass it in yourself.\"\n );\n }\n\n const applicationId = options.applicationId || Application.applicationId;\n if (!applicationId) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_NO_APPLICATION_ID',\n \"No applicationId found. If it can't be inferred from native configuration by expo-application, you have to pass it in yourself.\"\n );\n }\n const type = options.type || getTypeOfToken(devicePushToken);\n const development = options.development || (await shouldUseDevelopmentNotificationService());\n\n const url = options.url || `${options.baseUrl || productionBaseUrl}push/getExpoPushToken`;\n\n const body = {\n type,\n deviceId,\n development,\n experienceId,\n appId: applicationId,\n deviceToken: getDeviceToken(devicePushToken),\n };\n\n const response = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(body),\n }).catch(error => {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_NETWORK_ERROR',\n `Error encountered while fetching Expo token: ${error}.`\n );\n });\n\n if (!response.ok) {\n const statusInfo = response.statusText || response.status;\n let body: string | undefined = undefined;\n try {\n body = await response.text();\n } catch (error) {\n // do nothing\n }\n throw new CodedError(\n 'ERR_NOTIFICATIONS_SERVER_ERROR',\n `Error encountered while fetching Expo token, expected an OK response, received: ${statusInfo} (body: \"${body}\").`\n );\n }\n\n const expoPushToken = getExpoPushToken(await parseResponse(response));\n\n return {\n type: 'expo',\n data: expoPushToken,\n };\n}\n\nasync function parseResponse(response: Response) {\n try {\n return await response.json();\n } catch (error) {\n try {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_SERVER_ERROR',\n `Expected a JSON response from server when fetching Expo token, received body: ${JSON.stringify(\n await response.text()\n )}.`\n );\n } catch (innerError) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_SERVER_ERROR',\n `Expected a JSON response from server when fetching Expo token, received response: ${JSON.stringify(\n response\n )}.`\n );\n }\n }\n}\n\nfunction getExpoPushToken(data: any) {\n if (\n !data ||\n !(typeof data === 'object') ||\n !data.data ||\n !(typeof data.data === 'object') ||\n !data.data.expoPushToken ||\n !(typeof data.data.expoPushToken === 'string')\n ) {\n throw new CodedError(\n 'ERR_NOTIFICATIONS_SERVER_ERROR',\n `Malformed response from server, expected \"{ data: { expoPushToken: string } }\", received: ${JSON.stringify(\n data,\n null,\n 2\n )}.`\n );\n }\n\n return data.data.expoPushToken as string;\n}\n\nasync function getDeviceIdAsync() {\n try {\n if (!InstallationIdProvider.getInstallationIdAsync) {\n throw new UnavailabilityError('InstallationIdProvider', 'getInstallationIdAsync');\n }\n\n return await InstallationIdProvider.getInstallationIdAsync();\n } catch (e) {\n throw new CodedError(\n 'ERR_NOTIF_DEVICE_ID',\n `Could not have fetched installation ID of the application: ${e}.`\n );\n }\n}\n\nfunction getDeviceToken(devicePushToken: DevicePushToken) {\n if (typeof devicePushToken.data === 'string') {\n return devicePushToken.data;\n }\n\n return JSON.stringify(devicePushToken.data);\n}\n\nasync function shouldUseDevelopmentNotificationService() {\n if (Platform.OS === 'ios') {\n try {\n const notificationServiceEnvironment = await Application.getIosPushNotificationServiceEnvironmentAsync();\n if (notificationServiceEnvironment === 'development') {\n return true;\n }\n } catch (e) {\n // We can't do anything here, we'll fallback to false then.\n }\n }\n\n return false;\n}\n\nfunction getTypeOfToken(devicePushToken: DevicePushToken) {\n switch (devicePushToken.type) {\n case 'ios':\n return 'apns';\n case 'android':\n return 'fcm';\n // This probably will error on server, but let's make this function future-safe.\n default:\n return devicePushToken.type;\n }\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/InstallationIdProvider.native.ts b/packages/expo-notifications/src/InstallationIdProvider.native.ts new file mode 100644 index 0000000000000..90f1a549260b5 --- /dev/null +++ b/packages/expo-notifications/src/InstallationIdProvider.native.ts @@ -0,0 +1,5 @@ +import { NativeModulesProxy } from '@unimodules/core'; + +import { InstallationIdProvider } from './InstallationIdProvider.types'; + +export default (NativeModulesProxy.NotificationsInstallationIdProvider as any) as InstallationIdProvider; diff --git a/packages/expo-notifications/src/InstallationIdProvider.ts b/packages/expo-notifications/src/InstallationIdProvider.ts index 90f1a549260b5..7142f95f8d814 100644 --- a/packages/expo-notifications/src/InstallationIdProvider.ts +++ b/packages/expo-notifications/src/InstallationIdProvider.ts @@ -1,5 +1,6 @@ -import { NativeModulesProxy } from '@unimodules/core'; - import { InstallationIdProvider } from './InstallationIdProvider.types'; -export default (NativeModulesProxy.NotificationsInstallationIdProvider as any) as InstallationIdProvider; +export default { + addListener: () => {}, + removeListeners: () => {}, +} as InstallationIdProvider; diff --git a/packages/expo-notifications/src/InstallationIdProvider.types.ts b/packages/expo-notifications/src/InstallationIdProvider.types.ts index 8aeb2efa3baa6..d553ffd2b5429 100644 --- a/packages/expo-notifications/src/InstallationIdProvider.types.ts +++ b/packages/expo-notifications/src/InstallationIdProvider.types.ts @@ -1,5 +1,5 @@ import { ProxyNativeModule } from '@unimodules/core'; export interface InstallationIdProvider extends ProxyNativeModule { - getInstallationIdAsync: () => Promise; + getInstallationIdAsync?: () => Promise; } diff --git a/packages/expo-notifications/src/getExpoPushTokenAsync.ts b/packages/expo-notifications/src/getExpoPushTokenAsync.ts index 12fed839aa1ea..b454889e2b732 100644 --- a/packages/expo-notifications/src/getExpoPushTokenAsync.ts +++ b/packages/expo-notifications/src/getExpoPushTokenAsync.ts @@ -1,4 +1,4 @@ -import { Platform, CodedError } from '@unimodules/core'; +import { Platform, CodedError, UnavailabilityError } from '@unimodules/core'; import * as Application from 'expo-application'; import Constants from 'expo-constants'; @@ -137,6 +137,10 @@ function getExpoPushToken(data: any) { async function getDeviceIdAsync() { try { + if (!InstallationIdProvider.getInstallationIdAsync) { + throw new UnavailabilityError('InstallationIdProvider', 'getInstallationIdAsync'); + } + return await InstallationIdProvider.getInstallationIdAsync(); } catch (e) { throw new CodedError( From b925db5f4c972107774fc333320a760471d8d14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 18 Jun 2020 10:03:47 +0200 Subject: [PATCH 15/17] [expo-notifications] Swap native and web for modules declarations --- .../build/NotificationChannelGroupManager.js | 6 ++++-- .../build/NotificationChannelGroupManager.js.map | 2 +- ... NotificationChannelGroupManager.native.d.ts} | 0 .../NotificationChannelGroupManager.native.js | 3 +++ ...NotificationChannelGroupManager.native.js.map | 1 + .../build/NotificationChannelGroupManager.web.js | 5 ----- .../NotificationChannelGroupManager.web.js.map | 1 - .../build/NotificationChannelManager.js | 6 ++++-- .../build/NotificationChannelManager.js.map | 2 +- ...ts => NotificationChannelManager.native.d.ts} | 0 .../build/NotificationChannelManager.native.js | 3 +++ .../NotificationChannelManager.native.js.map | 1 + .../build/NotificationChannelManager.web.js | 5 ----- .../build/NotificationChannelManager.web.js.map | 1 - .../build/NotificationPermissionsModule.js | 6 ++++-- .../build/NotificationPermissionsModule.js.map | 2 +- ...=> NotificationPermissionsModule.native.d.ts} | 0 .../NotificationPermissionsModule.native.js | 3 +++ .../NotificationPermissionsModule.native.js.map | 1 + .../build/NotificationPermissionsModule.web.js | 5 ----- .../NotificationPermissionsModule.web.js.map | 1 - .../build/NotificationPresenterModule.js | 6 ++++-- .../build/NotificationPresenterModule.js.map | 2 +- ...s => NotificationPresenterModule.native.d.ts} | 0 .../build/NotificationPresenterModule.native.js | 3 +++ .../NotificationPresenterModule.native.js.map | 1 + .../build/NotificationPresenterModule.web.js | 5 ----- .../build/NotificationPresenterModule.web.js.map | 1 - .../build/NotificationScheduler.js | 6 ++++-- .../build/NotificationScheduler.js.map | 2 +- ...eb.d.ts => NotificationScheduler.native.d.ts} | 0 .../build/NotificationScheduler.native.js | 3 +++ .../build/NotificationScheduler.native.js.map | 1 + .../build/NotificationScheduler.web.js | 5 ----- .../build/NotificationScheduler.web.js.map | 1 - .../build/NotificationsHandlerModule.js | 13 +++++++++++-- .../build/NotificationsHandlerModule.js.map | 2 +- ...ts => NotificationsHandlerModule.native.d.ts} | 0 .../build/NotificationsHandlerModule.native.js | 3 +++ .../NotificationsHandlerModule.native.js.map | 1 + .../build/NotificationsHandlerModule.web.js | 11 ----------- .../build/NotificationsHandlerModule.web.js.map | 1 - .../expo-notifications/build/PushTokenManager.js | 13 +++++++++++-- .../build/PushTokenManager.js.map | 2 +- ...ger.web.d.ts => PushTokenManager.native.d.ts} | 0 .../build/PushTokenManager.native.js | 3 +++ .../build/PushTokenManager.native.js.map | 1 + .../build/PushTokenManager.web.js | 11 ----------- .../build/PushTokenManager.web.js.map | 1 - .../NotificationChannelGroupManager.native.ts | 5 +++++ .../src/NotificationChannelGroupManager.ts | 7 ++++--- .../src/NotificationChannelGroupManager.web.ts | 6 ------ .../src/NotificationChannelManager.native.ts | 5 +++++ .../src/NotificationChannelManager.ts | 7 ++++--- .../src/NotificationChannelManager.web.ts | 6 ------ .../src/NotificationPermissionsModule.native.ts | 5 +++++ .../src/NotificationPermissionsModule.ts | 7 ++++--- .../src/NotificationPermissionsModule.web.ts | 6 ------ .../src/NotificationPresenterModule.native.ts | 5 +++++ .../src/NotificationPresenterModule.ts | 7 ++++--- .../src/NotificationPresenterModule.web.ts | 6 ------ .../src/NotificationScheduler.native.ts | 5 +++++ .../src/NotificationScheduler.ts | 7 ++++--- .../src/NotificationScheduler.web.ts | 6 ------ .../src/NotificationsHandlerModule.native.ts | 5 +++++ .../src/NotificationsHandlerModule.ts | 16 ++++++++++++++-- .../src/NotificationsHandlerModule.web.ts | 15 --------------- .../src/PushTokenManager.native.ts | 5 +++++ .../expo-notifications/src/PushTokenManager.ts | 16 ++++++++++++++-- .../src/PushTokenManager.web.ts | 15 --------------- 70 files changed, 160 insertions(+), 154 deletions(-) rename packages/expo-notifications/build/{NotificationChannelGroupManager.web.d.ts => NotificationChannelGroupManager.native.d.ts} (100%) create mode 100644 packages/expo-notifications/build/NotificationChannelGroupManager.native.js create mode 100644 packages/expo-notifications/build/NotificationChannelGroupManager.native.js.map delete mode 100644 packages/expo-notifications/build/NotificationChannelGroupManager.web.js delete mode 100644 packages/expo-notifications/build/NotificationChannelGroupManager.web.js.map rename packages/expo-notifications/build/{NotificationChannelManager.web.d.ts => NotificationChannelManager.native.d.ts} (100%) create mode 100644 packages/expo-notifications/build/NotificationChannelManager.native.js create mode 100644 packages/expo-notifications/build/NotificationChannelManager.native.js.map delete mode 100644 packages/expo-notifications/build/NotificationChannelManager.web.js delete mode 100644 packages/expo-notifications/build/NotificationChannelManager.web.js.map rename packages/expo-notifications/build/{NotificationPermissionsModule.web.d.ts => NotificationPermissionsModule.native.d.ts} (100%) create mode 100644 packages/expo-notifications/build/NotificationPermissionsModule.native.js create mode 100644 packages/expo-notifications/build/NotificationPermissionsModule.native.js.map delete mode 100644 packages/expo-notifications/build/NotificationPermissionsModule.web.js delete mode 100644 packages/expo-notifications/build/NotificationPermissionsModule.web.js.map rename packages/expo-notifications/build/{NotificationPresenterModule.web.d.ts => NotificationPresenterModule.native.d.ts} (100%) create mode 100644 packages/expo-notifications/build/NotificationPresenterModule.native.js create mode 100644 packages/expo-notifications/build/NotificationPresenterModule.native.js.map delete mode 100644 packages/expo-notifications/build/NotificationPresenterModule.web.js delete mode 100644 packages/expo-notifications/build/NotificationPresenterModule.web.js.map rename packages/expo-notifications/build/{NotificationScheduler.web.d.ts => NotificationScheduler.native.d.ts} (100%) create mode 100644 packages/expo-notifications/build/NotificationScheduler.native.js create mode 100644 packages/expo-notifications/build/NotificationScheduler.native.js.map delete mode 100644 packages/expo-notifications/build/NotificationScheduler.web.js delete mode 100644 packages/expo-notifications/build/NotificationScheduler.web.js.map rename packages/expo-notifications/build/{NotificationsHandlerModule.web.d.ts => NotificationsHandlerModule.native.d.ts} (100%) create mode 100644 packages/expo-notifications/build/NotificationsHandlerModule.native.js create mode 100644 packages/expo-notifications/build/NotificationsHandlerModule.native.js.map delete mode 100644 packages/expo-notifications/build/NotificationsHandlerModule.web.js delete mode 100644 packages/expo-notifications/build/NotificationsHandlerModule.web.js.map rename packages/expo-notifications/build/{PushTokenManager.web.d.ts => PushTokenManager.native.d.ts} (100%) create mode 100644 packages/expo-notifications/build/PushTokenManager.native.js create mode 100644 packages/expo-notifications/build/PushTokenManager.native.js.map delete mode 100644 packages/expo-notifications/build/PushTokenManager.web.js delete mode 100644 packages/expo-notifications/build/PushTokenManager.web.js.map create mode 100644 packages/expo-notifications/src/NotificationChannelGroupManager.native.ts delete mode 100644 packages/expo-notifications/src/NotificationChannelGroupManager.web.ts create mode 100644 packages/expo-notifications/src/NotificationChannelManager.native.ts delete mode 100644 packages/expo-notifications/src/NotificationChannelManager.web.ts create mode 100644 packages/expo-notifications/src/NotificationPermissionsModule.native.ts delete mode 100644 packages/expo-notifications/src/NotificationPermissionsModule.web.ts create mode 100644 packages/expo-notifications/src/NotificationPresenterModule.native.ts delete mode 100644 packages/expo-notifications/src/NotificationPresenterModule.web.ts create mode 100644 packages/expo-notifications/src/NotificationScheduler.native.ts delete mode 100644 packages/expo-notifications/src/NotificationScheduler.web.ts create mode 100644 packages/expo-notifications/src/NotificationsHandlerModule.native.ts delete mode 100644 packages/expo-notifications/src/NotificationsHandlerModule.web.ts create mode 100644 packages/expo-notifications/src/PushTokenManager.native.ts delete mode 100644 packages/expo-notifications/src/PushTokenManager.web.ts diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.js b/packages/expo-notifications/build/NotificationChannelGroupManager.js index 395506336eac3..a121a72376f41 100644 --- a/packages/expo-notifications/build/NotificationChannelGroupManager.js +++ b/packages/expo-notifications/build/NotificationChannelGroupManager.js @@ -1,3 +1,5 @@ -import { NativeModulesProxy } from '@unimodules/core'; -export default NativeModulesProxy.ExpoNotificationChannelGroupManager; +export default { + addListener: () => { }, + removeListeners: () => { }, +}; //# sourceMappingURL=NotificationChannelGroupManager.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.js.map b/packages/expo-notifications/build/NotificationChannelGroupManager.js.map index bf370fc9d4759..0ddd07f0b1ee4 100644 --- a/packages/expo-notifications/build/NotificationChannelGroupManager.js.map +++ b/packages/expo-notifications/build/NotificationChannelGroupManager.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationChannelGroupManager.js","sourceRoot":"","sources":["../src/NotificationChannelGroupManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,mCAA8E,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types';\n\nexport default (NativeModulesProxy.ExpoNotificationChannelGroupManager as any) as NotificationChannelGroupManager;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationChannelGroupManager.js","sourceRoot":"","sources":["../src/NotificationChannelGroupManager.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACS,CAAC","sourcesContent":["import { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationChannelGroupManager;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.web.d.ts b/packages/expo-notifications/build/NotificationChannelGroupManager.native.d.ts similarity index 100% rename from packages/expo-notifications/build/NotificationChannelGroupManager.web.d.ts rename to packages/expo-notifications/build/NotificationChannelGroupManager.native.d.ts diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.native.js b/packages/expo-notifications/build/NotificationChannelGroupManager.native.js new file mode 100644 index 0000000000000..0b10da09b2670 --- /dev/null +++ b/packages/expo-notifications/build/NotificationChannelGroupManager.native.js @@ -0,0 +1,3 @@ +import { NativeModulesProxy } from '@unimodules/core'; +export default NativeModulesProxy.ExpoNotificationChannelGroupManager; +//# sourceMappingURL=NotificationChannelGroupManager.native.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.native.js.map b/packages/expo-notifications/build/NotificationChannelGroupManager.native.js.map new file mode 100644 index 0000000000000..9f0a15e7d385b --- /dev/null +++ b/packages/expo-notifications/build/NotificationChannelGroupManager.native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationChannelGroupManager.native.js","sourceRoot":"","sources":["../src/NotificationChannelGroupManager.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,mCAA8E,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types';\n\nexport default (NativeModulesProxy.ExpoNotificationChannelGroupManager as any) as NotificationChannelGroupManager;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.web.js b/packages/expo-notifications/build/NotificationChannelGroupManager.web.js deleted file mode 100644 index 1e94cdf4d48ac..0000000000000 --- a/packages/expo-notifications/build/NotificationChannelGroupManager.web.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - addListener: () => { }, - removeListeners: () => { }, -}; -//# sourceMappingURL=NotificationChannelGroupManager.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelGroupManager.web.js.map b/packages/expo-notifications/build/NotificationChannelGroupManager.web.js.map deleted file mode 100644 index adc5d042b94c2..0000000000000 --- a/packages/expo-notifications/build/NotificationChannelGroupManager.web.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"NotificationChannelGroupManager.web.js","sourceRoot":"","sources":["../src/NotificationChannelGroupManager.web.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACS,CAAC","sourcesContent":["import { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationChannelGroupManager;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelManager.js b/packages/expo-notifications/build/NotificationChannelManager.js index a7fce201497a2..9189ba98b6125 100644 --- a/packages/expo-notifications/build/NotificationChannelManager.js +++ b/packages/expo-notifications/build/NotificationChannelManager.js @@ -1,3 +1,5 @@ -import { NativeModulesProxy } from '@unimodules/core'; -export default NativeModulesProxy.ExpoNotificationChannelManager; +export default { + addListener: () => { }, + removeListeners: () => { }, +}; //# sourceMappingURL=NotificationChannelManager.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelManager.js.map b/packages/expo-notifications/build/NotificationChannelManager.js.map index ba946f32797bd..8be5ed66e42f0 100644 --- a/packages/expo-notifications/build/NotificationChannelManager.js.map +++ b/packages/expo-notifications/build/NotificationChannelManager.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationChannelManager.js","sourceRoot":"","sources":["../src/NotificationChannelManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,8BAAoE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationChannelManager } from './NotificationChannelManager.types';\n\nexport default (NativeModulesProxy.ExpoNotificationChannelManager as any) as NotificationChannelManager;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationChannelManager.js","sourceRoot":"","sources":["../src/NotificationChannelManager.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACI,CAAC","sourcesContent":["import { NotificationChannelManager } from './NotificationChannelManager.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationChannelManager;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelManager.web.d.ts b/packages/expo-notifications/build/NotificationChannelManager.native.d.ts similarity index 100% rename from packages/expo-notifications/build/NotificationChannelManager.web.d.ts rename to packages/expo-notifications/build/NotificationChannelManager.native.d.ts diff --git a/packages/expo-notifications/build/NotificationChannelManager.native.js b/packages/expo-notifications/build/NotificationChannelManager.native.js new file mode 100644 index 0000000000000..fa1cc58538ea3 --- /dev/null +++ b/packages/expo-notifications/build/NotificationChannelManager.native.js @@ -0,0 +1,3 @@ +import { NativeModulesProxy } from '@unimodules/core'; +export default NativeModulesProxy.ExpoNotificationChannelManager; +//# sourceMappingURL=NotificationChannelManager.native.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelManager.native.js.map b/packages/expo-notifications/build/NotificationChannelManager.native.js.map new file mode 100644 index 0000000000000..b6ab42cc18fc8 --- /dev/null +++ b/packages/expo-notifications/build/NotificationChannelManager.native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationChannelManager.native.js","sourceRoot":"","sources":["../src/NotificationChannelManager.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,8BAAoE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationChannelManager } from './NotificationChannelManager.types';\n\nexport default (NativeModulesProxy.ExpoNotificationChannelManager as any) as NotificationChannelManager;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelManager.web.js b/packages/expo-notifications/build/NotificationChannelManager.web.js deleted file mode 100644 index b1676b47d7625..0000000000000 --- a/packages/expo-notifications/build/NotificationChannelManager.web.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - addListener: () => { }, - removeListeners: () => { }, -}; -//# sourceMappingURL=NotificationChannelManager.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationChannelManager.web.js.map b/packages/expo-notifications/build/NotificationChannelManager.web.js.map deleted file mode 100644 index b8fe94b4c41e8..0000000000000 --- a/packages/expo-notifications/build/NotificationChannelManager.web.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"NotificationChannelManager.web.js","sourceRoot":"","sources":["../src/NotificationChannelManager.web.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACI,CAAC","sourcesContent":["import { NotificationChannelManager } from './NotificationChannelManager.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationChannelManager;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.js b/packages/expo-notifications/build/NotificationPermissionsModule.js index 0396137af669e..df29d98b6cd45 100644 --- a/packages/expo-notifications/build/NotificationPermissionsModule.js +++ b/packages/expo-notifications/build/NotificationPermissionsModule.js @@ -1,3 +1,5 @@ -import { NativeModulesProxy } from '@unimodules/core'; -export default NativeModulesProxy.ExpoNotificationPermissionsModule; +export default { + addListener: () => { }, + removeListeners: () => { }, +}; //# sourceMappingURL=NotificationPermissionsModule.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.js.map b/packages/expo-notifications/build/NotificationPermissionsModule.js.map index 9ee38156e8466..aa261d2158989 100644 --- a/packages/expo-notifications/build/NotificationPermissionsModule.js.map +++ b/packages/expo-notifications/build/NotificationPermissionsModule.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationPermissionsModule.js","sourceRoot":"","sources":["../src/NotificationPermissionsModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,iCAA0E,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationPermissionsModule } from './NotificationPermissionsModule.types';\n\nexport default (NativeModulesProxy.ExpoNotificationPermissionsModule as any) as NotificationPermissionsModule;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationPermissionsModule.js","sourceRoot":"","sources":["../src/NotificationPermissionsModule.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACO,CAAC","sourcesContent":["import { NotificationPermissionsModule } from './NotificationPermissionsModule.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationPermissionsModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.web.d.ts b/packages/expo-notifications/build/NotificationPermissionsModule.native.d.ts similarity index 100% rename from packages/expo-notifications/build/NotificationPermissionsModule.web.d.ts rename to packages/expo-notifications/build/NotificationPermissionsModule.native.d.ts diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.native.js b/packages/expo-notifications/build/NotificationPermissionsModule.native.js new file mode 100644 index 0000000000000..5a0fe059e1073 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPermissionsModule.native.js @@ -0,0 +1,3 @@ +import { NativeModulesProxy } from '@unimodules/core'; +export default NativeModulesProxy.ExpoNotificationPermissionsModule; +//# sourceMappingURL=NotificationPermissionsModule.native.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.native.js.map b/packages/expo-notifications/build/NotificationPermissionsModule.native.js.map new file mode 100644 index 0000000000000..6c1910d10c2cd --- /dev/null +++ b/packages/expo-notifications/build/NotificationPermissionsModule.native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationPermissionsModule.native.js","sourceRoot":"","sources":["../src/NotificationPermissionsModule.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,iCAA0E,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationPermissionsModule } from './NotificationPermissionsModule.types';\n\nexport default (NativeModulesProxy.ExpoNotificationPermissionsModule as any) as NotificationPermissionsModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.web.js b/packages/expo-notifications/build/NotificationPermissionsModule.web.js deleted file mode 100644 index e9a00e15927c6..0000000000000 --- a/packages/expo-notifications/build/NotificationPermissionsModule.web.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - addListener: () => { }, - removeListeners: () => { }, -}; -//# sourceMappingURL=NotificationPermissionsModule.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPermissionsModule.web.js.map b/packages/expo-notifications/build/NotificationPermissionsModule.web.js.map deleted file mode 100644 index 295f6f4613a9f..0000000000000 --- a/packages/expo-notifications/build/NotificationPermissionsModule.web.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"NotificationPermissionsModule.web.js","sourceRoot":"","sources":["../src/NotificationPermissionsModule.web.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACO,CAAC","sourcesContent":["import { NotificationPermissionsModule } from './NotificationPermissionsModule.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationPermissionsModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenterModule.js b/packages/expo-notifications/build/NotificationPresenterModule.js index 85f838c53b6a9..9533576511b73 100644 --- a/packages/expo-notifications/build/NotificationPresenterModule.js +++ b/packages/expo-notifications/build/NotificationPresenterModule.js @@ -1,3 +1,5 @@ -import { NativeModulesProxy } from '@unimodules/core'; -export default NativeModulesProxy.ExpoNotificationPresenter; +export default { + addListener: () => { }, + removeListeners: () => { }, +}; //# sourceMappingURL=NotificationPresenterModule.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenterModule.js.map b/packages/expo-notifications/build/NotificationPresenterModule.js.map index 160367c036061..5ee3c8a1c57b1 100644 --- a/packages/expo-notifications/build/NotificationPresenterModule.js.map +++ b/packages/expo-notifications/build/NotificationPresenterModule.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationPresenterModule.js","sourceRoot":"","sources":["../src/NotificationPresenterModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,yBAAgE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationPresenterModule } from './NotificationPresenterModule.types';\n\nexport default (NativeModulesProxy.ExpoNotificationPresenter as any) as NotificationPresenterModule;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationPresenterModule.js","sourceRoot":"","sources":["../src/NotificationPresenterModule.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACK,CAAC","sourcesContent":["import { NotificationPresenterModule } from './NotificationPresenterModule.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationPresenterModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenterModule.web.d.ts b/packages/expo-notifications/build/NotificationPresenterModule.native.d.ts similarity index 100% rename from packages/expo-notifications/build/NotificationPresenterModule.web.d.ts rename to packages/expo-notifications/build/NotificationPresenterModule.native.d.ts diff --git a/packages/expo-notifications/build/NotificationPresenterModule.native.js b/packages/expo-notifications/build/NotificationPresenterModule.native.js new file mode 100644 index 0000000000000..c8f0bde0f21bd --- /dev/null +++ b/packages/expo-notifications/build/NotificationPresenterModule.native.js @@ -0,0 +1,3 @@ +import { NativeModulesProxy } from '@unimodules/core'; +export default NativeModulesProxy.ExpoNotificationPresenter; +//# sourceMappingURL=NotificationPresenterModule.native.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenterModule.native.js.map b/packages/expo-notifications/build/NotificationPresenterModule.native.js.map new file mode 100644 index 0000000000000..086aa691583a7 --- /dev/null +++ b/packages/expo-notifications/build/NotificationPresenterModule.native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationPresenterModule.native.js","sourceRoot":"","sources":["../src/NotificationPresenterModule.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,yBAAgE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationPresenterModule } from './NotificationPresenterModule.types';\n\nexport default (NativeModulesProxy.ExpoNotificationPresenter as any) as NotificationPresenterModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenterModule.web.js b/packages/expo-notifications/build/NotificationPresenterModule.web.js deleted file mode 100644 index f568187888519..0000000000000 --- a/packages/expo-notifications/build/NotificationPresenterModule.web.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - addListener: () => { }, - removeListeners: () => { }, -}; -//# sourceMappingURL=NotificationPresenterModule.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationPresenterModule.web.js.map b/packages/expo-notifications/build/NotificationPresenterModule.web.js.map deleted file mode 100644 index ab5327738b023..0000000000000 --- a/packages/expo-notifications/build/NotificationPresenterModule.web.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"NotificationPresenterModule.web.js","sourceRoot":"","sources":["../src/NotificationPresenterModule.web.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACK,CAAC","sourcesContent":["import { NotificationPresenterModule } from './NotificationPresenterModule.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationPresenterModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationScheduler.js b/packages/expo-notifications/build/NotificationScheduler.js index d805283612302..3bf9a9890b06e 100644 --- a/packages/expo-notifications/build/NotificationScheduler.js +++ b/packages/expo-notifications/build/NotificationScheduler.js @@ -1,3 +1,5 @@ -import { NativeModulesProxy } from '@unimodules/core'; -export default NativeModulesProxy.ExpoNotificationScheduler; +export default { + addListener: () => { }, + removeListeners: () => { }, +}; //# sourceMappingURL=NotificationScheduler.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationScheduler.js.map b/packages/expo-notifications/build/NotificationScheduler.js.map index 1355706d0577b..7317a0c22efb5 100644 --- a/packages/expo-notifications/build/NotificationScheduler.js.map +++ b/packages/expo-notifications/build/NotificationScheduler.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationScheduler.js","sourceRoot":"","sources":["../src/NotificationScheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,yBAAgE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationSchedulerModule } from './NotificationScheduler.types';\n\nexport default (NativeModulesProxy.ExpoNotificationScheduler as any) as NotificationSchedulerModule;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationScheduler.js","sourceRoot":"","sources":["../src/NotificationScheduler.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACK,CAAC","sourcesContent":["import { NotificationSchedulerModule } from './NotificationScheduler.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationSchedulerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationScheduler.web.d.ts b/packages/expo-notifications/build/NotificationScheduler.native.d.ts similarity index 100% rename from packages/expo-notifications/build/NotificationScheduler.web.d.ts rename to packages/expo-notifications/build/NotificationScheduler.native.d.ts diff --git a/packages/expo-notifications/build/NotificationScheduler.native.js b/packages/expo-notifications/build/NotificationScheduler.native.js new file mode 100644 index 0000000000000..6504e2b2bc772 --- /dev/null +++ b/packages/expo-notifications/build/NotificationScheduler.native.js @@ -0,0 +1,3 @@ +import { NativeModulesProxy } from '@unimodules/core'; +export default NativeModulesProxy.ExpoNotificationScheduler; +//# sourceMappingURL=NotificationScheduler.native.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationScheduler.native.js.map b/packages/expo-notifications/build/NotificationScheduler.native.js.map new file mode 100644 index 0000000000000..9c65171e82fd3 --- /dev/null +++ b/packages/expo-notifications/build/NotificationScheduler.native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationScheduler.native.js","sourceRoot":"","sources":["../src/NotificationScheduler.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,yBAAgE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationSchedulerModule } from './NotificationScheduler.types';\n\nexport default (NativeModulesProxy.ExpoNotificationScheduler as any) as NotificationSchedulerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationScheduler.web.js b/packages/expo-notifications/build/NotificationScheduler.web.js deleted file mode 100644 index 0013b5c06e3a6..0000000000000 --- a/packages/expo-notifications/build/NotificationScheduler.web.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - addListener: () => { }, - removeListeners: () => { }, -}; -//# sourceMappingURL=NotificationScheduler.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationScheduler.web.js.map b/packages/expo-notifications/build/NotificationScheduler.web.js.map deleted file mode 100644 index 533ef250d2d4e..0000000000000 --- a/packages/expo-notifications/build/NotificationScheduler.web.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"NotificationScheduler.web.js","sourceRoot":"","sources":["../src/NotificationScheduler.web.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,WAAW,EAAE,GAAG,EAAE,GAAE,CAAC;IACrB,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACK,CAAC","sourcesContent":["import { NotificationSchedulerModule } from './NotificationScheduler.types';\n\nexport default {\n addListener: () => {},\n removeListeners: () => {},\n} as NotificationSchedulerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.js b/packages/expo-notifications/build/NotificationsHandlerModule.js index c109faec4b025..defdd1bb3e8ad 100644 --- a/packages/expo-notifications/build/NotificationsHandlerModule.js +++ b/packages/expo-notifications/build/NotificationsHandlerModule.js @@ -1,3 +1,12 @@ -import { NativeModulesProxy } from '@unimodules/core'; -export default NativeModulesProxy.ExpoNotificationsHandlerModule; +import { Platform } from '@unimodules/core'; +let warningHasBeenShown = false; +export default { + addListener: () => { + if (!warningHasBeenShown) { + console.warn(`[expo-notifications] Notifications handling is not yet fully supported on ${Platform.OS}. Handling notifications will have no effect.`); + warningHasBeenShown = true; + } + }, + removeListeners: () => { }, +}; //# sourceMappingURL=NotificationsHandlerModule.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.js.map b/packages/expo-notifications/build/NotificationsHandlerModule.js.map index b53c0096317be..0d9688823e52c 100644 --- a/packages/expo-notifications/build/NotificationsHandlerModule.js.map +++ b/packages/expo-notifications/build/NotificationsHandlerModule.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationsHandlerModule.js","sourceRoot":"","sources":["../src/NotificationsHandlerModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,8BAAoE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationsHandlerModule } from './NotificationsHandlerModule.types';\n\nexport default (NativeModulesProxy.ExpoNotificationsHandlerModule as any) as NotificationsHandlerModule;\n"]} \ No newline at end of file +{"version":3,"file":"NotificationsHandlerModule.js","sourceRoot":"","sources":["../src/NotificationsHandlerModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,eAAe;IACb,WAAW,EAAE,GAAG,EAAE;QAChB,IAAI,CAAC,mBAAmB,EAAE;YACxB,OAAO,CAAC,IAAI,CACV,6EAA6E,QAAQ,CAAC,EAAE,+CAA+C,CACxI,CAAC;YACF,mBAAmB,GAAG,IAAI,CAAC;SAC5B;IACH,CAAC;IACD,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACI,CAAC","sourcesContent":["import { Platform } from '@unimodules/core';\n\nimport { NotificationsHandlerModule } from './NotificationsHandlerModule.types';\n\nlet warningHasBeenShown = false;\n\nexport default {\n addListener: () => {\n if (!warningHasBeenShown) {\n console.warn(\n `[expo-notifications] Notifications handling is not yet fully supported on ${Platform.OS}. Handling notifications will have no effect.`\n );\n warningHasBeenShown = true;\n }\n },\n removeListeners: () => {},\n} as NotificationsHandlerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.web.d.ts b/packages/expo-notifications/build/NotificationsHandlerModule.native.d.ts similarity index 100% rename from packages/expo-notifications/build/NotificationsHandlerModule.web.d.ts rename to packages/expo-notifications/build/NotificationsHandlerModule.native.d.ts diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.native.js b/packages/expo-notifications/build/NotificationsHandlerModule.native.js new file mode 100644 index 0000000000000..34ad18186f25a --- /dev/null +++ b/packages/expo-notifications/build/NotificationsHandlerModule.native.js @@ -0,0 +1,3 @@ +import { NativeModulesProxy } from '@unimodules/core'; +export default NativeModulesProxy.ExpoNotificationsHandlerModule; +//# sourceMappingURL=NotificationsHandlerModule.native.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.native.js.map b/packages/expo-notifications/build/NotificationsHandlerModule.native.js.map new file mode 100644 index 0000000000000..7f08f0c685472 --- /dev/null +++ b/packages/expo-notifications/build/NotificationsHandlerModule.native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationsHandlerModule.native.js","sourceRoot":"","sources":["../src/NotificationsHandlerModule.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,8BAAoE,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationsHandlerModule } from './NotificationsHandlerModule.types';\n\nexport default (NativeModulesProxy.ExpoNotificationsHandlerModule as any) as NotificationsHandlerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.web.js b/packages/expo-notifications/build/NotificationsHandlerModule.web.js deleted file mode 100644 index d44deff665905..0000000000000 --- a/packages/expo-notifications/build/NotificationsHandlerModule.web.js +++ /dev/null @@ -1,11 +0,0 @@ -let warningHasBeenShown = false; -export default { - addListener: () => { - if (!warningHasBeenShown) { - console.warn('[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.'); - warningHasBeenShown = true; - } - }, - removeListeners: () => { }, -}; -//# sourceMappingURL=NotificationsHandlerModule.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsHandlerModule.web.js.map b/packages/expo-notifications/build/NotificationsHandlerModule.web.js.map deleted file mode 100644 index b2d579b220993..0000000000000 --- a/packages/expo-notifications/build/NotificationsHandlerModule.web.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"NotificationsHandlerModule.web.js","sourceRoot":"","sources":["../src/NotificationsHandlerModule.web.ts"],"names":[],"mappings":"AAEA,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,eAAe;IACb,WAAW,EAAE,GAAG,EAAE;QAChB,IAAI,CAAC,mBAAmB,EAAE;YACxB,OAAO,CAAC,IAAI,CACV,4HAA4H,CAC7H,CAAC;YACF,mBAAmB,GAAG,IAAI,CAAC;SAC5B;IACH,CAAC;IACD,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACI,CAAC","sourcesContent":["import { NotificationsHandlerModule } from './NotificationsHandlerModule.types';\n\nlet warningHasBeenShown = false;\n\nexport default {\n addListener: () => {\n if (!warningHasBeenShown) {\n console.warn(\n '[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.'\n );\n warningHasBeenShown = true;\n }\n },\n removeListeners: () => {},\n} as NotificationsHandlerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/PushTokenManager.js b/packages/expo-notifications/build/PushTokenManager.js index 0a483ffd90809..390f88903138e 100644 --- a/packages/expo-notifications/build/PushTokenManager.js +++ b/packages/expo-notifications/build/PushTokenManager.js @@ -1,3 +1,12 @@ -import { NativeModulesProxy } from '@unimodules/core'; -export default NativeModulesProxy.ExpoPushTokenManager; +import { Platform } from '@unimodules/core'; +let warningHasBeenShown = false; +export default { + addListener: () => { + if (!warningHasBeenShown) { + console.warn(`[expo-notifications] Listening to push token changes is not yet fully supported on ${Platform.OS}. Adding a listener will have no effect.`); + warningHasBeenShown = true; + } + }, + removeListeners: () => { }, +}; //# sourceMappingURL=PushTokenManager.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/PushTokenManager.js.map b/packages/expo-notifications/build/PushTokenManager.js.map index 0be719d7b1b78..078adfebd9c88 100644 --- a/packages/expo-notifications/build/PushTokenManager.js.map +++ b/packages/expo-notifications/build/PushTokenManager.js.map @@ -1 +1 @@ -{"version":3,"file":"PushTokenManager.js","sourceRoot":"","sources":["../src/PushTokenManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,oBAAsD,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { PushTokenManagerModule } from './PushTokenManager.types';\n\nexport default (NativeModulesProxy.ExpoPushTokenManager as any) as PushTokenManagerModule;\n"]} \ No newline at end of file +{"version":3,"file":"PushTokenManager.js","sourceRoot":"","sources":["../src/PushTokenManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,eAAe;IACb,WAAW,EAAE,GAAG,EAAE;QAChB,IAAI,CAAC,mBAAmB,EAAE;YACxB,OAAO,CAAC,IAAI,CACV,sFAAsF,QAAQ,CAAC,EAAE,0CAA0C,CAC5I,CAAC;YACF,mBAAmB,GAAG,IAAI,CAAC;SAC5B;IACH,CAAC;IACD,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACA,CAAC","sourcesContent":["import { Platform } from '@unimodules/core';\n\nimport { PushTokenManagerModule } from './PushTokenManager.types';\n\nlet warningHasBeenShown = false;\n\nexport default {\n addListener: () => {\n if (!warningHasBeenShown) {\n console.warn(\n `[expo-notifications] Listening to push token changes is not yet fully supported on ${Platform.OS}. Adding a listener will have no effect.`\n );\n warningHasBeenShown = true;\n }\n },\n removeListeners: () => {},\n} as PushTokenManagerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/PushTokenManager.web.d.ts b/packages/expo-notifications/build/PushTokenManager.native.d.ts similarity index 100% rename from packages/expo-notifications/build/PushTokenManager.web.d.ts rename to packages/expo-notifications/build/PushTokenManager.native.d.ts diff --git a/packages/expo-notifications/build/PushTokenManager.native.js b/packages/expo-notifications/build/PushTokenManager.native.js new file mode 100644 index 0000000000000..6b7c2a84355fd --- /dev/null +++ b/packages/expo-notifications/build/PushTokenManager.native.js @@ -0,0 +1,3 @@ +import { NativeModulesProxy } from '@unimodules/core'; +export default NativeModulesProxy.ExpoPushTokenManager; +//# sourceMappingURL=PushTokenManager.native.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/PushTokenManager.native.js.map b/packages/expo-notifications/build/PushTokenManager.native.js.map new file mode 100644 index 0000000000000..0cb4b4bca470d --- /dev/null +++ b/packages/expo-notifications/build/PushTokenManager.native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PushTokenManager.native.js","sourceRoot":"","sources":["../src/PushTokenManager.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,oBAAsD,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { PushTokenManagerModule } from './PushTokenManager.types';\n\nexport default (NativeModulesProxy.ExpoPushTokenManager as any) as PushTokenManagerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/PushTokenManager.web.js b/packages/expo-notifications/build/PushTokenManager.web.js deleted file mode 100644 index 3ff24a3014eea..0000000000000 --- a/packages/expo-notifications/build/PushTokenManager.web.js +++ /dev/null @@ -1,11 +0,0 @@ -let warningHasBeenShown = false; -export default { - addListener: () => { - if (!warningHasBeenShown) { - console.warn('[expo-notifications] Listening to push token changes is not yet fully supported on web. Adding a listener will have no effect.'); - warningHasBeenShown = true; - } - }, - removeListeners: () => { }, -}; -//# sourceMappingURL=PushTokenManager.web.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/PushTokenManager.web.js.map b/packages/expo-notifications/build/PushTokenManager.web.js.map deleted file mode 100644 index 81cffe2dc7f49..0000000000000 --- a/packages/expo-notifications/build/PushTokenManager.web.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"PushTokenManager.web.js","sourceRoot":"","sources":["../src/PushTokenManager.web.ts"],"names":[],"mappings":"AAEA,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,eAAe;IACb,WAAW,EAAE,GAAG,EAAE;QAChB,IAAI,CAAC,mBAAmB,EAAE;YACxB,OAAO,CAAC,IAAI,CACV,gIAAgI,CACjI,CAAC;YACF,mBAAmB,GAAG,IAAI,CAAC;SAC5B;IACH,CAAC;IACD,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACA,CAAC","sourcesContent":["import { PushTokenManagerModule } from './PushTokenManager.types';\n\nlet warningHasBeenShown = false;\n\nexport default {\n addListener: () => {\n if (!warningHasBeenShown) {\n console.warn(\n '[expo-notifications] Listening to push token changes is not yet fully supported on web. Adding a listener will have no effect.'\n );\n warningHasBeenShown = true;\n }\n },\n removeListeners: () => {},\n} as PushTokenManagerModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/NotificationChannelGroupManager.native.ts b/packages/expo-notifications/src/NotificationChannelGroupManager.native.ts new file mode 100644 index 0000000000000..1eb22c9484868 --- /dev/null +++ b/packages/expo-notifications/src/NotificationChannelGroupManager.native.ts @@ -0,0 +1,5 @@ +import { NativeModulesProxy } from '@unimodules/core'; + +import { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types'; + +export default (NativeModulesProxy.ExpoNotificationChannelGroupManager as any) as NotificationChannelGroupManager; diff --git a/packages/expo-notifications/src/NotificationChannelGroupManager.ts b/packages/expo-notifications/src/NotificationChannelGroupManager.ts index 1eb22c9484868..edc8ad1300206 100644 --- a/packages/expo-notifications/src/NotificationChannelGroupManager.ts +++ b/packages/expo-notifications/src/NotificationChannelGroupManager.ts @@ -1,5 +1,6 @@ -import { NativeModulesProxy } from '@unimodules/core'; - import { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types'; -export default (NativeModulesProxy.ExpoNotificationChannelGroupManager as any) as NotificationChannelGroupManager; +export default { + addListener: () => {}, + removeListeners: () => {}, +} as NotificationChannelGroupManager; diff --git a/packages/expo-notifications/src/NotificationChannelGroupManager.web.ts b/packages/expo-notifications/src/NotificationChannelGroupManager.web.ts deleted file mode 100644 index edc8ad1300206..0000000000000 --- a/packages/expo-notifications/src/NotificationChannelGroupManager.web.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { NotificationChannelGroupManager } from './NotificationChannelGroupManager.types'; - -export default { - addListener: () => {}, - removeListeners: () => {}, -} as NotificationChannelGroupManager; diff --git a/packages/expo-notifications/src/NotificationChannelManager.native.ts b/packages/expo-notifications/src/NotificationChannelManager.native.ts new file mode 100644 index 0000000000000..6caa1dcdd09e4 --- /dev/null +++ b/packages/expo-notifications/src/NotificationChannelManager.native.ts @@ -0,0 +1,5 @@ +import { NativeModulesProxy } from '@unimodules/core'; + +import { NotificationChannelManager } from './NotificationChannelManager.types'; + +export default (NativeModulesProxy.ExpoNotificationChannelManager as any) as NotificationChannelManager; diff --git a/packages/expo-notifications/src/NotificationChannelManager.ts b/packages/expo-notifications/src/NotificationChannelManager.ts index 6caa1dcdd09e4..987deff10cd09 100644 --- a/packages/expo-notifications/src/NotificationChannelManager.ts +++ b/packages/expo-notifications/src/NotificationChannelManager.ts @@ -1,5 +1,6 @@ -import { NativeModulesProxy } from '@unimodules/core'; - import { NotificationChannelManager } from './NotificationChannelManager.types'; -export default (NativeModulesProxy.ExpoNotificationChannelManager as any) as NotificationChannelManager; +export default { + addListener: () => {}, + removeListeners: () => {}, +} as NotificationChannelManager; diff --git a/packages/expo-notifications/src/NotificationChannelManager.web.ts b/packages/expo-notifications/src/NotificationChannelManager.web.ts deleted file mode 100644 index 987deff10cd09..0000000000000 --- a/packages/expo-notifications/src/NotificationChannelManager.web.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { NotificationChannelManager } from './NotificationChannelManager.types'; - -export default { - addListener: () => {}, - removeListeners: () => {}, -} as NotificationChannelManager; diff --git a/packages/expo-notifications/src/NotificationPermissionsModule.native.ts b/packages/expo-notifications/src/NotificationPermissionsModule.native.ts new file mode 100644 index 0000000000000..ee56d2cf3fbb0 --- /dev/null +++ b/packages/expo-notifications/src/NotificationPermissionsModule.native.ts @@ -0,0 +1,5 @@ +import { NativeModulesProxy } from '@unimodules/core'; + +import { NotificationPermissionsModule } from './NotificationPermissionsModule.types'; + +export default (NativeModulesProxy.ExpoNotificationPermissionsModule as any) as NotificationPermissionsModule; diff --git a/packages/expo-notifications/src/NotificationPermissionsModule.ts b/packages/expo-notifications/src/NotificationPermissionsModule.ts index ee56d2cf3fbb0..6ce6c5f758b98 100644 --- a/packages/expo-notifications/src/NotificationPermissionsModule.ts +++ b/packages/expo-notifications/src/NotificationPermissionsModule.ts @@ -1,5 +1,6 @@ -import { NativeModulesProxy } from '@unimodules/core'; - import { NotificationPermissionsModule } from './NotificationPermissionsModule.types'; -export default (NativeModulesProxy.ExpoNotificationPermissionsModule as any) as NotificationPermissionsModule; +export default { + addListener: () => {}, + removeListeners: () => {}, +} as NotificationPermissionsModule; diff --git a/packages/expo-notifications/src/NotificationPermissionsModule.web.ts b/packages/expo-notifications/src/NotificationPermissionsModule.web.ts deleted file mode 100644 index 6ce6c5f758b98..0000000000000 --- a/packages/expo-notifications/src/NotificationPermissionsModule.web.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { NotificationPermissionsModule } from './NotificationPermissionsModule.types'; - -export default { - addListener: () => {}, - removeListeners: () => {}, -} as NotificationPermissionsModule; diff --git a/packages/expo-notifications/src/NotificationPresenterModule.native.ts b/packages/expo-notifications/src/NotificationPresenterModule.native.ts new file mode 100644 index 0000000000000..41742a7df2d2b --- /dev/null +++ b/packages/expo-notifications/src/NotificationPresenterModule.native.ts @@ -0,0 +1,5 @@ +import { NativeModulesProxy } from '@unimodules/core'; + +import { NotificationPresenterModule } from './NotificationPresenterModule.types'; + +export default (NativeModulesProxy.ExpoNotificationPresenter as any) as NotificationPresenterModule; diff --git a/packages/expo-notifications/src/NotificationPresenterModule.ts b/packages/expo-notifications/src/NotificationPresenterModule.ts index 41742a7df2d2b..26c1451640436 100644 --- a/packages/expo-notifications/src/NotificationPresenterModule.ts +++ b/packages/expo-notifications/src/NotificationPresenterModule.ts @@ -1,5 +1,6 @@ -import { NativeModulesProxy } from '@unimodules/core'; - import { NotificationPresenterModule } from './NotificationPresenterModule.types'; -export default (NativeModulesProxy.ExpoNotificationPresenter as any) as NotificationPresenterModule; +export default { + addListener: () => {}, + removeListeners: () => {}, +} as NotificationPresenterModule; diff --git a/packages/expo-notifications/src/NotificationPresenterModule.web.ts b/packages/expo-notifications/src/NotificationPresenterModule.web.ts deleted file mode 100644 index 26c1451640436..0000000000000 --- a/packages/expo-notifications/src/NotificationPresenterModule.web.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { NotificationPresenterModule } from './NotificationPresenterModule.types'; - -export default { - addListener: () => {}, - removeListeners: () => {}, -} as NotificationPresenterModule; diff --git a/packages/expo-notifications/src/NotificationScheduler.native.ts b/packages/expo-notifications/src/NotificationScheduler.native.ts new file mode 100644 index 0000000000000..bf9f2833d587c --- /dev/null +++ b/packages/expo-notifications/src/NotificationScheduler.native.ts @@ -0,0 +1,5 @@ +import { NativeModulesProxy } from '@unimodules/core'; + +import { NotificationSchedulerModule } from './NotificationScheduler.types'; + +export default (NativeModulesProxy.ExpoNotificationScheduler as any) as NotificationSchedulerModule; diff --git a/packages/expo-notifications/src/NotificationScheduler.ts b/packages/expo-notifications/src/NotificationScheduler.ts index bf9f2833d587c..76abeb76a7a86 100644 --- a/packages/expo-notifications/src/NotificationScheduler.ts +++ b/packages/expo-notifications/src/NotificationScheduler.ts @@ -1,5 +1,6 @@ -import { NativeModulesProxy } from '@unimodules/core'; - import { NotificationSchedulerModule } from './NotificationScheduler.types'; -export default (NativeModulesProxy.ExpoNotificationScheduler as any) as NotificationSchedulerModule; +export default { + addListener: () => {}, + removeListeners: () => {}, +} as NotificationSchedulerModule; diff --git a/packages/expo-notifications/src/NotificationScheduler.web.ts b/packages/expo-notifications/src/NotificationScheduler.web.ts deleted file mode 100644 index 76abeb76a7a86..0000000000000 --- a/packages/expo-notifications/src/NotificationScheduler.web.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { NotificationSchedulerModule } from './NotificationScheduler.types'; - -export default { - addListener: () => {}, - removeListeners: () => {}, -} as NotificationSchedulerModule; diff --git a/packages/expo-notifications/src/NotificationsHandlerModule.native.ts b/packages/expo-notifications/src/NotificationsHandlerModule.native.ts new file mode 100644 index 0000000000000..a30f587e6c75b --- /dev/null +++ b/packages/expo-notifications/src/NotificationsHandlerModule.native.ts @@ -0,0 +1,5 @@ +import { NativeModulesProxy } from '@unimodules/core'; + +import { NotificationsHandlerModule } from './NotificationsHandlerModule.types'; + +export default (NativeModulesProxy.ExpoNotificationsHandlerModule as any) as NotificationsHandlerModule; diff --git a/packages/expo-notifications/src/NotificationsHandlerModule.ts b/packages/expo-notifications/src/NotificationsHandlerModule.ts index a30f587e6c75b..1c6d8e50b7ac1 100644 --- a/packages/expo-notifications/src/NotificationsHandlerModule.ts +++ b/packages/expo-notifications/src/NotificationsHandlerModule.ts @@ -1,5 +1,17 @@ -import { NativeModulesProxy } from '@unimodules/core'; +import { Platform } from '@unimodules/core'; import { NotificationsHandlerModule } from './NotificationsHandlerModule.types'; -export default (NativeModulesProxy.ExpoNotificationsHandlerModule as any) as NotificationsHandlerModule; +let warningHasBeenShown = false; + +export default { + addListener: () => { + if (!warningHasBeenShown) { + console.warn( + `[expo-notifications] Notifications handling is not yet fully supported on ${Platform.OS}. Handling notifications will have no effect.` + ); + warningHasBeenShown = true; + } + }, + removeListeners: () => {}, +} as NotificationsHandlerModule; diff --git a/packages/expo-notifications/src/NotificationsHandlerModule.web.ts b/packages/expo-notifications/src/NotificationsHandlerModule.web.ts deleted file mode 100644 index 4b4392f460683..0000000000000 --- a/packages/expo-notifications/src/NotificationsHandlerModule.web.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { NotificationsHandlerModule } from './NotificationsHandlerModule.types'; - -let warningHasBeenShown = false; - -export default { - addListener: () => { - if (!warningHasBeenShown) { - console.warn( - '[expo-notifications] Notifications handling is not yet fully supported on web. Handling notifications will have no effect.' - ); - warningHasBeenShown = true; - } - }, - removeListeners: () => {}, -} as NotificationsHandlerModule; diff --git a/packages/expo-notifications/src/PushTokenManager.native.ts b/packages/expo-notifications/src/PushTokenManager.native.ts new file mode 100644 index 0000000000000..1644dc1f9090e --- /dev/null +++ b/packages/expo-notifications/src/PushTokenManager.native.ts @@ -0,0 +1,5 @@ +import { NativeModulesProxy } from '@unimodules/core'; + +import { PushTokenManagerModule } from './PushTokenManager.types'; + +export default (NativeModulesProxy.ExpoPushTokenManager as any) as PushTokenManagerModule; diff --git a/packages/expo-notifications/src/PushTokenManager.ts b/packages/expo-notifications/src/PushTokenManager.ts index 1644dc1f9090e..2ffb9cac33ea6 100644 --- a/packages/expo-notifications/src/PushTokenManager.ts +++ b/packages/expo-notifications/src/PushTokenManager.ts @@ -1,5 +1,17 @@ -import { NativeModulesProxy } from '@unimodules/core'; +import { Platform } from '@unimodules/core'; import { PushTokenManagerModule } from './PushTokenManager.types'; -export default (NativeModulesProxy.ExpoPushTokenManager as any) as PushTokenManagerModule; +let warningHasBeenShown = false; + +export default { + addListener: () => { + if (!warningHasBeenShown) { + console.warn( + `[expo-notifications] Listening to push token changes is not yet fully supported on ${Platform.OS}. Adding a listener will have no effect.` + ); + warningHasBeenShown = true; + } + }, + removeListeners: () => {}, +} as PushTokenManagerModule; diff --git a/packages/expo-notifications/src/PushTokenManager.web.ts b/packages/expo-notifications/src/PushTokenManager.web.ts deleted file mode 100644 index 824d016c3944a..0000000000000 --- a/packages/expo-notifications/src/PushTokenManager.web.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { PushTokenManagerModule } from './PushTokenManager.types'; - -let warningHasBeenShown = false; - -export default { - addListener: () => { - if (!warningHasBeenShown) { - console.warn( - '[expo-notifications] Listening to push token changes is not yet fully supported on web. Adding a listener will have no effect.' - ); - warningHasBeenShown = true; - } - }, - removeListeners: () => {}, -} as PushTokenManagerModule; From 8d06db1b54186b57dc8fafede05584610fc23658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 18 Jun 2020 10:08:19 +0200 Subject: [PATCH 16/17] [expo-notifications] Fix types and add web support for NotificationsEmitter --- .../build/NotificationsEmitter.js | 5 +++-- .../build/NotificationsEmitter.js.map | 2 +- .../build/NotificationsEmitterModule.d.ts | 3 +++ .../build/NotificationsEmitterModule.js | 12 ++++++++++++ .../build/NotificationsEmitterModule.js.map | 1 + .../NotificationsEmitterModule.native.d.ts | 3 +++ .../build/NotificationsEmitterModule.native.js | 3 +++ .../NotificationsEmitterModule.native.js.map | 1 + .../build/NotificationsEmitterModule.types.d.ts | 3 +++ .../build/NotificationsEmitterModule.types.js | 1 + .../NotificationsEmitterModule.types.js.map | 1 + .../src/NotificationsEmitter.ts | 5 +++-- .../src/NotificationsEmitterModule.native.ts | 5 +++++ .../src/NotificationsEmitterModule.ts | 17 +++++++++++++++++ .../src/NotificationsEmitterModule.types.ts | 3 +++ 15 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 packages/expo-notifications/build/NotificationsEmitterModule.d.ts create mode 100644 packages/expo-notifications/build/NotificationsEmitterModule.js create mode 100644 packages/expo-notifications/build/NotificationsEmitterModule.js.map create mode 100644 packages/expo-notifications/build/NotificationsEmitterModule.native.d.ts create mode 100644 packages/expo-notifications/build/NotificationsEmitterModule.native.js create mode 100644 packages/expo-notifications/build/NotificationsEmitterModule.native.js.map create mode 100644 packages/expo-notifications/build/NotificationsEmitterModule.types.d.ts create mode 100644 packages/expo-notifications/build/NotificationsEmitterModule.types.js create mode 100644 packages/expo-notifications/build/NotificationsEmitterModule.types.js.map create mode 100644 packages/expo-notifications/src/NotificationsEmitterModule.native.ts create mode 100644 packages/expo-notifications/src/NotificationsEmitterModule.ts create mode 100644 packages/expo-notifications/src/NotificationsEmitterModule.types.ts diff --git a/packages/expo-notifications/build/NotificationsEmitter.js b/packages/expo-notifications/build/NotificationsEmitter.js index e6d0235dfbce3..8bab991d61149 100644 --- a/packages/expo-notifications/build/NotificationsEmitter.js +++ b/packages/expo-notifications/build/NotificationsEmitter.js @@ -1,6 +1,7 @@ -import { EventEmitter, NativeModulesProxy } from '@unimodules/core'; +import { EventEmitter } from '@unimodules/core'; +import NotificationsEmitterModule from './NotificationsEmitterModule'; // Web uses SyntheticEventEmitter -const emitter = new EventEmitter(NativeModulesProxy.ExpoNotificationsEmitter); +const emitter = new EventEmitter(NotificationsEmitterModule); const didReceiveNotificationEventName = 'onDidReceiveNotification'; const didDropNotificationsEventName = 'onNotificationsDeleted'; const didReceiveNotificationResponseEventName = 'onDidReceiveNotificationResponse'; diff --git a/packages/expo-notifications/build/NotificationsEmitter.js.map b/packages/expo-notifications/build/NotificationsEmitter.js.map index de940e3707344..0139c8ba2fffe 100644 --- a/packages/expo-notifications/build/NotificationsEmitter.js.map +++ b/packages/expo-notifications/build/NotificationsEmitter.js.map @@ -1 +1 @@ -{"version":3,"file":"NotificationsEmitter.js","sourceRoot":"","sources":["../src/NotificationsEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAIlF,iCAAiC;AACjC,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,CAAC;AAE9E,MAAM,+BAA+B,GAAG,0BAA0B,CAAC;AACnE,MAAM,6BAA6B,GAAG,wBAAwB,CAAC;AAC/D,MAAM,uCAAuC,GAAG,kCAAkC,CAAC;AAEnF,MAAM,CAAC,MAAM,yBAAyB,GAAG,4CAA4C,CAAC;AAEtF,MAAM,UAAU,+BAA+B,CAC7C,QAAuC;IAEvC,OAAO,OAAO,CAAC,WAAW,CAAe,+BAA+B,EAAE,QAAQ,CAAC,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,QAAoB;IAClE,OAAO,OAAO,CAAC,WAAW,CAAO,6BAA6B,EAAE,QAAQ,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,uCAAuC,CACrD,QAA+C;IAE/C,OAAO,OAAO,CAAC,WAAW,CACxB,uCAAuC,EACvC,QAAQ,CACT,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,YAA0B;IACvE,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,OAAO,CAAC,kBAAkB,CAAC,+BAA+B,CAAC,CAAC;IAC5D,OAAO,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,CAAC;IAC1D,OAAO,CAAC,kBAAkB,CAAC,uCAAuC,CAAC,CAAC;AACtE,CAAC","sourcesContent":["import { EventEmitter, Subscription, NativeModulesProxy } from '@unimodules/core';\n\nimport { Notification, NotificationResponse } from './Notifications.types';\n\n// Web uses SyntheticEventEmitter\nconst emitter = new EventEmitter(NativeModulesProxy.ExpoNotificationsEmitter);\n\nconst didReceiveNotificationEventName = 'onDidReceiveNotification';\nconst didDropNotificationsEventName = 'onNotificationsDeleted';\nconst didReceiveNotificationResponseEventName = 'onDidReceiveNotificationResponse';\n\nexport const DEFAULT_ACTION_IDENTIFIER = 'expo.modules.notifications.actions.DEFAULT';\n\nexport function addNotificationReceivedListener(\n listener: (event: Notification) => void\n): Subscription {\n return emitter.addListener(didReceiveNotificationEventName, listener);\n}\n\nexport function addNotificationsDroppedListener(listener: () => void): Subscription {\n return emitter.addListener(didDropNotificationsEventName, listener);\n}\n\nexport function addNotificationResponseReceivedListener(\n listener: (event: NotificationResponse) => void\n): Subscription {\n return emitter.addListener(\n didReceiveNotificationResponseEventName,\n listener\n );\n}\n\nexport function removeNotificationSubscription(subscription: Subscription) {\n emitter.removeSubscription(subscription);\n}\n\nexport function removeAllNotificationListeners() {\n emitter.removeAllListeners(didReceiveNotificationEventName);\n emitter.removeAllListeners(didDropNotificationsEventName);\n emitter.removeAllListeners(didReceiveNotificationResponseEventName);\n}\n"]} \ No newline at end of file +{"version":3,"file":"NotificationsEmitter.js","sourceRoot":"","sources":["../src/NotificationsEmitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,kBAAkB,CAAC;AAG9D,OAAO,0BAA0B,MAAM,8BAA8B,CAAC;AAEtE,iCAAiC;AACjC,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,0BAA0B,CAAC,CAAC;AAE7D,MAAM,+BAA+B,GAAG,0BAA0B,CAAC;AACnE,MAAM,6BAA6B,GAAG,wBAAwB,CAAC;AAC/D,MAAM,uCAAuC,GAAG,kCAAkC,CAAC;AAEnF,MAAM,CAAC,MAAM,yBAAyB,GAAG,4CAA4C,CAAC;AAEtF,MAAM,UAAU,+BAA+B,CAC7C,QAAuC;IAEvC,OAAO,OAAO,CAAC,WAAW,CAAe,+BAA+B,EAAE,QAAQ,CAAC,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,QAAoB;IAClE,OAAO,OAAO,CAAC,WAAW,CAAO,6BAA6B,EAAE,QAAQ,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,uCAAuC,CACrD,QAA+C;IAE/C,OAAO,OAAO,CAAC,WAAW,CACxB,uCAAuC,EACvC,QAAQ,CACT,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,YAA0B;IACvE,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,OAAO,CAAC,kBAAkB,CAAC,+BAA+B,CAAC,CAAC;IAC5D,OAAO,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,CAAC;IAC1D,OAAO,CAAC,kBAAkB,CAAC,uCAAuC,CAAC,CAAC;AACtE,CAAC","sourcesContent":["import { EventEmitter, Subscription } from '@unimodules/core';\n\nimport { Notification, NotificationResponse } from './Notifications.types';\nimport NotificationsEmitterModule from './NotificationsEmitterModule';\n\n// Web uses SyntheticEventEmitter\nconst emitter = new EventEmitter(NotificationsEmitterModule);\n\nconst didReceiveNotificationEventName = 'onDidReceiveNotification';\nconst didDropNotificationsEventName = 'onNotificationsDeleted';\nconst didReceiveNotificationResponseEventName = 'onDidReceiveNotificationResponse';\n\nexport const DEFAULT_ACTION_IDENTIFIER = 'expo.modules.notifications.actions.DEFAULT';\n\nexport function addNotificationReceivedListener(\n listener: (event: Notification) => void\n): Subscription {\n return emitter.addListener(didReceiveNotificationEventName, listener);\n}\n\nexport function addNotificationsDroppedListener(listener: () => void): Subscription {\n return emitter.addListener(didDropNotificationsEventName, listener);\n}\n\nexport function addNotificationResponseReceivedListener(\n listener: (event: NotificationResponse) => void\n): Subscription {\n return emitter.addListener(\n didReceiveNotificationResponseEventName,\n listener\n );\n}\n\nexport function removeNotificationSubscription(subscription: Subscription) {\n emitter.removeSubscription(subscription);\n}\n\nexport function removeAllNotificationListeners() {\n emitter.removeAllListeners(didReceiveNotificationEventName);\n emitter.removeAllListeners(didDropNotificationsEventName);\n emitter.removeAllListeners(didReceiveNotificationResponseEventName);\n}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsEmitterModule.d.ts b/packages/expo-notifications/build/NotificationsEmitterModule.d.ts new file mode 100644 index 0000000000000..18bb02e7e009d --- /dev/null +++ b/packages/expo-notifications/build/NotificationsEmitterModule.d.ts @@ -0,0 +1,3 @@ +import { NotificationsEmitterModule } from './NotificationsEmitterModule.types'; +declare const _default: NotificationsEmitterModule; +export default _default; diff --git a/packages/expo-notifications/build/NotificationsEmitterModule.js b/packages/expo-notifications/build/NotificationsEmitterModule.js new file mode 100644 index 0000000000000..785c34e89f316 --- /dev/null +++ b/packages/expo-notifications/build/NotificationsEmitterModule.js @@ -0,0 +1,12 @@ +import { Platform } from '@unimodules/core'; +let warningHasBeenShown = false; +export default { + addListener: () => { + if (!warningHasBeenShown) { + console.warn(`[expo-notifications] Emitting notifications is not yet fully supported on ${Platform.OS}. Adding a listener will have no effect.`); + warningHasBeenShown = true; + } + }, + removeListeners: () => { }, +}; +//# sourceMappingURL=NotificationsEmitterModule.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsEmitterModule.js.map b/packages/expo-notifications/build/NotificationsEmitterModule.js.map new file mode 100644 index 0000000000000..eff0d53c388a6 --- /dev/null +++ b/packages/expo-notifications/build/NotificationsEmitterModule.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationsEmitterModule.js","sourceRoot":"","sources":["../src/NotificationsEmitterModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAEhC,eAAe;IACb,WAAW,EAAE,GAAG,EAAE;QAChB,IAAI,CAAC,mBAAmB,EAAE;YACxB,OAAO,CAAC,IAAI,CACV,6EAA6E,QAAQ,CAAC,EAAE,0CAA0C,CACnI,CAAC;YACF,mBAAmB,GAAG,IAAI,CAAC;SAC5B;IACH,CAAC;IACD,eAAe,EAAE,GAAG,EAAE,GAAE,CAAC;CACI,CAAC","sourcesContent":["import { Platform } from '@unimodules/core';\n\nimport { NotificationsEmitterModule } from './NotificationsEmitterModule.types';\n\nlet warningHasBeenShown = false;\n\nexport default {\n addListener: () => {\n if (!warningHasBeenShown) {\n console.warn(\n `[expo-notifications] Emitting notifications is not yet fully supported on ${Platform.OS}. Adding a listener will have no effect.`\n );\n warningHasBeenShown = true;\n }\n },\n removeListeners: () => {},\n} as NotificationsEmitterModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsEmitterModule.native.d.ts b/packages/expo-notifications/build/NotificationsEmitterModule.native.d.ts new file mode 100644 index 0000000000000..18bb02e7e009d --- /dev/null +++ b/packages/expo-notifications/build/NotificationsEmitterModule.native.d.ts @@ -0,0 +1,3 @@ +import { NotificationsEmitterModule } from './NotificationsEmitterModule.types'; +declare const _default: NotificationsEmitterModule; +export default _default; diff --git a/packages/expo-notifications/build/NotificationsEmitterModule.native.js b/packages/expo-notifications/build/NotificationsEmitterModule.native.js new file mode 100644 index 0000000000000..555d231611b56 --- /dev/null +++ b/packages/expo-notifications/build/NotificationsEmitterModule.native.js @@ -0,0 +1,3 @@ +import { NativeModulesProxy } from '@unimodules/core'; +export default NativeModulesProxy.ExpoNotificationsEmitter; +//# sourceMappingURL=NotificationsEmitterModule.native.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsEmitterModule.native.js.map b/packages/expo-notifications/build/NotificationsEmitterModule.native.js.map new file mode 100644 index 0000000000000..d7134b6586e4e --- /dev/null +++ b/packages/expo-notifications/build/NotificationsEmitterModule.native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationsEmitterModule.native.js","sourceRoot":"","sources":["../src/NotificationsEmitterModule.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAgB,kBAAkB,CAAC,wBAA8D,CAAC","sourcesContent":["import { NativeModulesProxy } from '@unimodules/core';\n\nimport { NotificationsEmitterModule } from './NotificationsEmitterModule.types';\n\nexport default (NativeModulesProxy.ExpoNotificationsEmitter as any) as NotificationsEmitterModule;\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsEmitterModule.types.d.ts b/packages/expo-notifications/build/NotificationsEmitterModule.types.d.ts new file mode 100644 index 0000000000000..85e4739544ab2 --- /dev/null +++ b/packages/expo-notifications/build/NotificationsEmitterModule.types.d.ts @@ -0,0 +1,3 @@ +import { ProxyNativeModule } from '@unimodules/core'; +export interface NotificationsEmitterModule extends ProxyNativeModule { +} diff --git a/packages/expo-notifications/build/NotificationsEmitterModule.types.js b/packages/expo-notifications/build/NotificationsEmitterModule.types.js new file mode 100644 index 0000000000000..e126a43a4de7b --- /dev/null +++ b/packages/expo-notifications/build/NotificationsEmitterModule.types.js @@ -0,0 +1 @@ +//# sourceMappingURL=NotificationsEmitterModule.types.js.map \ No newline at end of file diff --git a/packages/expo-notifications/build/NotificationsEmitterModule.types.js.map b/packages/expo-notifications/build/NotificationsEmitterModule.types.js.map new file mode 100644 index 0000000000000..a1be166f5dad3 --- /dev/null +++ b/packages/expo-notifications/build/NotificationsEmitterModule.types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NotificationsEmitterModule.types.js","sourceRoot":"","sources":["../src/NotificationsEmitterModule.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ProxyNativeModule } from '@unimodules/core';\n\nexport interface NotificationsEmitterModule extends ProxyNativeModule {}\n"]} \ No newline at end of file diff --git a/packages/expo-notifications/src/NotificationsEmitter.ts b/packages/expo-notifications/src/NotificationsEmitter.ts index 78a1a890dc750..91f68ba16fc81 100644 --- a/packages/expo-notifications/src/NotificationsEmitter.ts +++ b/packages/expo-notifications/src/NotificationsEmitter.ts @@ -1,9 +1,10 @@ -import { EventEmitter, Subscription, NativeModulesProxy } from '@unimodules/core'; +import { EventEmitter, Subscription } from '@unimodules/core'; import { Notification, NotificationResponse } from './Notifications.types'; +import NotificationsEmitterModule from './NotificationsEmitterModule'; // Web uses SyntheticEventEmitter -const emitter = new EventEmitter(NativeModulesProxy.ExpoNotificationsEmitter); +const emitter = new EventEmitter(NotificationsEmitterModule); const didReceiveNotificationEventName = 'onDidReceiveNotification'; const didDropNotificationsEventName = 'onNotificationsDeleted'; diff --git a/packages/expo-notifications/src/NotificationsEmitterModule.native.ts b/packages/expo-notifications/src/NotificationsEmitterModule.native.ts new file mode 100644 index 0000000000000..b909f503b8664 --- /dev/null +++ b/packages/expo-notifications/src/NotificationsEmitterModule.native.ts @@ -0,0 +1,5 @@ +import { NativeModulesProxy } from '@unimodules/core'; + +import { NotificationsEmitterModule } from './NotificationsEmitterModule.types'; + +export default (NativeModulesProxy.ExpoNotificationsEmitter as any) as NotificationsEmitterModule; diff --git a/packages/expo-notifications/src/NotificationsEmitterModule.ts b/packages/expo-notifications/src/NotificationsEmitterModule.ts new file mode 100644 index 0000000000000..ed814505a9525 --- /dev/null +++ b/packages/expo-notifications/src/NotificationsEmitterModule.ts @@ -0,0 +1,17 @@ +import { Platform } from '@unimodules/core'; + +import { NotificationsEmitterModule } from './NotificationsEmitterModule.types'; + +let warningHasBeenShown = false; + +export default { + addListener: () => { + if (!warningHasBeenShown) { + console.warn( + `[expo-notifications] Emitting notifications is not yet fully supported on ${Platform.OS}. Adding a listener will have no effect.` + ); + warningHasBeenShown = true; + } + }, + removeListeners: () => {}, +} as NotificationsEmitterModule; diff --git a/packages/expo-notifications/src/NotificationsEmitterModule.types.ts b/packages/expo-notifications/src/NotificationsEmitterModule.types.ts new file mode 100644 index 0000000000000..3abaf537a33a4 --- /dev/null +++ b/packages/expo-notifications/src/NotificationsEmitterModule.types.ts @@ -0,0 +1,3 @@ +import { ProxyNativeModule } from '@unimodules/core'; + +export interface NotificationsEmitterModule extends ProxyNativeModule {} From 066e841e865139b29623e12778dce52718605be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 18 Jun 2020 10:35:47 +0200 Subject: [PATCH 17/17] [apps] Minor notifications related fixes --- .../src/screens/NotificationScreen.tsx | 6 +++--- apps/test-suite/tests/NewNotifications.js | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/apps/native-component-list/src/screens/NotificationScreen.tsx b/apps/native-component-list/src/screens/NotificationScreen.tsx index 087275976e020..cca488249de81 100644 --- a/apps/native-component-list/src/screens/NotificationScreen.tsx +++ b/apps/native-component-list/src/screens/NotificationScreen.tsx @@ -138,7 +138,7 @@ export default class NotificationScreen extends React.Component< _presentLocalNotificationAsync = async () => { await this._obtainUserFacingNotifPermissionsAsync(); - Notifications.scheduleNotificationAsync({ + await Notifications.scheduleNotificationAsync({ content: { title: 'Here is a scheduled notification!', body: 'This is the body', @@ -154,7 +154,7 @@ export default class NotificationScreen extends React.Component< _LEGACY_presentLocalNotificationAsync = async () => { await this._obtainUserFacingNotifPermissionsAsync(); - Notifications.presentNotificationAsync({ + await Notifications.presentNotificationAsync({ title: 'Here is a local notification!', body: 'This is the body', data: { @@ -166,7 +166,7 @@ export default class NotificationScreen extends React.Component< _scheduleLocalNotificationAsync = async () => { await this._obtainUserFacingNotifPermissionsAsync(); - Notifications.scheduleNotificationAsync({ + await Notifications.scheduleNotificationAsync({ content: { title: 'Here is a local notification!', body: 'This is the body', diff --git a/apps/test-suite/tests/NewNotifications.js b/apps/test-suite/tests/NewNotifications.js index 3e67d90d211bf..2884f5c3bf6c5 100644 --- a/apps/test-suite/tests/NewNotifications.js +++ b/apps/test-suite/tests/NewNotifications.js @@ -59,7 +59,7 @@ export async function test(t) { t.expect(tokenFromEvent).toEqual(tokenFromMethodCall); }); - t.fit('resolves when multiple calls are issued', async () => { + t.it('resolves when multiple calls are issued', async () => { const results = await Promise.all([ Notifications.getDevicePushTokenAsync(), Notifications.getDevicePushTokenAsync(), @@ -69,7 +69,7 @@ export async function test(t) { }); // Not running this test on web since Expo push notification doesn't yet support web. - const itWithExpoPushToken = ['ios', 'android'].includes(Platform.OS) ? t.fit : t.xit; + const itWithExpoPushToken = ['ios', 'android'].includes(Platform.OS) ? t.it : t.xit; itWithExpoPushToken('fetches Expo push token', async () => { let experienceId = undefined; if (!Constants.manifest) { @@ -86,8 +86,15 @@ export async function test(t) { }); itWithExpoPushToken('resolves when mixed multiple calls are issued', async () => { + let experienceId = undefined; + if (!Constants.manifest) { + // Absence of manifest means we're running out of managed workflow + // in bare-expo. @exponent/bare-expo "experience" has been configured + // to use Apple Push Notification key that will work in bare-expo. + experienceId = '@exponent/bare-expo'; + } await Promise.all([ - Notifications.getExpoPushTokenAsync(), + Notifications.getExpoPushTokenAsync({ experienceId }), Notifications.getDevicePushTokenAsync(), ]); }); @@ -1304,7 +1311,7 @@ export async function test(t) { }; t.beforeEach(async () => { - Notifications.cancelAllScheduledNotificationsAsync(); + await Notifications.cancelAllScheduledNotificationsAsync(); Notifications.setNotificationHandler({ handleNotification: async () => { timesSpyHasBeenCalled += 1; @@ -1315,9 +1322,9 @@ export async function test(t) { }); }); - t.afterEach(() => { + t.afterEach(async () => { Notifications.setNotificationHandler(null); - Notifications.cancelAllScheduledNotificationsAsync(); + await Notifications.cancelAllScheduledNotificationsAsync(); }); t.it(