@symbiote-native/notifications 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +258 -0
- package/build/angular/index.d.ts +1 -0
- package/build/angular/index.js +1 -0
- package/build/core/background-task.d.ts +9 -0
- package/build/core/background-task.js +28 -0
- package/build/core/badge.d.ts +7 -0
- package/build/core/badge.js +23 -0
- package/build/core/categories.d.ts +10 -0
- package/build/core/categories.js +28 -0
- package/build/core/channels.d.ts +20 -0
- package/build/core/channels.js +106 -0
- package/build/core/emitter.d.ts +24 -0
- package/build/core/emitter.js +58 -0
- package/build/core/handler.d.ts +15 -0
- package/build/core/handler.js +50 -0
- package/build/core/index.d.ts +12 -0
- package/build/core/index.js +11 -0
- package/build/core/native-modules.d.ts +82 -0
- package/build/core/native-modules.js +33 -0
- package/build/core/permissions.d.ts +8 -0
- package/build/core/permissions.js +30 -0
- package/build/core/presenter.d.ts +7 -0
- package/build/core/presenter.js +27 -0
- package/build/core/scheduler.d.ts +13 -0
- package/build/core/scheduler.js +193 -0
- package/build/core/tokens.d.ts +30 -0
- package/build/core/tokens.js +192 -0
- package/build/core/types.d.ts +633 -0
- package/build/core/types.js +116 -0
- package/build/core/utils.d.ts +6 -0
- package/build/core/utils.js +53 -0
- package/build-ngc/angular/index.d.ts +1 -0
- package/build-ngc/angular/index.js +2 -0
- package/build-ngc/angular/index.js.map +1 -0
- package/build-ngc/core/background-task.d.ts +9 -0
- package/build-ngc/core/background-task.js +29 -0
- package/build-ngc/core/background-task.js.map +1 -0
- package/build-ngc/core/badge.d.ts +7 -0
- package/build-ngc/core/badge.js +24 -0
- package/build-ngc/core/badge.js.map +1 -0
- package/build-ngc/core/categories.d.ts +10 -0
- package/build-ngc/core/categories.js +29 -0
- package/build-ngc/core/categories.js.map +1 -0
- package/build-ngc/core/channels.d.ts +20 -0
- package/build-ngc/core/channels.js +107 -0
- package/build-ngc/core/channels.js.map +1 -0
- package/build-ngc/core/emitter.d.ts +24 -0
- package/build-ngc/core/emitter.js +59 -0
- package/build-ngc/core/emitter.js.map +1 -0
- package/build-ngc/core/handler.d.ts +15 -0
- package/build-ngc/core/handler.js +51 -0
- package/build-ngc/core/handler.js.map +1 -0
- package/build-ngc/core/index.d.ts +12 -0
- package/build-ngc/core/index.js +12 -0
- package/build-ngc/core/index.js.map +1 -0
- package/build-ngc/core/native-modules.d.ts +82 -0
- package/build-ngc/core/native-modules.js +34 -0
- package/build-ngc/core/native-modules.js.map +1 -0
- package/build-ngc/core/permissions.d.ts +8 -0
- package/build-ngc/core/permissions.js +31 -0
- package/build-ngc/core/permissions.js.map +1 -0
- package/build-ngc/core/presenter.d.ts +7 -0
- package/build-ngc/core/presenter.js +28 -0
- package/build-ngc/core/presenter.js.map +1 -0
- package/build-ngc/core/scheduler.d.ts +13 -0
- package/build-ngc/core/scheduler.js +194 -0
- package/build-ngc/core/scheduler.js.map +1 -0
- package/build-ngc/core/tokens.d.ts +30 -0
- package/build-ngc/core/tokens.js +193 -0
- package/build-ngc/core/tokens.js.map +1 -0
- package/build-ngc/core/types.d.ts +633 -0
- package/build-ngc/core/types.js +117 -0
- package/build-ngc/core/types.js.map +1 -0
- package/build-ngc/core/utils.d.ts +6 -0
- package/build-ngc/core/utils.js +54 -0
- package/build-ngc/core/utils.js.map +1 -0
- package/native-link.json +88 -0
- package/package.json +150 -0
- package/src/angular/index.ts +1 -0
- package/src/core/background-task.ts +32 -0
- package/src/core/badge.ts +26 -0
- package/src/core/categories.ts +60 -0
- package/src/core/channels.ts +183 -0
- package/src/core/emitter.ts +95 -0
- package/src/core/handler.ts +95 -0
- package/src/core/index.ts +144 -0
- package/src/core/native-modules.ts +209 -0
- package/src/core/permissions.ts +46 -0
- package/src/core/presenter.ts +45 -0
- package/src/core/scheduler.ts +265 -0
- package/src/core/tokens.ts +272 -0
- package/src/core/types.ts +767 -0
- package/src/core/utils.ts +82 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Hand-ported from expo-notifications @ sdk-57 (Notifications.types.ts / Tokens.types.ts /
|
|
2
|
+
// NotificationChannelManager.types.ts / NotificationChannelGroupManager.types.ts /
|
|
3
|
+
// NotificationScheduler.types.ts) — this repo's own `I`-prefix convention for public types.
|
|
4
|
+
//
|
|
5
|
+
// PermissionResponse/PermissionStatus/PermissionExpiration come straight from
|
|
6
|
+
// expo-modules-core (the same precedent packages/sensors and packages/local-auth already use),
|
|
7
|
+
// not redeclared here.
|
|
8
|
+
import { PermissionStatus, } from 'expo-modules-core';
|
|
9
|
+
export { PermissionStatus };
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Permissions
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
/** @platform ios */
|
|
14
|
+
export var IosAlertStyle;
|
|
15
|
+
(function (IosAlertStyle) {
|
|
16
|
+
IosAlertStyle[IosAlertStyle["NONE"] = 0] = "NONE";
|
|
17
|
+
IosAlertStyle[IosAlertStyle["BANNER"] = 1] = "BANNER";
|
|
18
|
+
IosAlertStyle[IosAlertStyle["ALERT"] = 2] = "ALERT";
|
|
19
|
+
})(IosAlertStyle || (IosAlertStyle = {}));
|
|
20
|
+
/** @platform ios */
|
|
21
|
+
export var IosAllowsPreviews;
|
|
22
|
+
(function (IosAllowsPreviews) {
|
|
23
|
+
IosAllowsPreviews[IosAllowsPreviews["NEVER"] = 0] = "NEVER";
|
|
24
|
+
IosAllowsPreviews[IosAllowsPreviews["ALWAYS"] = 1] = "ALWAYS";
|
|
25
|
+
IosAllowsPreviews[IosAllowsPreviews["WHEN_AUTHENTICATED"] = 2] = "WHEN_AUTHENTICATED";
|
|
26
|
+
})(IosAllowsPreviews || (IosAllowsPreviews = {}));
|
|
27
|
+
/** @platform ios */
|
|
28
|
+
export var IosAuthorizationStatus;
|
|
29
|
+
(function (IosAuthorizationStatus) {
|
|
30
|
+
IosAuthorizationStatus[IosAuthorizationStatus["NOT_DETERMINED"] = 0] = "NOT_DETERMINED";
|
|
31
|
+
IosAuthorizationStatus[IosAuthorizationStatus["DENIED"] = 1] = "DENIED";
|
|
32
|
+
IosAuthorizationStatus[IosAuthorizationStatus["AUTHORIZED"] = 2] = "AUTHORIZED";
|
|
33
|
+
IosAuthorizationStatus[IosAuthorizationStatus["PROVISIONAL"] = 3] = "PROVISIONAL";
|
|
34
|
+
IosAuthorizationStatus[IosAuthorizationStatus["EPHEMERAL"] = 4] = "EPHEMERAL";
|
|
35
|
+
})(IosAuthorizationStatus || (IosAuthorizationStatus = {}));
|
|
36
|
+
export var SchedulableTriggerInputTypes;
|
|
37
|
+
(function (SchedulableTriggerInputTypes) {
|
|
38
|
+
SchedulableTriggerInputTypes["CALENDAR"] = "calendar";
|
|
39
|
+
SchedulableTriggerInputTypes["DAILY"] = "daily";
|
|
40
|
+
SchedulableTriggerInputTypes["WEEKLY"] = "weekly";
|
|
41
|
+
SchedulableTriggerInputTypes["MONTHLY"] = "monthly";
|
|
42
|
+
SchedulableTriggerInputTypes["YEARLY"] = "yearly";
|
|
43
|
+
SchedulableTriggerInputTypes["DATE"] = "date";
|
|
44
|
+
SchedulableTriggerInputTypes["TIME_INTERVAL"] = "timeInterval";
|
|
45
|
+
})(SchedulableTriggerInputTypes || (SchedulableTriggerInputTypes = {}));
|
|
46
|
+
/** @platform android */
|
|
47
|
+
export var AndroidNotificationPriority;
|
|
48
|
+
(function (AndroidNotificationPriority) {
|
|
49
|
+
AndroidNotificationPriority["MIN"] = "min";
|
|
50
|
+
AndroidNotificationPriority["LOW"] = "low";
|
|
51
|
+
AndroidNotificationPriority["DEFAULT"] = "default";
|
|
52
|
+
AndroidNotificationPriority["HIGH"] = "high";
|
|
53
|
+
AndroidNotificationPriority["MAX"] = "max";
|
|
54
|
+
})(AndroidNotificationPriority || (AndroidNotificationPriority = {}));
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
// Android channels / channel groups
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
/** @platform android */
|
|
59
|
+
export var AndroidNotificationVisibility;
|
|
60
|
+
(function (AndroidNotificationVisibility) {
|
|
61
|
+
AndroidNotificationVisibility[AndroidNotificationVisibility["UNKNOWN"] = 0] = "UNKNOWN";
|
|
62
|
+
AndroidNotificationVisibility[AndroidNotificationVisibility["PUBLIC"] = 1] = "PUBLIC";
|
|
63
|
+
AndroidNotificationVisibility[AndroidNotificationVisibility["PRIVATE"] = 2] = "PRIVATE";
|
|
64
|
+
AndroidNotificationVisibility[AndroidNotificationVisibility["SECRET"] = 3] = "SECRET";
|
|
65
|
+
})(AndroidNotificationVisibility || (AndroidNotificationVisibility = {}));
|
|
66
|
+
/** @platform android */
|
|
67
|
+
export var AndroidAudioContentType;
|
|
68
|
+
(function (AndroidAudioContentType) {
|
|
69
|
+
AndroidAudioContentType[AndroidAudioContentType["UNKNOWN"] = 0] = "UNKNOWN";
|
|
70
|
+
AndroidAudioContentType[AndroidAudioContentType["SPEECH"] = 1] = "SPEECH";
|
|
71
|
+
AndroidAudioContentType[AndroidAudioContentType["MUSIC"] = 2] = "MUSIC";
|
|
72
|
+
AndroidAudioContentType[AndroidAudioContentType["MOVIE"] = 3] = "MOVIE";
|
|
73
|
+
AndroidAudioContentType[AndroidAudioContentType["SONIFICATION"] = 4] = "SONIFICATION";
|
|
74
|
+
})(AndroidAudioContentType || (AndroidAudioContentType = {}));
|
|
75
|
+
/** @platform android */
|
|
76
|
+
export var AndroidImportance;
|
|
77
|
+
(function (AndroidImportance) {
|
|
78
|
+
AndroidImportance[AndroidImportance["UNKNOWN"] = 0] = "UNKNOWN";
|
|
79
|
+
/** Use `DEFAULT` instead — present for compatibility only. */
|
|
80
|
+
AndroidImportance[AndroidImportance["UNSPECIFIED"] = 1] = "UNSPECIFIED";
|
|
81
|
+
AndroidImportance[AndroidImportance["NONE"] = 2] = "NONE";
|
|
82
|
+
AndroidImportance[AndroidImportance["MIN"] = 3] = "MIN";
|
|
83
|
+
AndroidImportance[AndroidImportance["LOW"] = 4] = "LOW";
|
|
84
|
+
AndroidImportance[AndroidImportance["DEFAULT"] = 5] = "DEFAULT";
|
|
85
|
+
AndroidImportance[AndroidImportance["HIGH"] = 6] = "HIGH";
|
|
86
|
+
AndroidImportance[AndroidImportance["MAX"] = 7] = "MAX";
|
|
87
|
+
})(AndroidImportance || (AndroidImportance = {}));
|
|
88
|
+
/** @platform android */
|
|
89
|
+
export var AndroidAudioUsage;
|
|
90
|
+
(function (AndroidAudioUsage) {
|
|
91
|
+
AndroidAudioUsage[AndroidAudioUsage["UNKNOWN"] = 0] = "UNKNOWN";
|
|
92
|
+
AndroidAudioUsage[AndroidAudioUsage["MEDIA"] = 1] = "MEDIA";
|
|
93
|
+
AndroidAudioUsage[AndroidAudioUsage["VOICE_COMMUNICATION"] = 2] = "VOICE_COMMUNICATION";
|
|
94
|
+
AndroidAudioUsage[AndroidAudioUsage["VOICE_COMMUNICATION_SIGNALLING"] = 3] = "VOICE_COMMUNICATION_SIGNALLING";
|
|
95
|
+
AndroidAudioUsage[AndroidAudioUsage["ALARM"] = 4] = "ALARM";
|
|
96
|
+
AndroidAudioUsage[AndroidAudioUsage["NOTIFICATION"] = 5] = "NOTIFICATION";
|
|
97
|
+
AndroidAudioUsage[AndroidAudioUsage["NOTIFICATION_RINGTONE"] = 6] = "NOTIFICATION_RINGTONE";
|
|
98
|
+
AndroidAudioUsage[AndroidAudioUsage["NOTIFICATION_COMMUNICATION_REQUEST"] = 7] = "NOTIFICATION_COMMUNICATION_REQUEST";
|
|
99
|
+
AndroidAudioUsage[AndroidAudioUsage["NOTIFICATION_COMMUNICATION_INSTANT"] = 8] = "NOTIFICATION_COMMUNICATION_INSTANT";
|
|
100
|
+
AndroidAudioUsage[AndroidAudioUsage["NOTIFICATION_COMMUNICATION_DELAYED"] = 9] = "NOTIFICATION_COMMUNICATION_DELAYED";
|
|
101
|
+
AndroidAudioUsage[AndroidAudioUsage["NOTIFICATION_EVENT"] = 10] = "NOTIFICATION_EVENT";
|
|
102
|
+
AndroidAudioUsage[AndroidAudioUsage["ASSISTANCE_ACCESSIBILITY"] = 11] = "ASSISTANCE_ACCESSIBILITY";
|
|
103
|
+
AndroidAudioUsage[AndroidAudioUsage["ASSISTANCE_NAVIGATION_GUIDANCE"] = 12] = "ASSISTANCE_NAVIGATION_GUIDANCE";
|
|
104
|
+
AndroidAudioUsage[AndroidAudioUsage["ASSISTANCE_SONIFICATION"] = 13] = "ASSISTANCE_SONIFICATION";
|
|
105
|
+
AndroidAudioUsage[AndroidAudioUsage["GAME"] = 14] = "GAME";
|
|
106
|
+
})(AndroidAudioUsage || (AndroidAudioUsage = {}));
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
// Background task
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
/** Corresponds to `UIBackgroundFetchResult`. @platform ios */
|
|
111
|
+
export var BackgroundNotificationTaskResult;
|
|
112
|
+
(function (BackgroundNotificationTaskResult) {
|
|
113
|
+
BackgroundNotificationTaskResult[BackgroundNotificationTaskResult["NewData"] = 0] = "NewData";
|
|
114
|
+
BackgroundNotificationTaskResult[BackgroundNotificationTaskResult["NoData"] = 1] = "NoData";
|
|
115
|
+
BackgroundNotificationTaskResult[BackgroundNotificationTaskResult["Failed"] = 2] = "Failed";
|
|
116
|
+
})(BackgroundNotificationTaskResult || (BackgroundNotificationTaskResult = {}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { INotification, INotificationContent, INotificationRequest, INotificationResponse } from './types';
|
|
2
|
+
export declare function hasValidTriggerObject(trigger: unknown): boolean;
|
|
3
|
+
export declare function mapNotificationContent(content: INotificationContent): INotificationContent;
|
|
4
|
+
export declare function mapNotificationRequest(request: INotificationRequest): INotificationRequest;
|
|
5
|
+
export declare function mapNotification(notification: INotification): INotification;
|
|
6
|
+
export declare function mapNotificationResponse(response: INotificationResponse): INotificationResponse;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export function hasValidTriggerObject(trigger) {
|
|
2
|
+
if (trigger === null)
|
|
3
|
+
return true;
|
|
4
|
+
if (typeof trigger !== 'object')
|
|
5
|
+
return false;
|
|
6
|
+
return 'type' in trigger || 'channelId' in trigger;
|
|
7
|
+
}
|
|
8
|
+
let warnedAboutDataString = false;
|
|
9
|
+
// Native hands over a raw payload that may carry a legacy `dataString` field this package's own
|
|
10
|
+
// `INotificationContent` type does not declare — the one narrowing boundary for that dynamic
|
|
11
|
+
// extra field lives here, not scattered across call sites.
|
|
12
|
+
function readLegacyDataString(content) {
|
|
13
|
+
const record = content;
|
|
14
|
+
const dataString = record.dataString;
|
|
15
|
+
return typeof dataString === 'string' ? dataString : undefined;
|
|
16
|
+
}
|
|
17
|
+
export function mapNotificationContent(content) {
|
|
18
|
+
try {
|
|
19
|
+
const dataString = readLegacyDataString(content);
|
|
20
|
+
if (typeof dataString === 'string') {
|
|
21
|
+
const mapped = {
|
|
22
|
+
...content,
|
|
23
|
+
};
|
|
24
|
+
mapped.data = JSON.parse(dataString);
|
|
25
|
+
Object.defineProperty(mapped, 'dataString', {
|
|
26
|
+
get() {
|
|
27
|
+
if (!warnedAboutDataString) {
|
|
28
|
+
warnedAboutDataString = true;
|
|
29
|
+
console.warn('[notifications] reading dataString is deprecated, use data instead');
|
|
30
|
+
}
|
|
31
|
+
return dataString;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return mapped;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.error(`[notifications] Error parsing notification content: ${error}`);
|
|
39
|
+
}
|
|
40
|
+
return content;
|
|
41
|
+
}
|
|
42
|
+
export function mapNotificationRequest(request) {
|
|
43
|
+
return { ...request, content: mapNotificationContent(request.content) };
|
|
44
|
+
}
|
|
45
|
+
export function mapNotification(notification) {
|
|
46
|
+
return {
|
|
47
|
+
...notification,
|
|
48
|
+
request: mapNotificationRequest(notification.request),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function mapNotificationResponse(response) {
|
|
52
|
+
return { ...response, notification: mapNotification(response.notification) };
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/angular/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { BackgroundNotificationTaskResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Starts delivering notification-received/response events (and, when the app is terminated,
|
|
4
|
+
* headless background notifications) into a task already defined with
|
|
5
|
+
* `TaskManager.defineTask(taskName, …)`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerTaskAsync(taskName: string): Promise<null>;
|
|
8
|
+
/** Stops delivering into a task registered with `registerTaskAsync`. */
|
|
9
|
+
export declare function unregisterTaskAsync(taskName: string): Promise<null>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Ported from expo-notifications @ sdk-57's registerTaskAsync.ts / unregisterTaskAsync.ts.
|
|
2
|
+
//
|
|
3
|
+
// Runs on `@symbiote-native/task-manager` under the hood, exactly like upstream runs on
|
|
4
|
+
// `expo-task-manager` — `TaskManager.defineTask(taskName, executor)` must be called first, at
|
|
5
|
+
// the top of the JS bundle (outside any component), then this function tells native to start
|
|
6
|
+
// delivering into that task. See this package's README for the full wiring, including why the
|
|
7
|
+
// task also needs `@symbiote-native/task-manager` installed.
|
|
8
|
+
import { UnavailabilityError } from 'expo-modules-core';
|
|
9
|
+
import { backgroundNotificationTasksModule } from './native-modules';
|
|
10
|
+
export { BackgroundNotificationTaskResult } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Starts delivering notification-received/response events (and, when the app is terminated,
|
|
13
|
+
* headless background notifications) into a task already defined with
|
|
14
|
+
* `TaskManager.defineTask(taskName, …)`.
|
|
15
|
+
*/
|
|
16
|
+
export async function registerTaskAsync(taskName) {
|
|
17
|
+
if (!backgroundNotificationTasksModule.registerTaskAsync) {
|
|
18
|
+
throw new UnavailabilityError('Notifications', 'registerTaskAsync');
|
|
19
|
+
}
|
|
20
|
+
return backgroundNotificationTasksModule.registerTaskAsync(taskName);
|
|
21
|
+
}
|
|
22
|
+
/** Stops delivering into a task registered with `registerTaskAsync`. */
|
|
23
|
+
export async function unregisterTaskAsync(taskName) {
|
|
24
|
+
if (!backgroundNotificationTasksModule.unregisterTaskAsync) {
|
|
25
|
+
throw new UnavailabilityError('Notifications', 'unregisterTaskAsync');
|
|
26
|
+
}
|
|
27
|
+
return backgroundNotificationTasksModule.unregisterTaskAsync(taskName);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=background-task.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background-task.js","sourceRoot":"","sources":["../../src/core/background-task.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,EAAE;AACF,wFAAwF;AACxF,8FAA8F;AAC9F,6FAA6F;AAC7F,8FAA8F;AAC9F,6DAA6D;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAgB;IACtD,IAAI,CAAC,iCAAiC,CAAC,iBAAiB,EAAE,CAAC;QACzD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,iCAAiC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AACvE,CAAC;AAED,wEAAwE;AACxE,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,QAAgB;IACxD,IAAI,CAAC,iCAAiC,CAAC,mBAAmB,EAAE,CAAC;QAC3D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,iCAAiC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Current app-icon badge count. `0` if unset — not every Android launcher supports badges. */
|
|
2
|
+
export declare function getBadgeCountAsync(): Promise<number>;
|
|
3
|
+
/**
|
|
4
|
+
* Sets the app-icon badge. `0` clears it. On iOS this needs the `allowBadge` permission
|
|
5
|
+
* (`requestPermissionsAsync`) or it resolves to `false`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function setBadgeCountAsync(badgeCount: number): Promise<boolean>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Ported from expo-notifications @ sdk-57's getBadgeCountAsync.ts / setBadgeCountAsync.ts.
|
|
2
|
+
//
|
|
3
|
+
// ponytail: upstream's `SetBadgeCountOptions.web` (a `badgin` options bag) is web-only and this
|
|
4
|
+
// project targets iOS/Android — not ported.
|
|
5
|
+
import { UnavailabilityError } from 'expo-modules-core';
|
|
6
|
+
import { badgeModule } from './native-modules';
|
|
7
|
+
/** Current app-icon badge count. `0` if unset — not every Android launcher supports badges. */
|
|
8
|
+
export async function getBadgeCountAsync() {
|
|
9
|
+
if (!badgeModule.getBadgeCountAsync) {
|
|
10
|
+
throw new UnavailabilityError('Notifications', 'getBadgeCountAsync');
|
|
11
|
+
}
|
|
12
|
+
return badgeModule.getBadgeCountAsync();
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Sets the app-icon badge. `0` clears it. On iOS this needs the `allowBadge` permission
|
|
16
|
+
* (`requestPermissionsAsync`) or it resolves to `false`.
|
|
17
|
+
*/
|
|
18
|
+
export async function setBadgeCountAsync(badgeCount) {
|
|
19
|
+
if (!badgeModule.setBadgeCountAsync) {
|
|
20
|
+
throw new UnavailabilityError('Notifications', 'setBadgeCountAsync');
|
|
21
|
+
}
|
|
22
|
+
return badgeModule.setBadgeCountAsync(badgeCount);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=badge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.js","sourceRoot":"","sources":["../../src/core/badge.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,EAAE;AACF,gGAAgG;AAChG,4CAA4C;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,+FAA+F;AAC/F,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC;QACpC,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,WAAW,CAAC,kBAAkB,EAAE,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,UAAkB;IACzD,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC;QACpC,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,WAAW,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { INotificationAction, INotificationCategory, INotificationCategoryOptions } from './types';
|
|
2
|
+
/** Every registered notification category. */
|
|
3
|
+
export declare function getNotificationCategoriesAsync(): Promise<INotificationCategory[]>;
|
|
4
|
+
/**
|
|
5
|
+
* Registers a category of action buttons under `identifier`, referenced later via
|
|
6
|
+
* `INotificationContentInput.categoryIdentifier`. Avoid `:`/`-` in `identifier`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setNotificationCategoryAsync(identifier: string, actions: INotificationAction[], options?: INotificationCategoryOptions): Promise<INotificationCategory>;
|
|
9
|
+
/** Deletes a category. Resolves `false` if it did not exist. */
|
|
10
|
+
export declare function deleteNotificationCategoryAsync(identifier: string): Promise<boolean>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Ported from expo-notifications @ sdk-57's getNotificationCategoriesAsync.ts,
|
|
2
|
+
// setNotificationCategoryAsync.ts, deleteNotificationCategoryAsync.ts.
|
|
3
|
+
import { UnavailabilityError } from 'expo-modules-core';
|
|
4
|
+
import { notificationCategoriesModule } from './native-modules';
|
|
5
|
+
/** Every registered notification category. */
|
|
6
|
+
export async function getNotificationCategoriesAsync() {
|
|
7
|
+
if (!notificationCategoriesModule.getNotificationCategoriesAsync) {
|
|
8
|
+
throw new UnavailabilityError('Notifications', 'getNotificationCategoriesAsync');
|
|
9
|
+
}
|
|
10
|
+
return notificationCategoriesModule.getNotificationCategoriesAsync();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Registers a category of action buttons under `identifier`, referenced later via
|
|
14
|
+
* `INotificationContentInput.categoryIdentifier`. Avoid `:`/`-` in `identifier`.
|
|
15
|
+
*/
|
|
16
|
+
export async function setNotificationCategoryAsync(identifier, actions, options) {
|
|
17
|
+
if (!notificationCategoriesModule.setNotificationCategoryAsync) {
|
|
18
|
+
throw new UnavailabilityError('Notifications', 'setNotificationCategoryAsync');
|
|
19
|
+
}
|
|
20
|
+
return notificationCategoriesModule.setNotificationCategoryAsync(identifier, actions, options);
|
|
21
|
+
}
|
|
22
|
+
/** Deletes a category. Resolves `false` if it did not exist. */
|
|
23
|
+
export async function deleteNotificationCategoryAsync(identifier) {
|
|
24
|
+
if (!notificationCategoriesModule.deleteNotificationCategoryAsync) {
|
|
25
|
+
throw new UnavailabilityError('Notifications', 'deleteNotificationCategoryAsync');
|
|
26
|
+
}
|
|
27
|
+
return notificationCategoriesModule.deleteNotificationCategoryAsync(identifier);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=categories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"categories.js","sourceRoot":"","sources":["../../src/core/categories.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,uEAAuE;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAOhE,8CAA8C;AAC9C,MAAM,CAAC,KAAK,UAAU,8BAA8B;IAGlD,IAAI,CAAC,4BAA4B,CAAC,8BAA8B,EAAE,CAAC;QACjE,MAAM,IAAI,mBAAmB,CAC3B,eAAe,EACf,gCAAgC,CACjC,CAAC;IACJ,CAAC;IACD,OAAO,4BAA4B,CAAC,8BAA8B,EAAE,CAAC;AACvE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,UAAkB,EAClB,OAA8B,EAC9B,OAAsC;IAEtC,IAAI,CAAC,4BAA4B,CAAC,4BAA4B,EAAE,CAAC;QAC/D,MAAM,IAAI,mBAAmB,CAC3B,eAAe,EACf,8BAA8B,CAC/B,CAAC;IACJ,CAAC;IACD,OAAO,4BAA4B,CAAC,4BAA4B,CAC9D,UAAU,EACV,OAAO,EACP,OAAO,CACR,CAAC;AACJ,CAAC;AAED,gEAAgE;AAChE,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,UAAkB;IAElB,IAAI,CAAC,4BAA4B,CAAC,+BAA+B,EAAE,CAAC;QAClE,MAAM,IAAI,mBAAmB,CAC3B,eAAe,EACf,iCAAiC,CAClC,CAAC;IACJ,CAAC;IACD,OAAO,4BAA4B,CAAC,+BAA+B,CACjE,UAAU,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type INotificationChannel, type INotificationChannelGroup, type INotificationChannelGroupInput, type INotificationChannelInput } from './types';
|
|
2
|
+
/** @platform android — empty array on every other platform. */
|
|
3
|
+
export declare function getNotificationChannelsAsync(): Promise<INotificationChannel[]>;
|
|
4
|
+
/** @platform android — `null` on every other platform. */
|
|
5
|
+
export declare function getNotificationChannelAsync(channelId: string): Promise<INotificationChannel | null>;
|
|
6
|
+
/**
|
|
7
|
+
* Creates or updates a channel. Only the name and description may change once a channel
|
|
8
|
+
* exists — an Android OS limitation. @platform android — `null` on every other platform.
|
|
9
|
+
*/
|
|
10
|
+
export declare function setNotificationChannelAsync(channelId: string, channel: INotificationChannelInput): Promise<INotificationChannel | null>;
|
|
11
|
+
/** @platform android — no-op on every other platform. */
|
|
12
|
+
export declare function deleteNotificationChannelAsync(channelId: string): Promise<void>;
|
|
13
|
+
/** @platform android — empty array on every other platform. */
|
|
14
|
+
export declare function getNotificationChannelGroupsAsync(): Promise<INotificationChannelGroup[]>;
|
|
15
|
+
/** @platform android — `null` on every other platform. */
|
|
16
|
+
export declare function getNotificationChannelGroupAsync(groupId: string): Promise<INotificationChannelGroup | null>;
|
|
17
|
+
/** @platform android — `null` on every other platform. */
|
|
18
|
+
export declare function setNotificationChannelGroupAsync(groupId: string, group: INotificationChannelGroupInput): Promise<INotificationChannelGroup | null>;
|
|
19
|
+
/** @platform android — no-op on every other platform. */
|
|
20
|
+
export declare function deleteNotificationChannelGroupAsync(groupId: string): Promise<void>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Ported from expo-notifications @ sdk-57's get/set/deleteNotificationChannel(Group)Async.ts —
|
|
2
|
+
// upstream splits each of these into a `.ts` (iOS no-op) and a `.android.ts` (real) file picked
|
|
3
|
+
// by Metro's platform extension resolution; this port collapses each pair into one function with
|
|
4
|
+
// a runtime `Platform.OS === 'android'` branch, since this package has no separate build step
|
|
5
|
+
// per platform to exploit the file-split for.
|
|
6
|
+
import { Platform, UnavailabilityError } from 'expo-modules-core';
|
|
7
|
+
import { notificationChannelGroupManager, notificationChannelManager, } from './native-modules';
|
|
8
|
+
import { AndroidImportance, } from './types';
|
|
9
|
+
const ANDROID_ONLY_NOTICE = 'Notification channels are only supported on Android.';
|
|
10
|
+
function isAndroid() {
|
|
11
|
+
return Platform.OS === 'android';
|
|
12
|
+
}
|
|
13
|
+
/** @platform android — empty array on every other platform. */
|
|
14
|
+
export async function getNotificationChannelsAsync() {
|
|
15
|
+
if (!isAndroid()) {
|
|
16
|
+
console.debug(ANDROID_ONLY_NOTICE);
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
if (!notificationChannelManager.getNotificationChannelsAsync) {
|
|
20
|
+
throw new UnavailabilityError('Notifications', 'getNotificationChannelsAsync');
|
|
21
|
+
}
|
|
22
|
+
return ((await notificationChannelManager.getNotificationChannelsAsync()) ?? []);
|
|
23
|
+
}
|
|
24
|
+
/** @platform android — `null` on every other platform. */
|
|
25
|
+
export async function getNotificationChannelAsync(channelId) {
|
|
26
|
+
if (!isAndroid()) {
|
|
27
|
+
console.debug(ANDROID_ONLY_NOTICE);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (!notificationChannelManager.getNotificationChannelAsync) {
|
|
31
|
+
throw new UnavailabilityError('Notifications', 'getNotificationChannelAsync');
|
|
32
|
+
}
|
|
33
|
+
return notificationChannelManager.getNotificationChannelAsync(channelId);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates or updates a channel. Only the name and description may change once a channel
|
|
37
|
+
* exists — an Android OS limitation. @platform android — `null` on every other platform.
|
|
38
|
+
*/
|
|
39
|
+
export async function setNotificationChannelAsync(channelId, channel) {
|
|
40
|
+
if (!isAndroid()) {
|
|
41
|
+
console.debug(ANDROID_ONLY_NOTICE);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (!notificationChannelManager.setNotificationChannelAsync) {
|
|
45
|
+
throw new UnavailabilityError('Notifications', 'setNotificationChannelAsync');
|
|
46
|
+
}
|
|
47
|
+
if (channel.importance === AndroidImportance.UNSPECIFIED) {
|
|
48
|
+
console.warn(`[notifications] Channel "${channelId}" importance is UNSPECIFIED, which can error on some Android versions — use AndroidImportance.DEFAULT instead.`);
|
|
49
|
+
}
|
|
50
|
+
return notificationChannelManager.setNotificationChannelAsync(channelId, channel);
|
|
51
|
+
}
|
|
52
|
+
/** @platform android — no-op on every other platform. */
|
|
53
|
+
export async function deleteNotificationChannelAsync(channelId) {
|
|
54
|
+
if (!isAndroid()) {
|
|
55
|
+
console.debug(ANDROID_ONLY_NOTICE);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!notificationChannelManager.deleteNotificationChannelAsync) {
|
|
59
|
+
throw new UnavailabilityError('Notifications', 'deleteNotificationChannelAsync');
|
|
60
|
+
}
|
|
61
|
+
return notificationChannelManager.deleteNotificationChannelAsync(channelId);
|
|
62
|
+
}
|
|
63
|
+
/** @platform android — empty array on every other platform. */
|
|
64
|
+
export async function getNotificationChannelGroupsAsync() {
|
|
65
|
+
if (!isAndroid()) {
|
|
66
|
+
console.debug(ANDROID_ONLY_NOTICE);
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
if (!notificationChannelGroupManager.getNotificationChannelGroupsAsync) {
|
|
70
|
+
throw new UnavailabilityError('Notifications', 'getNotificationChannelGroupsAsync');
|
|
71
|
+
}
|
|
72
|
+
return notificationChannelGroupManager.getNotificationChannelGroupsAsync();
|
|
73
|
+
}
|
|
74
|
+
/** @platform android — `null` on every other platform. */
|
|
75
|
+
export async function getNotificationChannelGroupAsync(groupId) {
|
|
76
|
+
if (!isAndroid()) {
|
|
77
|
+
console.debug(ANDROID_ONLY_NOTICE);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
if (!notificationChannelGroupManager.getNotificationChannelGroupAsync) {
|
|
81
|
+
throw new UnavailabilityError('Notifications', 'getNotificationChannelGroupAsync');
|
|
82
|
+
}
|
|
83
|
+
return notificationChannelGroupManager.getNotificationChannelGroupAsync(groupId);
|
|
84
|
+
}
|
|
85
|
+
/** @platform android — `null` on every other platform. */
|
|
86
|
+
export async function setNotificationChannelGroupAsync(groupId, group) {
|
|
87
|
+
if (!isAndroid()) {
|
|
88
|
+
console.debug(ANDROID_ONLY_NOTICE);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
if (!notificationChannelGroupManager.setNotificationChannelGroupAsync) {
|
|
92
|
+
throw new UnavailabilityError('Notifications', 'setNotificationChannelGroupAsync');
|
|
93
|
+
}
|
|
94
|
+
return notificationChannelGroupManager.setNotificationChannelGroupAsync(groupId, group);
|
|
95
|
+
}
|
|
96
|
+
/** @platform android — no-op on every other platform. */
|
|
97
|
+
export async function deleteNotificationChannelGroupAsync(groupId) {
|
|
98
|
+
if (!isAndroid()) {
|
|
99
|
+
console.debug(ANDROID_ONLY_NOTICE);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (!notificationChannelGroupManager.deleteNotificationChannelGroupAsync) {
|
|
103
|
+
throw new UnavailabilityError('Notifications', 'deleteNotificationChannelGroupAsync');
|
|
104
|
+
}
|
|
105
|
+
return notificationChannelGroupManager.deleteNotificationChannelGroupAsync(groupId);
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=channels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels.js","sourceRoot":"","sources":["../../src/core/channels.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,gGAAgG;AAChG,iGAAiG;AACjG,8FAA8F;AAC9F,8CAA8C;AAC9C,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,iBAAiB,GAKlB,MAAM,SAAS,CAAC;AAEjB,MAAM,mBAAmB,GACvB,sDAAsD,CAAC;AAEzD,SAAS,SAAS;IAChB,OAAO,QAAQ,CAAC,EAAE,KAAK,SAAS,CAAC;AACnC,CAAC;AAED,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,4BAA4B;IAGhD,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QACjB,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC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,SAAS,EAAE,EAAE,CAAC;QACjB,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC,+BAA+B,CAAC,gCAAgC,EAAE,CAAC;QACtE,MAAM,IAAI,mBAAmB,CAC3B,eAAe,EACf,kCAAkC,CACnC,CAAC;IACJ,CAAC;IACD,OAAO,+BAA+B,CAAC,gCAAgC,CACrE,OAAO,EACP,KAAK,CACN,CAAC;AACJ,CAAC;AAED,yDAAyD;AACzD,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,OAAe;IAEf,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC;QACjB,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACnC,OAAO;IACT,CAAC;IACD,IAAI,CAAC,+BAA+B,CAAC,mCAAmC,EAAE,CAAC;QACzE,MAAM,IAAI,mBAAmB,CAC3B,eAAe,EACf,qCAAqC,CACtC,CAAC;IACJ,CAAC;IACD,OAAO,+BAA+B,CAAC,mCAAmC,CACxE,OAAO,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type EventSubscription } from 'expo-modules-core';
|
|
2
|
+
import type { INotification, INotificationResponse } from './types';
|
|
3
|
+
export declare const DEFAULT_ACTION_IDENTIFIER = "expo.modules.notifications.actions.DEFAULT";
|
|
4
|
+
/** Fires whenever a notification is received while the app is running. */
|
|
5
|
+
export declare function addNotificationReceivedListener(listener: (event: INotification) => void): EventSubscription;
|
|
6
|
+
/**
|
|
7
|
+
* Fires whenever the server (Firebase Cloud Messaging) dropped queued notifications.
|
|
8
|
+
* @platform android
|
|
9
|
+
*/
|
|
10
|
+
export declare function addNotificationsDroppedListener(listener: () => void): EventSubscription;
|
|
11
|
+
/** Fires whenever the user interacts with a notification (e.g. taps it). */
|
|
12
|
+
export declare function addNotificationResponseReceivedListener(listener: (event: INotificationResponse) => void): EventSubscription;
|
|
13
|
+
/**
|
|
14
|
+
* The most recently received notification response, or `null` if the app was not opened by
|
|
15
|
+
* one.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getLastNotificationResponse(): INotificationResponse | null;
|
|
18
|
+
/**
|
|
19
|
+
* Clears the last notification response, e.g. once its route has been handled and should not
|
|
20
|
+
* be re-applied on the next read.
|
|
21
|
+
*/
|
|
22
|
+
export declare function clearLastNotificationResponse(): void;
|
|
23
|
+
/** Fires whenever `clearLastNotificationResponse` runs. */
|
|
24
|
+
export declare function addNotificationResponseClearedListener(listener: () => void): EventSubscription;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Ported from expo-notifications @ sdk-57's NotificationsEmitter.ts.
|
|
2
|
+
import { LegacyEventEmitter, UnavailabilityError, } from 'expo-modules-core';
|
|
3
|
+
import { dlog } from '@symbiote-native/engine';
|
|
4
|
+
import { notificationsEmitterModule } from './native-modules';
|
|
5
|
+
import { mapNotification, mapNotificationResponse } from './utils';
|
|
6
|
+
const emitter = new LegacyEventEmitter(notificationsEmitterModule);
|
|
7
|
+
const RECEIVED_EVENT = 'onDidReceiveNotification';
|
|
8
|
+
const DROPPED_EVENT = 'onNotificationsDeleted';
|
|
9
|
+
const RESPONSE_RECEIVED_EVENT = 'onDidReceiveNotificationResponse';
|
|
10
|
+
const RESPONSE_CLEARED_EVENT = 'onDidClearNotificationResponse';
|
|
11
|
+
export const DEFAULT_ACTION_IDENTIFIER = 'expo.modules.notifications.actions.DEFAULT';
|
|
12
|
+
/** Fires whenever a notification is received while the app is running. */
|
|
13
|
+
export function addNotificationReceivedListener(listener) {
|
|
14
|
+
return emitter.addListener(RECEIVED_EVENT, notification => {
|
|
15
|
+
dlog(() => `[notifications] received ${notification.request.identifier}`);
|
|
16
|
+
listener(mapNotification(notification));
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Fires whenever the server (Firebase Cloud Messaging) dropped queued notifications.
|
|
21
|
+
* @platform android
|
|
22
|
+
*/
|
|
23
|
+
export function addNotificationsDroppedListener(listener) {
|
|
24
|
+
return emitter.addListener(DROPPED_EVENT, listener);
|
|
25
|
+
}
|
|
26
|
+
/** Fires whenever the user interacts with a notification (e.g. taps it). */
|
|
27
|
+
export function addNotificationResponseReceivedListener(listener) {
|
|
28
|
+
return emitter.addListener(RESPONSE_RECEIVED_EVENT, response => {
|
|
29
|
+
dlog(() => `[notifications] response ${response.actionIdentifier} for ${response.notification.request.identifier}`);
|
|
30
|
+
listener(mapNotificationResponse(response));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The most recently received notification response, or `null` if the app was not opened by
|
|
35
|
+
* one.
|
|
36
|
+
*/
|
|
37
|
+
export function getLastNotificationResponse() {
|
|
38
|
+
if (!notificationsEmitterModule.getLastNotificationResponse) {
|
|
39
|
+
throw new UnavailabilityError('Notifications', 'getLastNotificationResponse');
|
|
40
|
+
}
|
|
41
|
+
const response = notificationsEmitterModule.getLastNotificationResponse();
|
|
42
|
+
return response ? mapNotificationResponse(response) : response;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Clears the last notification response, e.g. once its route has been handled and should not
|
|
46
|
+
* be re-applied on the next read.
|
|
47
|
+
*/
|
|
48
|
+
export function clearLastNotificationResponse() {
|
|
49
|
+
if (!notificationsEmitterModule.clearLastNotificationResponse) {
|
|
50
|
+
throw new UnavailabilityError('Notifications', 'clearLastNotificationResponse');
|
|
51
|
+
}
|
|
52
|
+
notificationsEmitterModule.clearLastNotificationResponse();
|
|
53
|
+
emitter.emit(RESPONSE_CLEARED_EVENT, []);
|
|
54
|
+
}
|
|
55
|
+
/** Fires whenever `clearLastNotificationResponse` runs. */
|
|
56
|
+
export function addNotificationResponseClearedListener(listener) {
|
|
57
|
+
return emitter.addListener(RESPONSE_CLEARED_EVENT, listener);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=emitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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AQ,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,CAC1G,CAAC;QACF,QAAQ,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9C,CAAC,CACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC,0BAA0B,CAAC,2BAA2B,EAAE,CAAC;QAC5D,MAAM,IAAI,mBAAmB,CAC3B,eAAe,EACf,6BAA6B,CAC9B,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,0BAA0B,CAAC,2BAA2B,EAAE,CAAC;IAC1E,OAAO,QAAQ,CAAC,CAAC,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,6BAA6B;IAC3C,IAAI,CAAC,0BAA0B,CAAC,6BAA6B,EAAE,CAAC;QAC9D,MAAM,IAAI,mBAAmB,CAC3B,eAAe,EACf,+BAA+B,CAChC,CAAC;IACJ,CAAC;IACD,0BAA0B,CAAC,6BAA6B,EAAE,CAAC;IAC3D,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,sCAAsC,CACpD,QAAoB;IAEpB,OAAO,OAAO,CAAC,WAAW,CAAO,sBAAsB,EAAE,QAAQ,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CodedError } from 'expo-modules-core';
|
|
2
|
+
import type { INotification, INotificationHandler } from './types';
|
|
3
|
+
export declare class NotificationTimeoutError extends CodedError {
|
|
4
|
+
info: {
|
|
5
|
+
notification: INotification;
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
constructor(notificationId: string, notification: INotification);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Sets the callback deciding whether/how a notification received while the app is running
|
|
12
|
+
* should be shown. Must respond within 3 seconds or the notification is discarded. Passing
|
|
13
|
+
* `null` clears the handler — the default (no handler) is to not show anything.
|
|
14
|
+
*/
|
|
15
|
+
export declare function setNotificationHandler(handler: INotificationHandler | null): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Ported from expo-notifications @ sdk-57's NotificationsHandler.ts.
|
|
2
|
+
import { CodedError, LegacyEventEmitter, } from 'expo-modules-core';
|
|
3
|
+
import { dlog } from '@symbiote-native/engine';
|
|
4
|
+
import { notificationsHandlerModule } from './native-modules';
|
|
5
|
+
import { mapNotification } from './utils';
|
|
6
|
+
export class NotificationTimeoutError extends CodedError {
|
|
7
|
+
info;
|
|
8
|
+
constructor(notificationId, notification) {
|
|
9
|
+
super('ERR_NOTIFICATION_TIMEOUT', `Notification handling timed out for ID ${notificationId}.`);
|
|
10
|
+
this.info = { id: notificationId, notification };
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const emitter = new LegacyEventEmitter(notificationsHandlerModule);
|
|
14
|
+
const HANDLE_EVENT = 'onHandleNotification';
|
|
15
|
+
const HANDLE_TIMEOUT_EVENT = 'onHandleNotificationTimeout';
|
|
16
|
+
let handleSubscription = null;
|
|
17
|
+
let handleTimeoutSubscription = null;
|
|
18
|
+
/**
|
|
19
|
+
* Sets the callback deciding whether/how a notification received while the app is running
|
|
20
|
+
* should be shown. Must respond within 3 seconds or the notification is discarded. Passing
|
|
21
|
+
* `null` clears the handler — the default (no handler) is to not show anything.
|
|
22
|
+
*/
|
|
23
|
+
export function setNotificationHandler(handler) {
|
|
24
|
+
handleSubscription?.remove();
|
|
25
|
+
handleSubscription = null;
|
|
26
|
+
handleTimeoutSubscription?.remove();
|
|
27
|
+
handleTimeoutSubscription = null;
|
|
28
|
+
if (!handler)
|
|
29
|
+
return;
|
|
30
|
+
dlog('[notifications] setNotificationHandler');
|
|
31
|
+
handleSubscription = emitter.addListener(HANDLE_EVENT, async ({ id, notification }) => {
|
|
32
|
+
if (!notificationsHandlerModule.handleNotificationAsync) {
|
|
33
|
+
handler.handleError?.(id, new Error('handleNotificationAsync is not available on this platform'));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const behavior = await handler.handleNotification(mapNotification(notification));
|
|
38
|
+
if (behavior.shouldShowAlert) {
|
|
39
|
+
console.warn('[notifications] `shouldShowAlert` is deprecated — specify `shouldShowBanner` and/or `shouldShowList` instead.');
|
|
40
|
+
}
|
|
41
|
+
await notificationsHandlerModule.handleNotificationAsync(id, behavior);
|
|
42
|
+
dlog(() => `[notifications] handled ${id}`);
|
|
43
|
+
handler.handleSuccess?.(id);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
handler.handleError?.(id, error instanceof Error ? error : new Error(String(error)));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
handleTimeoutSubscription = emitter.addListener(HANDLE_TIMEOUT_EVENT, ({ id, notification }) => handler.handleError?.(id, new NotificationTimeoutError(id, mapNotification(notification))));
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/core/handler.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,UAAU,EACV,kBAAkB,GAEnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAM9D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,OAAO,wBAAyB,SAAQ,UAAU;IAC7C,IAAI,CAA8C;IAC3D,YAAY,cAAsB,EAAE,YAA2B;QAC7D,KAAK,CACH,0BAA0B,EAC1B,0CAA0C,cAAc,GAAG,CAC5D,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,EAAE,EA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