@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,12 @@
|
|
|
1
|
+
export { getPermissionsAsync, requestPermissionsAsync } from './permissions';
|
|
2
|
+
export { addPushTokenListener, getDevicePushTokenAsync, getExpoPushTokenAsync, setAutoServerRegistrationEnabledAsync, subscribeToTopicAsync, unregisterForNotificationsAsync, unsubscribeFromTopicAsync, type IPushTokenListener, } from './tokens';
|
|
3
|
+
export { dismissAllNotificationsAsync, dismissNotificationAsync, getPresentedNotificationsAsync, } from './presenter';
|
|
4
|
+
export { getBadgeCountAsync, setBadgeCountAsync } from './badge';
|
|
5
|
+
export { cancelAllScheduledNotificationsAsync, cancelScheduledNotificationAsync, getAllScheduledNotificationsAsync, getNextTriggerDateAsync, scheduleNotificationAsync, } from './scheduler';
|
|
6
|
+
export { deleteNotificationCategoryAsync, getNotificationCategoriesAsync, setNotificationCategoryAsync, } from './categories';
|
|
7
|
+
export { deleteNotificationChannelAsync, deleteNotificationChannelGroupAsync, getNotificationChannelAsync, getNotificationChannelGroupAsync, getNotificationChannelGroupsAsync, getNotificationChannelsAsync, setNotificationChannelAsync, setNotificationChannelGroupAsync, } from './channels';
|
|
8
|
+
export { NotificationTimeoutError, setNotificationHandler } from './handler';
|
|
9
|
+
export { DEFAULT_ACTION_IDENTIFIER, addNotificationReceivedListener, addNotificationResponseClearedListener, addNotificationResponseReceivedListener, addNotificationsDroppedListener, clearLastNotificationResponse, getLastNotificationResponse, } from './emitter';
|
|
10
|
+
export { BackgroundNotificationTaskResult, registerTaskAsync, unregisterTaskAsync, } from './background-task';
|
|
11
|
+
export type { IAudioAttributes, IAudioAttributesInput, IBeaconRegion, ICalendarNotificationTrigger, ICalendarTriggerInput, IChannelAwareTriggerInput, ICircularRegion, IDailyNotificationTrigger, IDailyTriggerInput, IDateTriggerInput, IDevicePushToken, IExpoPushToken, IExpoPushTokenOptions, IFirebaseRemoteMessage, IFirebaseRemoteMessageNotification, IInterruptionLevel, IIosNotificationPermissionsRequest, ILocationNotificationTrigger, IMaybeNotificationResponse, IMonthlyNotificationTrigger, IMonthlyTriggerInput, INativeCalendarTriggerInput, INativeChannelAwareTriggerInput, INativeDailyTriggerInput, INativeDateTriggerInput, INativeDevicePushToken, INativeMonthlyTriggerInput, INativeNotificationTriggerInput, INativeTimeIntervalTriggerInput, INativeWeeklyTriggerInput, INativeYearlyTriggerInput, INotification, INotificationAction, INotificationBehavior, INotificationCategory, INotificationCategoryOptions, INotificationChannel, INotificationChannelGroup, INotificationChannelGroupInput, INotificationChannelInput, INotificationContent, INotificationContentAndroid, INotificationContentAttachmentIos, INotificationContentInput, INotificationContentIos, INotificationHandler, INotificationPermissionsRequest, INotificationPermissionsStatus, INotificationRequest, INotificationRequestInput, INotificationResponse, INotificationTaskPayload, INotificationTrigger, INotificationTriggerInput, IPushNotificationTrigger, IRegion, ISchedulableNotificationTriggerInput, ITimeIntervalNotificationTrigger, ITimeIntervalTriggerInput, IUnknownNotificationTrigger, IWeeklyNotificationTrigger, IWeeklyTriggerInput, IYearlyNotificationTrigger, IYearlyTriggerInput, PermissionExpiration, PermissionResponse, } from './types';
|
|
12
|
+
export { AndroidAudioContentType, AndroidAudioUsage, AndroidImportance, AndroidNotificationPriority, AndroidNotificationVisibility, IosAlertStyle, IosAllowsPreviews, IosAuthorizationStatus, PermissionStatus, SchedulableTriggerInputTypes, } from './types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { getPermissionsAsync, requestPermissionsAsync } from './permissions';
|
|
2
|
+
export { addPushTokenListener, getDevicePushTokenAsync, getExpoPushTokenAsync, setAutoServerRegistrationEnabledAsync, subscribeToTopicAsync, unregisterForNotificationsAsync, unsubscribeFromTopicAsync, } from './tokens';
|
|
3
|
+
export { dismissAllNotificationsAsync, dismissNotificationAsync, getPresentedNotificationsAsync, } from './presenter';
|
|
4
|
+
export { getBadgeCountAsync, setBadgeCountAsync } from './badge';
|
|
5
|
+
export { cancelAllScheduledNotificationsAsync, cancelScheduledNotificationAsync, getAllScheduledNotificationsAsync, getNextTriggerDateAsync, scheduleNotificationAsync, } from './scheduler';
|
|
6
|
+
export { deleteNotificationCategoryAsync, getNotificationCategoriesAsync, setNotificationCategoryAsync, } from './categories';
|
|
7
|
+
export { deleteNotificationChannelAsync, deleteNotificationChannelGroupAsync, getNotificationChannelAsync, getNotificationChannelGroupAsync, getNotificationChannelGroupsAsync, getNotificationChannelsAsync, setNotificationChannelAsync, setNotificationChannelGroupAsync, } from './channels';
|
|
8
|
+
export { NotificationTimeoutError, setNotificationHandler } from './handler';
|
|
9
|
+
export { DEFAULT_ACTION_IDENTIFIER, addNotificationReceivedListener, addNotificationResponseClearedListener, addNotificationResponseReceivedListener, addNotificationsDroppedListener, clearLastNotificationResponse, getLastNotificationResponse, } from './emitter';
|
|
10
|
+
export { BackgroundNotificationTaskResult, registerTaskAsync, unregisterTaskAsync, } from './background-task';
|
|
11
|
+
export { AndroidAudioContentType, AndroidAudioUsage, AndroidImportance, AndroidNotificationPriority, AndroidNotificationVisibility, IosAlertStyle, IosAllowsPreviews, IosAuthorizationStatus, PermissionStatus, SchedulableTriggerInputTypes, } from './types';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7E,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,qCAAqC,EACrC,qBAAqB,EACrB,+BAA+B,EAC/B,yBAAyB,GAE1B,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEjE,OAAO,EACL,oCAAoC,EACpC,gCAAgC,EAChC,iCAAiC,EACjC,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,8BAA8B,EAC9B,mCAAmC,EACnC,2BAA2B,EAC3B,gCAAgC,EAChC,iCAAiC,EACjC,4BAA4B,EAC5B,2BAA2B,EAC3B,gCAAgC,GACjC,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAE7E,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAC/B,sCAAsC,EACtC,uCAAuC,EACvC,+BAA+B,EAC/B,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,gCAAgC,EAChC,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAsE3B,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,2BAA2B,EAC3B,6BAA6B,EAC7B,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { NativeModule, type EventSubscription, type ProxyNativeModule } from 'expo-modules-core';
|
|
2
|
+
import type { INotification, INotificationAction, INotificationBehavior, INotificationCategory, INotificationCategoryOptions, INotificationChannel, INotificationChannelGroup, INotificationChannelGroupInput, INotificationChannelInput, INotificationContentInput, INotificationPermissionsRequest, INotificationPermissionsStatus, INotificationRequest, INotificationResponse, INativeNotificationTriggerInput } from './types';
|
|
3
|
+
export interface INativePermissionsModule extends ProxyNativeModule {
|
|
4
|
+
getPermissionsAsync?(): Promise<INotificationPermissionsStatus>;
|
|
5
|
+
requestPermissionsAsync?(request: INotificationPermissionsRequest[keyof INotificationPermissionsRequest]): Promise<INotificationPermissionsStatus>;
|
|
6
|
+
}
|
|
7
|
+
export declare const notificationPermissionsModule: INativePermissionsModule;
|
|
8
|
+
export type IPushTokenManagerEvents = {
|
|
9
|
+
onDevicePushToken: (params: {
|
|
10
|
+
devicePushToken: string;
|
|
11
|
+
}) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare class PushTokenManagerModule extends NativeModule<IPushTokenManagerEvents> {
|
|
14
|
+
getDevicePushTokenAsync?(): Promise<string>;
|
|
15
|
+
unregisterForNotificationsAsync?(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare const pushTokenManager: PushTokenManagerModule;
|
|
18
|
+
export interface INativeTopicSubscriptionModule extends ProxyNativeModule {
|
|
19
|
+
subscribeToTopicAsync?(topic: string): Promise<null>;
|
|
20
|
+
unsubscribeFromTopicAsync?(topic: string): Promise<null>;
|
|
21
|
+
}
|
|
22
|
+
export declare const topicSubscriptionModule: INativeTopicSubscriptionModule;
|
|
23
|
+
export interface INativeServerRegistrationModule extends ProxyNativeModule {
|
|
24
|
+
getInstallationIdAsync?(): Promise<string>;
|
|
25
|
+
getRegistrationInfoAsync?(): Promise<string | undefined | null>;
|
|
26
|
+
setRegistrationInfoAsync?(registrationInfo: string | null): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export declare const serverRegistrationModule: INativeServerRegistrationModule;
|
|
29
|
+
export interface INativePresenterModule extends ProxyNativeModule {
|
|
30
|
+
getPresentedNotificationsAsync?(): Promise<INotification[]>;
|
|
31
|
+
dismissNotificationAsync?(identifier: string): Promise<void>;
|
|
32
|
+
dismissAllNotificationsAsync?(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export declare const notificationPresenterModule: INativePresenterModule;
|
|
35
|
+
export interface INativeBadgeModule extends ProxyNativeModule {
|
|
36
|
+
getBadgeCountAsync?(): Promise<number>;
|
|
37
|
+
setBadgeCountAsync?(badgeCount: number): Promise<boolean>;
|
|
38
|
+
}
|
|
39
|
+
export declare const badgeModule: INativeBadgeModule;
|
|
40
|
+
export interface INativeSchedulerModule extends ProxyNativeModule {
|
|
41
|
+
getAllScheduledNotificationsAsync?(): Promise<INotificationRequest[]>;
|
|
42
|
+
scheduleNotificationAsync?(identifier: string, content: INotificationContentInput, trigger: INativeNotificationTriggerInput): Promise<string>;
|
|
43
|
+
cancelScheduledNotificationAsync?(identifier: string): Promise<void>;
|
|
44
|
+
cancelAllScheduledNotificationsAsync?(): Promise<void>;
|
|
45
|
+
getNextTriggerDateAsync?(trigger: INativeNotificationTriggerInput): Promise<number>;
|
|
46
|
+
}
|
|
47
|
+
export declare const notificationScheduler: INativeSchedulerModule;
|
|
48
|
+
export interface INativeCategoriesModule extends ProxyNativeModule {
|
|
49
|
+
getNotificationCategoriesAsync?(): Promise<INotificationCategory[]>;
|
|
50
|
+
setNotificationCategoryAsync?(identifier: string, actions: INotificationAction[], options?: INotificationCategoryOptions): Promise<INotificationCategory>;
|
|
51
|
+
deleteNotificationCategoryAsync?(identifier: string): Promise<boolean>;
|
|
52
|
+
}
|
|
53
|
+
export declare const notificationCategoriesModule: INativeCategoriesModule;
|
|
54
|
+
export interface INativeChannelManagerModule extends ProxyNativeModule {
|
|
55
|
+
getNotificationChannelsAsync?(): Promise<INotificationChannel[] | null>;
|
|
56
|
+
getNotificationChannelAsync?(channelId: string): Promise<INotificationChannel | null>;
|
|
57
|
+
setNotificationChannelAsync?(channelId: string, channel: INotificationChannelInput): Promise<INotificationChannel | null>;
|
|
58
|
+
deleteNotificationChannelAsync?(channelId: string): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
export declare const notificationChannelManager: INativeChannelManagerModule;
|
|
61
|
+
export interface INativeChannelGroupManagerModule extends ProxyNativeModule {
|
|
62
|
+
getNotificationChannelGroupsAsync?(): Promise<INotificationChannelGroup[]>;
|
|
63
|
+
getNotificationChannelGroupAsync?(groupId: string): Promise<INotificationChannelGroup | null>;
|
|
64
|
+
setNotificationChannelGroupAsync?(groupId: string, group: INotificationChannelGroupInput): Promise<INotificationChannelGroup | null>;
|
|
65
|
+
deleteNotificationChannelGroupAsync?(groupId: string): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
export declare const notificationChannelGroupManager: INativeChannelGroupManagerModule;
|
|
68
|
+
export interface INativeHandlerModule extends ProxyNativeModule {
|
|
69
|
+
handleNotificationAsync?(notificationId: string, behavior: INotificationBehavior): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
export declare const notificationsHandlerModule: INativeHandlerModule;
|
|
72
|
+
export interface INativeEmitterModule extends ProxyNativeModule {
|
|
73
|
+
getLastNotificationResponse?(): INotificationResponse | null;
|
|
74
|
+
clearLastNotificationResponse?(): void;
|
|
75
|
+
}
|
|
76
|
+
export declare const notificationsEmitterModule: INativeEmitterModule;
|
|
77
|
+
export interface INativeBackgroundTasksModule extends ProxyNativeModule {
|
|
78
|
+
registerTaskAsync(taskName: string): Promise<null>;
|
|
79
|
+
unregisterTaskAsync(taskName: string): Promise<null>;
|
|
80
|
+
}
|
|
81
|
+
export declare const backgroundNotificationTasksModule: INativeBackgroundTasksModule;
|
|
82
|
+
export type { EventSubscription };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Resolves expo-notifications' 13 native modules by the same names their own
|
|
2
|
+
// `<Module>.native.ts` one-liners use (`.vendors/expo` @ origin/sdk-57,
|
|
3
|
+
// `packages/expo-notifications/src/*.native.ts`) — see this package's `native-link.json` for
|
|
4
|
+
// the matching Android Kotlin `importPath`/`className` for each.
|
|
5
|
+
//
|
|
6
|
+
// Every method is declared optional so a call site checks availability itself and throws an
|
|
7
|
+
// `UnavailabilityError`, matching upstream's own per-platform capability checks rather than
|
|
8
|
+
// assuming every native module implements its whole surface — same pattern
|
|
9
|
+
// packages/task-manager/src/core/native-module.ts and packages/local-auth use.
|
|
10
|
+
import { NativeModule, Platform, requireNativeModule, requireOptionalNativeModule, } from 'expo-modules-core';
|
|
11
|
+
export const notificationPermissionsModule = requireNativeModule('ExpoNotificationPermissionsModule');
|
|
12
|
+
export class PushTokenManagerModule extends NativeModule {
|
|
13
|
+
}
|
|
14
|
+
export const pushTokenManager = requireNativeModule('ExpoPushTokenManager');
|
|
15
|
+
export const topicSubscriptionModule = Platform.OS === 'android'
|
|
16
|
+
? requireNativeModule('ExpoTopicSubscriptionModule')
|
|
17
|
+
: (requireOptionalNativeModule('ExpoTopicSubscriptionModule') ?? {});
|
|
18
|
+
export const serverRegistrationModule = requireNativeModule('NotificationsServerRegistrationModule');
|
|
19
|
+
export const notificationPresenterModule = requireNativeModule('ExpoNotificationPresenter');
|
|
20
|
+
export const badgeModule = requireNativeModule('ExpoBadgeModule');
|
|
21
|
+
export const notificationScheduler = requireNativeModule('ExpoNotificationScheduler');
|
|
22
|
+
export const notificationCategoriesModule = requireNativeModule('ExpoNotificationCategoriesModule');
|
|
23
|
+
// Android-only concept, same as topicSubscriptionModule above — a hard requireNativeModule
|
|
24
|
+
// here throws at import time on iOS before any screen code runs.
|
|
25
|
+
export const notificationChannelManager = Platform.OS === 'android'
|
|
26
|
+
? requireNativeModule('ExpoNotificationChannelManager')
|
|
27
|
+
: (requireOptionalNativeModule('ExpoNotificationChannelManager') ?? {});
|
|
28
|
+
export const notificationChannelGroupManager = Platform.OS === 'android'
|
|
29
|
+
? requireNativeModule('ExpoNotificationChannelGroupManager')
|
|
30
|
+
: (requireOptionalNativeModule('ExpoNotificationChannelGroupManager') ?? {});
|
|
31
|
+
export const notificationsHandlerModule = requireNativeModule('ExpoNotificationsHandlerModule');
|
|
32
|
+
export const notificationsEmitterModule = requireNativeModule('ExpoNotificationsEmitter');
|
|
33
|
+
export const backgroundNotificationTasksModule = requireNativeModule('ExpoBackgroundNotificationTasksModule');
|
|
34
|
+
//# sourceMappingURL=native-modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-modules.js","sourceRoot":"","sources":["../../src/core/native-modules.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,wEAAwE;AACxE,6FAA6F;AAC7F,iEAAiE;AACjE,EAAE;AACF,4FAA4F;AAC5F,4FAA4F;AAC5F,2EAA2E;AAC3E,+EAA+E;A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,CAC1B,qCAAqC,CACtC,IAAI,EAAE,CAAC,CAAC;AASf,MAAM,CAAC,MAAM,0BAA0B,GACrC,mBAAmB,CAAuB,gCAAgC,CAAC,CAAC;AAM9E,MAAM,CAAC,MAAM,0BAA0B,GACrC,mBAAmB,CAAuB,0BAA0B,CAAC,CAAC;AAOxE,MAAM,CAAC,MAAM,iCAAiC,GAC5C,mBAAmB,CACjB,uCAAuC,CACxC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { INotificationPermissionsRequest, INotificationPermissionsStatus } from './types';
|
|
2
|
+
/** Checks (without prompting) whether the app can currently display alerts, play sounds, etc. */
|
|
3
|
+
export declare function getPermissionsAsync(): Promise<INotificationPermissionsStatus>;
|
|
4
|
+
/**
|
|
5
|
+
* Prompts the user for notification permissions. Defaults to alerts + badge + sound on iOS —
|
|
6
|
+
* on Android every permission is already granted and there is nothing to prompt for.
|
|
7
|
+
*/
|
|
8
|
+
export declare function requestPermissionsAsync(permissions?: INotificationPermissionsRequest): Promise<INotificationPermissionsStatus>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Ported from expo-notifications @ sdk-57's NotificationPermissions.ts.
|
|
2
|
+
import { Platform, UnavailabilityError } from 'expo-modules-core';
|
|
3
|
+
import { dlog } from '@symbiote-native/engine';
|
|
4
|
+
import { notificationPermissionsModule } from './native-modules';
|
|
5
|
+
/** Checks (without prompting) whether the app can currently display alerts, play sounds, etc. */
|
|
6
|
+
export async function getPermissionsAsync() {
|
|
7
|
+
if (!notificationPermissionsModule.getPermissionsAsync) {
|
|
8
|
+
throw new UnavailabilityError('Notifications', 'getPermissionsAsync');
|
|
9
|
+
}
|
|
10
|
+
const result = await notificationPermissionsModule.getPermissionsAsync();
|
|
11
|
+
dlog(() => `[notifications] getPermissionsAsync -> ${result.status}`);
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Prompts the user for notification permissions. Defaults to alerts + badge + sound on iOS —
|
|
16
|
+
* on Android every permission is already granted and there is nothing to prompt for.
|
|
17
|
+
*/
|
|
18
|
+
export async function requestPermissionsAsync(permissions) {
|
|
19
|
+
if (!notificationPermissionsModule.requestPermissionsAsync) {
|
|
20
|
+
throw new UnavailabilityError('Notifications', 'requestPermissionsAsync');
|
|
21
|
+
}
|
|
22
|
+
const requested = permissions ?? {
|
|
23
|
+
ios: { allowAlert: true, allowBadge: true, allowSound: true },
|
|
24
|
+
};
|
|
25
|
+
const platformRequest = requested[Platform.OS];
|
|
26
|
+
dlog('[notifications] requestPermissionsAsync');
|
|
27
|
+
const result = await notificationPermissionsModule.requestPermissionsAsync(platformRequest);
|
|
28
|
+
dlog(() => `[notifications] requestPermissionsAsync -> ${result.status}`);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/core/permissions.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAMjE,iGAAiG;AACjG,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC,6BAA6B,CAAC,mBAAmB,EAAE,CAAC;QACvD,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,qBAAqB,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,6BAA6B,CAAC,mBAAmB,EAAE,CAAC;IACzE,IAAI,CAAC,GAAG,EAAE,CAAC,0CAA0C,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,WAA6C;IAE7C,IAAI,CAAC,6BAA6B,CAAC,uBAAuB,EAAE,CAAC;QAC3D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,SAAS,GAAoC,WAAW,IAAI;QAChE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE;KAC9D,CAAC;IACF,MAAM,eAAe,GACnB,SAAS,CAAC,QAAQ,CAAC,EAA2C,CAAC,CAAC;IAElE,IAAI,CAAC,yCAAyC,CAAC,CAAC;IAChD,MAAM,MAAM,GACV,MAAM,6BAA6B,CAAC,uBAAuB,CACzD,eAAe,CAChB,CAAC;IACJ,IAAI,CAAC,GAAG,EAAE,CAAC,8CAA8C,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { INotification } from './types';
|
|
2
|
+
/** Notifications currently in the tray (Notification Center). Empty on Android below API 23. */
|
|
3
|
+
export declare function getPresentedNotificationsAsync(): Promise<INotification[]>;
|
|
4
|
+
/** Removes one notification from the tray by its identifier. */
|
|
5
|
+
export declare function dismissNotificationAsync(notificationIdentifier: string): Promise<void>;
|
|
6
|
+
/** Removes every one of this app's notifications from the tray. */
|
|
7
|
+
export declare function dismissAllNotificationsAsync(): Promise<void>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Ported from expo-notifications @ sdk-57's getPresentedNotificationsAsync.ts,
|
|
2
|
+
// dismissNotificationAsync.ts, dismissAllNotificationsAsync.ts.
|
|
3
|
+
import { UnavailabilityError } from 'expo-modules-core';
|
|
4
|
+
import { notificationPresenterModule } from './native-modules';
|
|
5
|
+
import { mapNotification } from './utils';
|
|
6
|
+
/** Notifications currently in the tray (Notification Center). Empty on Android below API 23. */
|
|
7
|
+
export async function getPresentedNotificationsAsync() {
|
|
8
|
+
if (!notificationPresenterModule.getPresentedNotificationsAsync) {
|
|
9
|
+
throw new UnavailabilityError('Notifications', 'getPresentedNotificationsAsync');
|
|
10
|
+
}
|
|
11
|
+
const notifications = await notificationPresenterModule.getPresentedNotificationsAsync();
|
|
12
|
+
return notifications.map(mapNotification);
|
|
13
|
+
}
|
|
14
|
+
/** Removes one notification from the tray by its identifier. */
|
|
15
|
+
export async function dismissNotificationAsync(notificationIdentifier) {
|
|
16
|
+
if (!notificationPresenterModule.dismissNotificationAsync) {
|
|
17
|
+
throw new UnavailabilityError('Notifications', 'dismissNotificationAsync');
|
|
18
|
+
}
|
|
19
|
+
return notificationPresenterModule.dismissNotificationAsync(notificationIdentifier);
|
|
20
|
+
}
|
|
21
|
+
/** Removes every one of this app's notifications from the tray. */
|
|
22
|
+
export async function dismissAllNotificationsAsync() {
|
|
23
|
+
if (!notificationPresenterModule.dismissAllNotificationsAsync) {
|
|
24
|
+
throw new UnavailabilityError('Notifications', 'dismissAllNotificationsAsync');
|
|
25
|
+
}
|
|
26
|
+
return notificationPresenterModule.dismissAllNotificationsAsync();
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=presenter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presenter.js","sourceRoot":"","sources":["../../src/core/presenter.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,gEAAgE;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,gGAAgG;AAChG,MAAM,CAAC,KAAK,UAAU,8BAA8B;IAGlD,IAAI,CAAC,2BAA2B,CAAC,8BAA8B,EAAE,CAAC;QAChE,MAAM,IAAI,mBAAmB,CAC3B,eAAe,EACf,gCAAgC,CACjC,CAAC;IACJ,CAAC;IACD,MAAM,aAAa,GACjB,MAAM,2BAA2B,CAAC,8BAA8B,EAAE,CAAC;IACrE,OAAO,aAAa,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAC5C,CAAC;AAED,gEAAgE;AAChE,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,sBAA8B;IAE9B,IAAI,CAAC,2BAA2B,CAAC,wBAAwB,EAAE,CAAC;QAC1D,MAAM,IAAI,mBAAmB,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,2BAA2B,CAAC,wBAAwB,CACzD,sBAAsB,CACvB,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,KAAK,UAAU,4BAA4B;IAChD,IAAI,CAAC,2BAA2B,CAAC,4BAA4B,EAAE,CAAC;QAC9D,MAAM,IAAI,mBAAmB,CAC3B,eAAe,EACf,8BAA8B,CAC/B,CAAC;IACJ,CAAC;IACD,OAAO,2BAA2B,CAAC,4BAA4B,EAAE,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type INativeNotificationTriggerInput, type INotificationRequest, type INotificationRequestInput, type INotificationTriggerInput, type ISchedulableNotificationTriggerInput } from './types';
|
|
2
|
+
/** Translates a public `INotificationTriggerInput` into the shape native expects. */
|
|
3
|
+
export declare function parseTrigger(trigger: INotificationTriggerInput): INativeNotificationTriggerInput;
|
|
4
|
+
/** Fetches every notification currently scheduled for future delivery. */
|
|
5
|
+
export declare function getAllScheduledNotificationsAsync(): Promise<INotificationRequest[]>;
|
|
6
|
+
/** Schedules a notification. Returns the identifier used to cancel it later. */
|
|
7
|
+
export declare function scheduleNotificationAsync(request: INotificationRequestInput): Promise<string>;
|
|
8
|
+
/** Cancels one scheduled notification by its identifier. */
|
|
9
|
+
export declare function cancelScheduledNotificationAsync(identifier: string): Promise<void>;
|
|
10
|
+
/** Cancels every scheduled notification. */
|
|
11
|
+
export declare function cancelAllScheduledNotificationsAsync(): Promise<void>;
|
|
12
|
+
/** The next Unix timestamp (ms) a schedulable trigger would fire at, or `null` if never. */
|
|
13
|
+
export declare function getNextTriggerDateAsync(trigger: ISchedulableNotificationTriggerInput): Promise<number | null>;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Ported from expo-notifications @ sdk-57's scheduleNotificationAsync.ts,
|
|
2
|
+
// getAllScheduledNotificationsAsync.ts, cancelScheduledNotificationAsync.ts,
|
|
3
|
+
// cancelAllScheduledNotificationsAsync.ts, getNextTriggerDateAsync.ts.
|
|
4
|
+
import { Platform, UnavailabilityError } from 'expo-modules-core';
|
|
5
|
+
import { dlog } from '@symbiote-native/engine';
|
|
6
|
+
import { notificationScheduler } from './native-modules';
|
|
7
|
+
import { SchedulableTriggerInputTypes, } from './types';
|
|
8
|
+
import { hasValidTriggerObject, mapNotificationRequest } from './utils';
|
|
9
|
+
function uuid() {
|
|
10
|
+
// Same fallback expo-modules-core's own `uuid.v4()` boils down to on native — a real RFC4122
|
|
11
|
+
// v4 id, no extra dependency for one call site.
|
|
12
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, char => {
|
|
13
|
+
const random = (Math.random() * 16) | 0;
|
|
14
|
+
const value = char === 'x' ? random : (random & 0x3) | 0x8;
|
|
15
|
+
return value.toString(16);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function daysInMonth(month, year) {
|
|
19
|
+
return new Date(year ?? 2000, month + 1, 0).getDate();
|
|
20
|
+
}
|
|
21
|
+
function validateDateComponents(trigger, components) {
|
|
22
|
+
for (const component of components) {
|
|
23
|
+
if (!(component in trigger)) {
|
|
24
|
+
throw new TypeError(`The ${component} parameter needs to be present`);
|
|
25
|
+
}
|
|
26
|
+
const value = trigger[component];
|
|
27
|
+
if (typeof value !== 'number') {
|
|
28
|
+
throw new TypeError(`The ${component} parameter should be a number`);
|
|
29
|
+
}
|
|
30
|
+
switch (component) {
|
|
31
|
+
case 'month':
|
|
32
|
+
if (value < 0 || value > 11) {
|
|
33
|
+
throw new RangeError(`The month parameter needs to be between 0 and 11. Found: ${value}`);
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
36
|
+
case 'day': {
|
|
37
|
+
const month = typeof trigger.month === 'number'
|
|
38
|
+
? trigger.month
|
|
39
|
+
: new Date().getMonth();
|
|
40
|
+
const max = daysInMonth(month);
|
|
41
|
+
if (value < 1 || value > max) {
|
|
42
|
+
throw new RangeError(`The day parameter for month ${month} must be between 1 and ${max}. Found: ${value}`);
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case 'weekday':
|
|
47
|
+
if (value < 1 || value > 7) {
|
|
48
|
+
throw new RangeError(`The weekday parameter needs to be between 1 and 7. Found: ${value}`);
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
case 'hour':
|
|
52
|
+
if (value < 0 || value > 23) {
|
|
53
|
+
throw new RangeError(`The hour parameter needs to be between 0 and 23. Found: ${value}`);
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
case 'minute':
|
|
57
|
+
if (value < 0 || value > 59) {
|
|
58
|
+
throw new RangeError(`The minute parameter needs to be between 0 and 59. Found: ${value}`);
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** Translates a public `INotificationTriggerInput` into the shape native expects. */
|
|
65
|
+
export function parseTrigger(trigger) {
|
|
66
|
+
if (trigger === null) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
if (trigger === undefined) {
|
|
70
|
+
throw new TypeError('Encountered an `undefined` notification trigger. Pass an explicit `null` to trigger immediately.');
|
|
71
|
+
}
|
|
72
|
+
if (!hasValidTriggerObject(trigger)) {
|
|
73
|
+
throw new TypeError('The `trigger` object needs a `type` or `channelId` entry.');
|
|
74
|
+
}
|
|
75
|
+
if ('type' in trigger) {
|
|
76
|
+
if (trigger.type === SchedulableTriggerInputTypes.DATE) {
|
|
77
|
+
const timestamp = trigger.date instanceof Date ? trigger.date.getTime() : trigger.date;
|
|
78
|
+
const result = { type: 'date', timestamp };
|
|
79
|
+
if (trigger.channelId)
|
|
80
|
+
result.channelId = trigger.channelId;
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
if (trigger.type === SchedulableTriggerInputTypes.CALENDAR) {
|
|
84
|
+
const { repeats, ...rest } = trigger;
|
|
85
|
+
return {
|
|
86
|
+
...rest,
|
|
87
|
+
repeats: Boolean(repeats),
|
|
88
|
+
type: 'calendar',
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (trigger.type === SchedulableTriggerInputTypes.DAILY) {
|
|
92
|
+
validateDateComponents(trigger, ['hour', 'minute']);
|
|
93
|
+
const result = {
|
|
94
|
+
type: 'daily',
|
|
95
|
+
hour: trigger.hour,
|
|
96
|
+
minute: trigger.minute,
|
|
97
|
+
};
|
|
98
|
+
if (trigger.channelId)
|
|
99
|
+
result.channelId = trigger.channelId;
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
if (trigger.type === SchedulableTriggerInputTypes.WEEKLY) {
|
|
103
|
+
validateDateComponents(trigger, ['weekday', 'hour', 'minute']);
|
|
104
|
+
const result = {
|
|
105
|
+
type: 'weekly',
|
|
106
|
+
weekday: trigger.weekday,
|
|
107
|
+
hour: trigger.hour,
|
|
108
|
+
minute: trigger.minute,
|
|
109
|
+
};
|
|
110
|
+
if (trigger.channelId)
|
|
111
|
+
result.channelId = trigger.channelId;
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
if (trigger.type === SchedulableTriggerInputTypes.MONTHLY) {
|
|
115
|
+
validateDateComponents(trigger, ['day', 'hour', 'minute']);
|
|
116
|
+
const result = {
|
|
117
|
+
type: 'monthly',
|
|
118
|
+
day: trigger.day,
|
|
119
|
+
hour: trigger.hour,
|
|
120
|
+
minute: trigger.minute,
|
|
121
|
+
};
|
|
122
|
+
if (trigger.channelId)
|
|
123
|
+
result.channelId = trigger.channelId;
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
if (trigger.type === SchedulableTriggerInputTypes.YEARLY) {
|
|
127
|
+
validateDateComponents(trigger, ['month', 'day', 'hour', 'minute']);
|
|
128
|
+
const result = {
|
|
129
|
+
type: 'yearly',
|
|
130
|
+
month: trigger.month,
|
|
131
|
+
day: trigger.day,
|
|
132
|
+
hour: trigger.hour,
|
|
133
|
+
minute: trigger.minute,
|
|
134
|
+
};
|
|
135
|
+
if (trigger.channelId)
|
|
136
|
+
result.channelId = trigger.channelId;
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
if (trigger.type === SchedulableTriggerInputTypes.TIME_INTERVAL) {
|
|
140
|
+
const result = {
|
|
141
|
+
type: 'timeInterval',
|
|
142
|
+
seconds: trigger.seconds,
|
|
143
|
+
repeats: trigger.repeats ?? false,
|
|
144
|
+
};
|
|
145
|
+
if (trigger.channelId)
|
|
146
|
+
result.channelId = trigger.channelId;
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (Platform.OS === 'android' && 'channelId' in trigger) {
|
|
151
|
+
return { type: 'channel', channelId: trigger.channelId };
|
|
152
|
+
}
|
|
153
|
+
// No notion of channels off Android — deliver immediately.
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
/** Fetches every notification currently scheduled for future delivery. */
|
|
157
|
+
export async function getAllScheduledNotificationsAsync() {
|
|
158
|
+
if (!notificationScheduler.getAllScheduledNotificationsAsync) {
|
|
159
|
+
throw new UnavailabilityError('Notifications', 'getAllScheduledNotificationsAsync');
|
|
160
|
+
}
|
|
161
|
+
const requests = await notificationScheduler.getAllScheduledNotificationsAsync();
|
|
162
|
+
return requests.map(mapNotificationRequest);
|
|
163
|
+
}
|
|
164
|
+
/** Schedules a notification. Returns the identifier used to cancel it later. */
|
|
165
|
+
export async function scheduleNotificationAsync(request) {
|
|
166
|
+
if (!notificationScheduler.scheduleNotificationAsync) {
|
|
167
|
+
throw new UnavailabilityError('Notifications', 'scheduleNotificationAsync');
|
|
168
|
+
}
|
|
169
|
+
const identifier = request.identifier ?? uuid();
|
|
170
|
+
dlog(() => `[notifications] scheduleNotificationAsync ${identifier}`);
|
|
171
|
+
return notificationScheduler.scheduleNotificationAsync(identifier, request.content, parseTrigger(request.trigger));
|
|
172
|
+
}
|
|
173
|
+
/** Cancels one scheduled notification by its identifier. */
|
|
174
|
+
export async function cancelScheduledNotificationAsync(identifier) {
|
|
175
|
+
if (!notificationScheduler.cancelScheduledNotificationAsync) {
|
|
176
|
+
throw new UnavailabilityError('Notifications', 'cancelScheduledNotificationAsync');
|
|
177
|
+
}
|
|
178
|
+
return notificationScheduler.cancelScheduledNotificationAsync(identifier);
|
|
179
|
+
}
|
|
180
|
+
/** Cancels every scheduled notification. */
|
|
181
|
+
export async function cancelAllScheduledNotificationsAsync() {
|
|
182
|
+
if (!notificationScheduler.cancelAllScheduledNotificationsAsync) {
|
|
183
|
+
throw new UnavailabilityError('Notifications', 'cancelAllScheduledNotificationsAsync');
|
|
184
|
+
}
|
|
185
|
+
return notificationScheduler.cancelAllScheduledNotificationsAsync();
|
|
186
|
+
}
|
|
187
|
+
/** The next Unix timestamp (ms) a schedulable trigger would fire at, or `null` if never. */
|
|
188
|
+
export async function getNextTriggerDateAsync(trigger) {
|
|
189
|
+
if (!notificationScheduler.getNextTriggerDateAsync) {
|
|
190
|
+
throw new UnavailabilityError('Notifications', 'getNextTriggerDateAsync');
|
|
191
|
+
}
|
|
192
|
+
return notificationScheduler.getNextTriggerDateAsync(parseTrigger(trigger));
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../src/core/scheduler.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,6EAA6E;AAC7E,uEAAuE;AACvE,OAAO,EAAE,QAAQ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AyB,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,qBAAqB,CAAC,uBAAuB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type EventSubscription } from 'expo-modules-core';
|
|
2
|
+
import type { IDevicePushToken, IExpoPushToken, IExpoPushTokenOptions } from './types';
|
|
3
|
+
export type IPushTokenListener = (token: IDevicePushToken) => void;
|
|
4
|
+
/** Fires whenever the OS rolls the device push token while the app is running. */
|
|
5
|
+
export declare function addPushTokenListener(listener: IPushTokenListener): EventSubscription;
|
|
6
|
+
/** Returns the native FCM (Android) or APNs (iOS) device push token. */
|
|
7
|
+
export declare function getDevicePushTokenAsync(): Promise<IDevicePushToken>;
|
|
8
|
+
/** Unregisters the device from receiving remote push notifications entirely. */
|
|
9
|
+
export declare function unregisterForNotificationsAsync(): Promise<void>;
|
|
10
|
+
/** Subscribes the device to an FCM topic. @platform android */
|
|
11
|
+
export declare function subscribeToTopicAsync(topic: string): Promise<null>;
|
|
12
|
+
/** Unsubscribes the device from an FCM topic. @platform android */
|
|
13
|
+
export declare function unsubscribeFromTopicAsync(topic: string): Promise<null>;
|
|
14
|
+
/**
|
|
15
|
+
* Enables/disables letting the OS-level registration blob persist whether the device push
|
|
16
|
+
* token should keep being pushed to the Expo push service backend. See the module doc comment
|
|
17
|
+
* above for what this deliberately does *not* do (the auto-resync daemon).
|
|
18
|
+
*/
|
|
19
|
+
export declare function setAutoServerRegistrationEnabledAsync(enabled: boolean): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Returns an Expo push token usable with Expo's push notification relay service. Makes a
|
|
22
|
+
* network request to Expo's servers — wrap in try/catch and retry once the device is back
|
|
23
|
+
* online.
|
|
24
|
+
*
|
|
25
|
+
* ponytail: upstream auto-fills `projectId`/`applicationId`/`development` from
|
|
26
|
+
* `expo-constants`/`expo-application`. Neither package is part of this port, so pass them
|
|
27
|
+
* explicitly (`applicationId` from `@symbiote-native/application`'s own `applicationId` export
|
|
28
|
+
* covers the second one).
|
|
29
|
+
*/
|
|
30
|
+
export declare function getExpoPushTokenAsync(options?: IExpoPushTokenOptions): Promise<IExpoPushToken>;
|