@fishonfire/bubbles-expo 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.
@@ -0,0 +1,306 @@
1
+ import { LocaleAndTimeZone, DeviceClient, DeviceClientOptions, RequestOptions, UpdateDeviceOptions } from '@fishonfire/bubbles-js';
2
+ import * as Notifications from 'expo-notifications';
3
+ import { Notification } from 'expo-notifications';
4
+ import * as react from 'react';
5
+ import { ReactNode } from 'react';
6
+
7
+ declare const BUBBLES_NOTIFICATIONS_EXPO_EXTRA_KEY = "bubblesNotificationsExpo";
8
+ declare const ANDROID_CHANNEL_IMPORTANCE_VALUES: readonly ["min", "low", "default", "high", "max"];
9
+ type AndroidChannelImportance = (typeof ANDROID_CHANNEL_IMPORTANCE_VALUES)[number];
10
+ interface BubblesNotificationsRuntimeConfig {
11
+ defaultChannelId: string;
12
+ defaultChannelName: string;
13
+ androidChannelImportance: AndroidChannelImportance;
14
+ }
15
+ declare function getBubblesNotificationsRuntimeConfig(): BubblesNotificationsRuntimeConfig;
16
+
17
+ interface StoredDeviceState {
18
+ deviceId: string | null;
19
+ apiBaseUrl: string | null;
20
+ appKey: string | null;
21
+ }
22
+ type StoredDeviceStateUpdate = Partial<StoredDeviceState>;
23
+ declare function readStoredDeviceState(): StoredDeviceState;
24
+ declare function storeDeviceState(state: StoredDeviceState): StoredDeviceState;
25
+ declare function patchStoredDeviceState(update: StoredDeviceStateUpdate): StoredDeviceState;
26
+ declare function readStoredDeviceId(): string | null;
27
+ declare function readStoredApiBaseUrl(): string | null;
28
+ declare function readStoredAppKey(): string | null;
29
+ declare function storeDeviceId(deviceId: string | null): StoredDeviceState;
30
+ declare function storeApiBaseUrl(apiBaseUrl: string | null): StoredDeviceState;
31
+ declare function storeAppKey(appKey: string | null): StoredDeviceState;
32
+
33
+ type BubblesDevicePlatform = 'android' | 'ios';
34
+ interface BuildBubblesDevicePayloadOptions {
35
+ userId: string;
36
+ aliasing?: string[] | null;
37
+ platform: BubblesDevicePlatform;
38
+ pushToken: string | null;
39
+ fid?: string | null;
40
+ appVersion?: string | null;
41
+ notificationsEnabled: boolean;
42
+ localeAndTimeZone?: LocaleAndTimeZone;
43
+ }
44
+ interface BuildBubblesCreateDevicePayloadOptions extends BuildBubblesDevicePayloadOptions {
45
+ appId: string | number;
46
+ }
47
+ interface BubblesDevicePayload {
48
+ user_id: string;
49
+ aliasing: string[];
50
+ platform: BubblesDevicePlatform;
51
+ push_token: string | null;
52
+ fid?: string | null;
53
+ app_version?: string;
54
+ locale: string;
55
+ timezone?: string;
56
+ notifications_enabled: boolean;
57
+ }
58
+ interface BubblesCreateDevicePayload extends BubblesDevicePayload {
59
+ app_id: string | number;
60
+ }
61
+ type BubblesUpdateDevicePayload = BubblesDevicePayload;
62
+ declare function buildCreateDevicePayload(options: BuildBubblesCreateDevicePayloadOptions): BubblesCreateDevicePayload;
63
+ declare function buildUpdateDevicePayload(options: BuildBubblesDevicePayloadOptions): BubblesUpdateDevicePayload;
64
+
65
+ declare class BubblesAppAuthenticationError extends Error {
66
+ readonly cause: unknown;
67
+ constructor(cause?: unknown);
68
+ }
69
+ interface BubblesDeviceClientOptions extends DeviceClientOptions {
70
+ appKey?: string;
71
+ }
72
+ type DeviceClientFactoryOptions$1 = Omit<BubblesDeviceClientOptions, 'baseUrl'>;
73
+ interface BubblesDeviceClientInput {
74
+ apiBaseUrl?: string;
75
+ appKey: string;
76
+ client?: DeviceClient;
77
+ clientOptions?: DeviceClientFactoryOptions$1;
78
+ }
79
+ interface CreateBubblesDeviceOptions extends BuildBubblesCreateDevicePayloadOptions, BubblesDeviceClientInput {
80
+ requestOptions?: RequestOptions;
81
+ }
82
+ interface UpdateBubblesDeviceOptions extends BuildBubblesDevicePayloadOptions, BubblesDeviceClientInput {
83
+ deviceId: string | number;
84
+ requestOptions?: UpdateDeviceOptions;
85
+ }
86
+ interface SyncBubblesDeviceOptions extends BuildBubblesCreateDevicePayloadOptions, BubblesDeviceClientInput {
87
+ deviceId: string | number | null;
88
+ createRequestOptions?: RequestOptions;
89
+ updateRequestOptions?: UpdateDeviceOptions;
90
+ }
91
+ interface SyncBubblesDeviceResult<TResponse = unknown> {
92
+ action: 'created' | 'updated';
93
+ deviceId: string | null;
94
+ response: TResponse;
95
+ }
96
+ declare function createBubblesDeviceClient(options: BubblesDeviceClientOptions): DeviceClient;
97
+ declare function extractDeviceIdFromDeviceResponse(value: unknown): string | null;
98
+ declare function createBubblesDevice<TResponse = unknown>(options: CreateBubblesDeviceOptions): Promise<TResponse>;
99
+ declare function updateBubblesDevice<TResponse = unknown>(options: UpdateBubblesDeviceOptions): Promise<TResponse>;
100
+ declare function syncBubblesDevice<TResponse = unknown>(options: SyncBubblesDeviceOptions): Promise<SyncBubblesDeviceResult<TResponse>>;
101
+
102
+ type DeviceClientFactoryOptions = Omit<DeviceClientOptions, 'baseUrl'>;
103
+ /**
104
+ * Public delivery status labels accepted by the Bubbles device API.
105
+ *
106
+ * Client-side notification callbacks are source-specific observations:
107
+ * "received" means app-observed, "shown" may be
108
+ * confirmed/requested/inferred depending on source, "clicked"
109
+ * means app-observed user interaction, and "disabled" describes
110
+ * permission/device capability.
111
+ */
112
+ declare const BUBBLES_DELIVERY_STATUSES: {
113
+ readonly notificationReceived: "received";
114
+ readonly notificationShown: "shown";
115
+ readonly notificationClicked: "clicked";
116
+ readonly notificationsDisabled: "disabled";
117
+ };
118
+ type BubblesDeliveryStatus = (typeof BUBBLES_DELIVERY_STATUSES)[keyof typeof BUBBLES_DELIVERY_STATUSES];
119
+ interface BubblesDeliveryStatusPayload {
120
+ status?: BubblesDeliveryStatus;
121
+ error?: string;
122
+ }
123
+ interface BuildBubblesDeliveryStatusPayloadOptions {
124
+ status?: BubblesDeliveryStatus;
125
+ error?: string | null;
126
+ }
127
+ interface PostBubblesDeliveryStatusOptions extends BuildBubblesDeliveryStatusPayloadOptions {
128
+ apiBaseUrl?: string;
129
+ appKey: string;
130
+ deviceId: string | number;
131
+ notificationId: string | number;
132
+ client?: DeviceClient;
133
+ clientOptions?: DeviceClientFactoryOptions;
134
+ requestOptions?: RequestOptions;
135
+ }
136
+ declare function buildBubblesDeliveryStatusPayload(options: BuildBubblesDeliveryStatusPayloadOptions): BubblesDeliveryStatusPayload;
137
+ declare function postBubblesDeliveryStatus(options: PostBubblesDeliveryStatusOptions): Promise<void>;
138
+
139
+ interface PostStoredBubblesDeliveryStatusOptions {
140
+ source: string;
141
+ notificationId: string | null;
142
+ status?: BubblesDeliveryStatus;
143
+ error?: string | null;
144
+ actionId?: string | null;
145
+ storedDeviceState?: StoredDeviceState;
146
+ }
147
+ declare function postStoredBubblesDeliveryStatus(options: PostStoredBubblesDeliveryStatusOptions): Promise<StoredDeviceState>;
148
+ declare function flushStoredBubblesDeliveryStatuses(storedDeviceState?: StoredDeviceState): Promise<StoredDeviceState>;
149
+
150
+ interface StoredDeliveryStatusEvent {
151
+ key: string;
152
+ notificationId: string;
153
+ status?: BubblesDeliveryStatus;
154
+ error?: string;
155
+ actionId?: string;
156
+ createdAt: string;
157
+ }
158
+ interface StoredDeliveryStatusLedger {
159
+ pendingEvents: StoredDeliveryStatusEvent[];
160
+ postedEventKeys: string[];
161
+ }
162
+ interface CreateStoredDeliveryStatusEventOptions {
163
+ notificationId: string;
164
+ status?: BubblesDeliveryStatus;
165
+ error?: string | null;
166
+ actionId?: string | null;
167
+ }
168
+ declare function buildStoredDeliveryStatusEventKey(options: Omit<CreateStoredDeliveryStatusEventOptions, 'error'> & {
169
+ error?: string;
170
+ }): string;
171
+ declare function createStoredDeliveryStatusEvent(options: CreateStoredDeliveryStatusEventOptions): StoredDeliveryStatusEvent;
172
+ declare function readStoredDeliveryStatusLedger(): StoredDeliveryStatusLedger;
173
+ declare function storeDeliveryStatusLedger(ledger: StoredDeliveryStatusLedger): StoredDeliveryStatusLedger;
174
+ declare function enqueueStoredDeliveryStatusEvent(event: StoredDeliveryStatusEvent): StoredDeliveryStatusLedger;
175
+ declare function markStoredDeliveryStatusEventPosted(event: StoredDeliveryStatusEvent): StoredDeliveryStatusLedger;
176
+
177
+ interface EnsureDefaultNotificationChannelOptions {
178
+ channelId?: string;
179
+ channelName?: string;
180
+ importance?: AndroidChannelImportance;
181
+ }
182
+ interface DefaultNotificationChannelConfig {
183
+ channelId: string;
184
+ channelName: string;
185
+ importance: AndroidChannelImportance;
186
+ }
187
+ declare function getAndroidNotificationChannelImportance(value: AndroidChannelImportance): Notifications.AndroidImportance;
188
+ declare function getDefaultNotificationChannelConfig(options?: EnsureDefaultNotificationChannelOptions): DefaultNotificationChannelConfig;
189
+ declare function ensureDefaultNotificationChannel(options?: EnsureDefaultNotificationChannelOptions): Promise<Notifications.NotificationChannel | null>;
190
+
191
+ declare function registerBubblesBackgroundHandlers(): void;
192
+
193
+ type PermissionRequestOptions = Parameters<typeof Notifications.requestPermissionsAsync>[0];
194
+ interface GetNotificationPermissionsOptions {
195
+ requestPermissions?: boolean;
196
+ permissionRequestOptions?: PermissionRequestOptions;
197
+ }
198
+ declare function isNotificationPermissionGranted(permissions: Notifications.NotificationPermissionsStatus): boolean;
199
+ declare function describeNotificationPermissionStatus(permissions: Notifications.NotificationPermissionsStatus): string;
200
+ declare function getNotificationPermissions(options?: GetNotificationPermissionsOptions): Promise<Notifications.NotificationPermissionsStatus>;
201
+ declare function ensureNotificationPermissions(options?: GetNotificationPermissionsOptions): Promise<Notifications.NotificationPermissionsStatus>;
202
+
203
+ type SupportedPlatform = 'android' | 'ios';
204
+
205
+ type NativeTokenType = 'fcm';
206
+ type GetDeviceTokenOptions = GetNotificationPermissionsOptions;
207
+ interface DeviceTokenResult {
208
+ platform: SupportedPlatform;
209
+ tokenType: NativeTokenType;
210
+ token: string;
211
+ }
212
+ interface DeviceRegistrationState {
213
+ platform: SupportedPlatform;
214
+ tokenType: NativeTokenType | null;
215
+ token: string | null;
216
+ permissionStatus: string;
217
+ notificationsEnabled: boolean;
218
+ }
219
+ declare function getDeviceRegistrationState(options?: GetDeviceTokenOptions): Promise<DeviceRegistrationState>;
220
+ declare function getDeviceToken(options?: GetDeviceTokenOptions): Promise<DeviceTokenResult>;
221
+ declare function getFCMToken(options?: GetDeviceTokenOptions): Promise<string>;
222
+
223
+ interface RegisterDeviceOptions {
224
+ requestPermissions?: boolean;
225
+ permissionRequestOptions?: PermissionRequestOptions;
226
+ }
227
+ interface ForegroundPresentationOptions {
228
+ shouldShowBanner?: boolean;
229
+ shouldShowList?: boolean;
230
+ shouldPlaySound?: boolean;
231
+ shouldSetBadge?: boolean;
232
+ }
233
+ interface BubblesNotificationsLogoutEvent {
234
+ previousUserId: string;
235
+ deviceId: string | null;
236
+ }
237
+ interface BubblesNotificationResponseEvent {
238
+ notification: Notification;
239
+ url: string | null;
240
+ notificationId: string | null;
241
+ deviceId: string | null;
242
+ data: Record<string, unknown>;
243
+ }
244
+ interface BubblesNotificationsProviderProps {
245
+ appId: string | number;
246
+ appKey: string;
247
+ apiBaseUrl: string;
248
+ ready: boolean;
249
+ userId: string | null;
250
+ aliasing?: string[];
251
+ appVersion?: string | null;
252
+ onLogout?: (event: BubblesNotificationsLogoutEvent) => Promise<void> | void;
253
+ foregroundPresentation?: ForegroundPresentationOptions;
254
+ onNotificationResponse?: (event: BubblesNotificationResponseEvent) => void;
255
+ children: ReactNode;
256
+ }
257
+ interface BubblesNotificationsContextValue {
258
+ registerDevice: (options?: RegisterDeviceOptions) => Promise<void>;
259
+ deviceId: string | null;
260
+ pushToken: string | null;
261
+ tokenType: NativeTokenType | null;
262
+ permissionStatus: string;
263
+ notificationsEnabled: boolean;
264
+ isSyncing: boolean;
265
+ error: Error | null;
266
+ }
267
+
268
+ declare function BubblesNotificationsProvider(props: BubblesNotificationsProviderProps): react.JSX.Element;
269
+
270
+ declare function useBubblesNotifications(): BubblesNotificationsContextValue;
271
+
272
+ interface BubblesNotificationDataContract {
273
+ notification_id: string;
274
+ url?: string;
275
+ type?: string;
276
+ resource_id?: string;
277
+ message_title?: string;
278
+ body?: string;
279
+ source?: string;
280
+ message_id?: string;
281
+ campaign_id?: string;
282
+ [key: string]: string | undefined;
283
+ }
284
+ interface BubblesVisibleNotificationPayloadContract {
285
+ notification: {
286
+ title: string;
287
+ body: string;
288
+ };
289
+ data: BubblesNotificationDataContract;
290
+ }
291
+ interface BubblesSilentNotificationPayloadContract {
292
+ data: BubblesNotificationDataContract;
293
+ }
294
+ type BubblesForegroundNotificationPayloadContract = BubblesVisibleNotificationPayloadContract;
295
+ interface BubblesNotificationPayload {
296
+ data: Record<string, unknown>;
297
+ notificationId: string | null;
298
+ messageTitle: string | null;
299
+ body: string | null;
300
+ source: string | null;
301
+ messageId: string | null;
302
+ campaignId: string | null;
303
+ url: string | null;
304
+ }
305
+
306
+ export { ANDROID_CHANNEL_IMPORTANCE_VALUES, type AndroidChannelImportance, BUBBLES_DELIVERY_STATUSES, BUBBLES_NOTIFICATIONS_EXPO_EXTRA_KEY, BubblesAppAuthenticationError, type BubblesCreateDevicePayload, type BubblesDeliveryStatus, type BubblesDeliveryStatusPayload, type BubblesDevicePayload, type BubblesDevicePlatform, type BubblesForegroundNotificationPayloadContract, type BubblesNotificationDataContract, type BubblesNotificationPayload, type BubblesNotificationResponseEvent, type BubblesNotificationsContextValue, type BubblesNotificationsLogoutEvent, BubblesNotificationsProvider, type BubblesNotificationsProviderProps, type BubblesNotificationsRuntimeConfig, type BubblesSilentNotificationPayloadContract, type BubblesUpdateDevicePayload, type BubblesVisibleNotificationPayloadContract, type BuildBubblesCreateDevicePayloadOptions, type BuildBubblesDeliveryStatusPayloadOptions, type BuildBubblesDevicePayloadOptions, type CreateBubblesDeviceOptions, type CreateStoredDeliveryStatusEventOptions, type DefaultNotificationChannelConfig, type DeviceRegistrationState, type DeviceTokenResult, type EnsureDefaultNotificationChannelOptions, type ForegroundPresentationOptions, type GetDeviceTokenOptions, type GetNotificationPermissionsOptions, type NativeTokenType, type PermissionRequestOptions, type PostBubblesDeliveryStatusOptions, type PostStoredBubblesDeliveryStatusOptions, type RegisterDeviceOptions, type StoredDeliveryStatusEvent, type StoredDeliveryStatusLedger, type StoredDeviceState, type StoredDeviceStateUpdate, type SupportedPlatform, type SyncBubblesDeviceOptions, type SyncBubblesDeviceResult, type UpdateBubblesDeviceOptions, buildBubblesDeliveryStatusPayload, buildCreateDevicePayload, buildStoredDeliveryStatusEventKey, buildUpdateDevicePayload, createBubblesDevice, createBubblesDeviceClient, createStoredDeliveryStatusEvent, describeNotificationPermissionStatus, enqueueStoredDeliveryStatusEvent, ensureDefaultNotificationChannel, ensureNotificationPermissions, extractDeviceIdFromDeviceResponse, flushStoredBubblesDeliveryStatuses, getAndroidNotificationChannelImportance, getBubblesNotificationsRuntimeConfig, getDefaultNotificationChannelConfig, getDeviceRegistrationState, getDeviceToken, getFCMToken, getNotificationPermissions, isNotificationPermissionGranted, markStoredDeliveryStatusEventPosted, patchStoredDeviceState, postBubblesDeliveryStatus, postStoredBubblesDeliveryStatus, readStoredApiBaseUrl, readStoredAppKey, readStoredDeliveryStatusLedger, readStoredDeviceId, readStoredDeviceState, registerBubblesBackgroundHandlers, storeApiBaseUrl, storeAppKey, storeDeliveryStatusLedger, storeDeviceId, storeDeviceState, syncBubblesDevice, updateBubblesDevice, useBubblesNotifications };
@@ -0,0 +1,306 @@
1
+ import { LocaleAndTimeZone, DeviceClient, DeviceClientOptions, RequestOptions, UpdateDeviceOptions } from '@fishonfire/bubbles-js';
2
+ import * as Notifications from 'expo-notifications';
3
+ import { Notification } from 'expo-notifications';
4
+ import * as react from 'react';
5
+ import { ReactNode } from 'react';
6
+
7
+ declare const BUBBLES_NOTIFICATIONS_EXPO_EXTRA_KEY = "bubblesNotificationsExpo";
8
+ declare const ANDROID_CHANNEL_IMPORTANCE_VALUES: readonly ["min", "low", "default", "high", "max"];
9
+ type AndroidChannelImportance = (typeof ANDROID_CHANNEL_IMPORTANCE_VALUES)[number];
10
+ interface BubblesNotificationsRuntimeConfig {
11
+ defaultChannelId: string;
12
+ defaultChannelName: string;
13
+ androidChannelImportance: AndroidChannelImportance;
14
+ }
15
+ declare function getBubblesNotificationsRuntimeConfig(): BubblesNotificationsRuntimeConfig;
16
+
17
+ interface StoredDeviceState {
18
+ deviceId: string | null;
19
+ apiBaseUrl: string | null;
20
+ appKey: string | null;
21
+ }
22
+ type StoredDeviceStateUpdate = Partial<StoredDeviceState>;
23
+ declare function readStoredDeviceState(): StoredDeviceState;
24
+ declare function storeDeviceState(state: StoredDeviceState): StoredDeviceState;
25
+ declare function patchStoredDeviceState(update: StoredDeviceStateUpdate): StoredDeviceState;
26
+ declare function readStoredDeviceId(): string | null;
27
+ declare function readStoredApiBaseUrl(): string | null;
28
+ declare function readStoredAppKey(): string | null;
29
+ declare function storeDeviceId(deviceId: string | null): StoredDeviceState;
30
+ declare function storeApiBaseUrl(apiBaseUrl: string | null): StoredDeviceState;
31
+ declare function storeAppKey(appKey: string | null): StoredDeviceState;
32
+
33
+ type BubblesDevicePlatform = 'android' | 'ios';
34
+ interface BuildBubblesDevicePayloadOptions {
35
+ userId: string;
36
+ aliasing?: string[] | null;
37
+ platform: BubblesDevicePlatform;
38
+ pushToken: string | null;
39
+ fid?: string | null;
40
+ appVersion?: string | null;
41
+ notificationsEnabled: boolean;
42
+ localeAndTimeZone?: LocaleAndTimeZone;
43
+ }
44
+ interface BuildBubblesCreateDevicePayloadOptions extends BuildBubblesDevicePayloadOptions {
45
+ appId: string | number;
46
+ }
47
+ interface BubblesDevicePayload {
48
+ user_id: string;
49
+ aliasing: string[];
50
+ platform: BubblesDevicePlatform;
51
+ push_token: string | null;
52
+ fid?: string | null;
53
+ app_version?: string;
54
+ locale: string;
55
+ timezone?: string;
56
+ notifications_enabled: boolean;
57
+ }
58
+ interface BubblesCreateDevicePayload extends BubblesDevicePayload {
59
+ app_id: string | number;
60
+ }
61
+ type BubblesUpdateDevicePayload = BubblesDevicePayload;
62
+ declare function buildCreateDevicePayload(options: BuildBubblesCreateDevicePayloadOptions): BubblesCreateDevicePayload;
63
+ declare function buildUpdateDevicePayload(options: BuildBubblesDevicePayloadOptions): BubblesUpdateDevicePayload;
64
+
65
+ declare class BubblesAppAuthenticationError extends Error {
66
+ readonly cause: unknown;
67
+ constructor(cause?: unknown);
68
+ }
69
+ interface BubblesDeviceClientOptions extends DeviceClientOptions {
70
+ appKey?: string;
71
+ }
72
+ type DeviceClientFactoryOptions$1 = Omit<BubblesDeviceClientOptions, 'baseUrl'>;
73
+ interface BubblesDeviceClientInput {
74
+ apiBaseUrl?: string;
75
+ appKey: string;
76
+ client?: DeviceClient;
77
+ clientOptions?: DeviceClientFactoryOptions$1;
78
+ }
79
+ interface CreateBubblesDeviceOptions extends BuildBubblesCreateDevicePayloadOptions, BubblesDeviceClientInput {
80
+ requestOptions?: RequestOptions;
81
+ }
82
+ interface UpdateBubblesDeviceOptions extends BuildBubblesDevicePayloadOptions, BubblesDeviceClientInput {
83
+ deviceId: string | number;
84
+ requestOptions?: UpdateDeviceOptions;
85
+ }
86
+ interface SyncBubblesDeviceOptions extends BuildBubblesCreateDevicePayloadOptions, BubblesDeviceClientInput {
87
+ deviceId: string | number | null;
88
+ createRequestOptions?: RequestOptions;
89
+ updateRequestOptions?: UpdateDeviceOptions;
90
+ }
91
+ interface SyncBubblesDeviceResult<TResponse = unknown> {
92
+ action: 'created' | 'updated';
93
+ deviceId: string | null;
94
+ response: TResponse;
95
+ }
96
+ declare function createBubblesDeviceClient(options: BubblesDeviceClientOptions): DeviceClient;
97
+ declare function extractDeviceIdFromDeviceResponse(value: unknown): string | null;
98
+ declare function createBubblesDevice<TResponse = unknown>(options: CreateBubblesDeviceOptions): Promise<TResponse>;
99
+ declare function updateBubblesDevice<TResponse = unknown>(options: UpdateBubblesDeviceOptions): Promise<TResponse>;
100
+ declare function syncBubblesDevice<TResponse = unknown>(options: SyncBubblesDeviceOptions): Promise<SyncBubblesDeviceResult<TResponse>>;
101
+
102
+ type DeviceClientFactoryOptions = Omit<DeviceClientOptions, 'baseUrl'>;
103
+ /**
104
+ * Public delivery status labels accepted by the Bubbles device API.
105
+ *
106
+ * Client-side notification callbacks are source-specific observations:
107
+ * "received" means app-observed, "shown" may be
108
+ * confirmed/requested/inferred depending on source, "clicked"
109
+ * means app-observed user interaction, and "disabled" describes
110
+ * permission/device capability.
111
+ */
112
+ declare const BUBBLES_DELIVERY_STATUSES: {
113
+ readonly notificationReceived: "received";
114
+ readonly notificationShown: "shown";
115
+ readonly notificationClicked: "clicked";
116
+ readonly notificationsDisabled: "disabled";
117
+ };
118
+ type BubblesDeliveryStatus = (typeof BUBBLES_DELIVERY_STATUSES)[keyof typeof BUBBLES_DELIVERY_STATUSES];
119
+ interface BubblesDeliveryStatusPayload {
120
+ status?: BubblesDeliveryStatus;
121
+ error?: string;
122
+ }
123
+ interface BuildBubblesDeliveryStatusPayloadOptions {
124
+ status?: BubblesDeliveryStatus;
125
+ error?: string | null;
126
+ }
127
+ interface PostBubblesDeliveryStatusOptions extends BuildBubblesDeliveryStatusPayloadOptions {
128
+ apiBaseUrl?: string;
129
+ appKey: string;
130
+ deviceId: string | number;
131
+ notificationId: string | number;
132
+ client?: DeviceClient;
133
+ clientOptions?: DeviceClientFactoryOptions;
134
+ requestOptions?: RequestOptions;
135
+ }
136
+ declare function buildBubblesDeliveryStatusPayload(options: BuildBubblesDeliveryStatusPayloadOptions): BubblesDeliveryStatusPayload;
137
+ declare function postBubblesDeliveryStatus(options: PostBubblesDeliveryStatusOptions): Promise<void>;
138
+
139
+ interface PostStoredBubblesDeliveryStatusOptions {
140
+ source: string;
141
+ notificationId: string | null;
142
+ status?: BubblesDeliveryStatus;
143
+ error?: string | null;
144
+ actionId?: string | null;
145
+ storedDeviceState?: StoredDeviceState;
146
+ }
147
+ declare function postStoredBubblesDeliveryStatus(options: PostStoredBubblesDeliveryStatusOptions): Promise<StoredDeviceState>;
148
+ declare function flushStoredBubblesDeliveryStatuses(storedDeviceState?: StoredDeviceState): Promise<StoredDeviceState>;
149
+
150
+ interface StoredDeliveryStatusEvent {
151
+ key: string;
152
+ notificationId: string;
153
+ status?: BubblesDeliveryStatus;
154
+ error?: string;
155
+ actionId?: string;
156
+ createdAt: string;
157
+ }
158
+ interface StoredDeliveryStatusLedger {
159
+ pendingEvents: StoredDeliveryStatusEvent[];
160
+ postedEventKeys: string[];
161
+ }
162
+ interface CreateStoredDeliveryStatusEventOptions {
163
+ notificationId: string;
164
+ status?: BubblesDeliveryStatus;
165
+ error?: string | null;
166
+ actionId?: string | null;
167
+ }
168
+ declare function buildStoredDeliveryStatusEventKey(options: Omit<CreateStoredDeliveryStatusEventOptions, 'error'> & {
169
+ error?: string;
170
+ }): string;
171
+ declare function createStoredDeliveryStatusEvent(options: CreateStoredDeliveryStatusEventOptions): StoredDeliveryStatusEvent;
172
+ declare function readStoredDeliveryStatusLedger(): StoredDeliveryStatusLedger;
173
+ declare function storeDeliveryStatusLedger(ledger: StoredDeliveryStatusLedger): StoredDeliveryStatusLedger;
174
+ declare function enqueueStoredDeliveryStatusEvent(event: StoredDeliveryStatusEvent): StoredDeliveryStatusLedger;
175
+ declare function markStoredDeliveryStatusEventPosted(event: StoredDeliveryStatusEvent): StoredDeliveryStatusLedger;
176
+
177
+ interface EnsureDefaultNotificationChannelOptions {
178
+ channelId?: string;
179
+ channelName?: string;
180
+ importance?: AndroidChannelImportance;
181
+ }
182
+ interface DefaultNotificationChannelConfig {
183
+ channelId: string;
184
+ channelName: string;
185
+ importance: AndroidChannelImportance;
186
+ }
187
+ declare function getAndroidNotificationChannelImportance(value: AndroidChannelImportance): Notifications.AndroidImportance;
188
+ declare function getDefaultNotificationChannelConfig(options?: EnsureDefaultNotificationChannelOptions): DefaultNotificationChannelConfig;
189
+ declare function ensureDefaultNotificationChannel(options?: EnsureDefaultNotificationChannelOptions): Promise<Notifications.NotificationChannel | null>;
190
+
191
+ declare function registerBubblesBackgroundHandlers(): void;
192
+
193
+ type PermissionRequestOptions = Parameters<typeof Notifications.requestPermissionsAsync>[0];
194
+ interface GetNotificationPermissionsOptions {
195
+ requestPermissions?: boolean;
196
+ permissionRequestOptions?: PermissionRequestOptions;
197
+ }
198
+ declare function isNotificationPermissionGranted(permissions: Notifications.NotificationPermissionsStatus): boolean;
199
+ declare function describeNotificationPermissionStatus(permissions: Notifications.NotificationPermissionsStatus): string;
200
+ declare function getNotificationPermissions(options?: GetNotificationPermissionsOptions): Promise<Notifications.NotificationPermissionsStatus>;
201
+ declare function ensureNotificationPermissions(options?: GetNotificationPermissionsOptions): Promise<Notifications.NotificationPermissionsStatus>;
202
+
203
+ type SupportedPlatform = 'android' | 'ios';
204
+
205
+ type NativeTokenType = 'fcm';
206
+ type GetDeviceTokenOptions = GetNotificationPermissionsOptions;
207
+ interface DeviceTokenResult {
208
+ platform: SupportedPlatform;
209
+ tokenType: NativeTokenType;
210
+ token: string;
211
+ }
212
+ interface DeviceRegistrationState {
213
+ platform: SupportedPlatform;
214
+ tokenType: NativeTokenType | null;
215
+ token: string | null;
216
+ permissionStatus: string;
217
+ notificationsEnabled: boolean;
218
+ }
219
+ declare function getDeviceRegistrationState(options?: GetDeviceTokenOptions): Promise<DeviceRegistrationState>;
220
+ declare function getDeviceToken(options?: GetDeviceTokenOptions): Promise<DeviceTokenResult>;
221
+ declare function getFCMToken(options?: GetDeviceTokenOptions): Promise<string>;
222
+
223
+ interface RegisterDeviceOptions {
224
+ requestPermissions?: boolean;
225
+ permissionRequestOptions?: PermissionRequestOptions;
226
+ }
227
+ interface ForegroundPresentationOptions {
228
+ shouldShowBanner?: boolean;
229
+ shouldShowList?: boolean;
230
+ shouldPlaySound?: boolean;
231
+ shouldSetBadge?: boolean;
232
+ }
233
+ interface BubblesNotificationsLogoutEvent {
234
+ previousUserId: string;
235
+ deviceId: string | null;
236
+ }
237
+ interface BubblesNotificationResponseEvent {
238
+ notification: Notification;
239
+ url: string | null;
240
+ notificationId: string | null;
241
+ deviceId: string | null;
242
+ data: Record<string, unknown>;
243
+ }
244
+ interface BubblesNotificationsProviderProps {
245
+ appId: string | number;
246
+ appKey: string;
247
+ apiBaseUrl: string;
248
+ ready: boolean;
249
+ userId: string | null;
250
+ aliasing?: string[];
251
+ appVersion?: string | null;
252
+ onLogout?: (event: BubblesNotificationsLogoutEvent) => Promise<void> | void;
253
+ foregroundPresentation?: ForegroundPresentationOptions;
254
+ onNotificationResponse?: (event: BubblesNotificationResponseEvent) => void;
255
+ children: ReactNode;
256
+ }
257
+ interface BubblesNotificationsContextValue {
258
+ registerDevice: (options?: RegisterDeviceOptions) => Promise<void>;
259
+ deviceId: string | null;
260
+ pushToken: string | null;
261
+ tokenType: NativeTokenType | null;
262
+ permissionStatus: string;
263
+ notificationsEnabled: boolean;
264
+ isSyncing: boolean;
265
+ error: Error | null;
266
+ }
267
+
268
+ declare function BubblesNotificationsProvider(props: BubblesNotificationsProviderProps): react.JSX.Element;
269
+
270
+ declare function useBubblesNotifications(): BubblesNotificationsContextValue;
271
+
272
+ interface BubblesNotificationDataContract {
273
+ notification_id: string;
274
+ url?: string;
275
+ type?: string;
276
+ resource_id?: string;
277
+ message_title?: string;
278
+ body?: string;
279
+ source?: string;
280
+ message_id?: string;
281
+ campaign_id?: string;
282
+ [key: string]: string | undefined;
283
+ }
284
+ interface BubblesVisibleNotificationPayloadContract {
285
+ notification: {
286
+ title: string;
287
+ body: string;
288
+ };
289
+ data: BubblesNotificationDataContract;
290
+ }
291
+ interface BubblesSilentNotificationPayloadContract {
292
+ data: BubblesNotificationDataContract;
293
+ }
294
+ type BubblesForegroundNotificationPayloadContract = BubblesVisibleNotificationPayloadContract;
295
+ interface BubblesNotificationPayload {
296
+ data: Record<string, unknown>;
297
+ notificationId: string | null;
298
+ messageTitle: string | null;
299
+ body: string | null;
300
+ source: string | null;
301
+ messageId: string | null;
302
+ campaignId: string | null;
303
+ url: string | null;
304
+ }
305
+
306
+ export { ANDROID_CHANNEL_IMPORTANCE_VALUES, type AndroidChannelImportance, BUBBLES_DELIVERY_STATUSES, BUBBLES_NOTIFICATIONS_EXPO_EXTRA_KEY, BubblesAppAuthenticationError, type BubblesCreateDevicePayload, type BubblesDeliveryStatus, type BubblesDeliveryStatusPayload, type BubblesDevicePayload, type BubblesDevicePlatform, type BubblesForegroundNotificationPayloadContract, type BubblesNotificationDataContract, type BubblesNotificationPayload, type BubblesNotificationResponseEvent, type BubblesNotificationsContextValue, type BubblesNotificationsLogoutEvent, BubblesNotificationsProvider, type BubblesNotificationsProviderProps, type BubblesNotificationsRuntimeConfig, type BubblesSilentNotificationPayloadContract, type BubblesUpdateDevicePayload, type BubblesVisibleNotificationPayloadContract, type BuildBubblesCreateDevicePayloadOptions, type BuildBubblesDeliveryStatusPayloadOptions, type BuildBubblesDevicePayloadOptions, type CreateBubblesDeviceOptions, type CreateStoredDeliveryStatusEventOptions, type DefaultNotificationChannelConfig, type DeviceRegistrationState, type DeviceTokenResult, type EnsureDefaultNotificationChannelOptions, type ForegroundPresentationOptions, type GetDeviceTokenOptions, type GetNotificationPermissionsOptions, type NativeTokenType, type PermissionRequestOptions, type PostBubblesDeliveryStatusOptions, type PostStoredBubblesDeliveryStatusOptions, type RegisterDeviceOptions, type StoredDeliveryStatusEvent, type StoredDeliveryStatusLedger, type StoredDeviceState, type StoredDeviceStateUpdate, type SupportedPlatform, type SyncBubblesDeviceOptions, type SyncBubblesDeviceResult, type UpdateBubblesDeviceOptions, buildBubblesDeliveryStatusPayload, buildCreateDevicePayload, buildStoredDeliveryStatusEventKey, buildUpdateDevicePayload, createBubblesDevice, createBubblesDeviceClient, createStoredDeliveryStatusEvent, describeNotificationPermissionStatus, enqueueStoredDeliveryStatusEvent, ensureDefaultNotificationChannel, ensureNotificationPermissions, extractDeviceIdFromDeviceResponse, flushStoredBubblesDeliveryStatuses, getAndroidNotificationChannelImportance, getBubblesNotificationsRuntimeConfig, getDefaultNotificationChannelConfig, getDeviceRegistrationState, getDeviceToken, getFCMToken, getNotificationPermissions, isNotificationPermissionGranted, markStoredDeliveryStatusEventPosted, patchStoredDeviceState, postBubblesDeliveryStatus, postStoredBubblesDeliveryStatus, readStoredApiBaseUrl, readStoredAppKey, readStoredDeliveryStatusLedger, readStoredDeviceId, readStoredDeviceState, registerBubblesBackgroundHandlers, storeApiBaseUrl, storeAppKey, storeDeliveryStatusLedger, storeDeviceId, storeDeviceState, syncBubblesDevice, updateBubblesDevice, useBubblesNotifications };