@umituz/react-native-notifications 1.0.6 → 1.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.
Files changed (67) hide show
  1. package/lib/infrastructure/hooks/actions/useNotificationActions.d.ts +4 -13
  2. package/lib/infrastructure/hooks/actions/useNotificationActions.d.ts.map +1 -1
  3. package/lib/infrastructure/hooks/actions/useNotificationActions.js +4 -70
  4. package/lib/infrastructure/hooks/actions/useNotificationActions.js.map +1 -1
  5. package/lib/infrastructure/hooks/actions/useNotificationManagementActions.d.ts +8 -0
  6. package/lib/infrastructure/hooks/actions/useNotificationManagementActions.d.ts.map +1 -0
  7. package/lib/infrastructure/hooks/actions/useNotificationManagementActions.js +78 -0
  8. package/lib/infrastructure/hooks/actions/useNotificationManagementActions.js.map +1 -0
  9. package/lib/infrastructure/hooks/state/useNotificationsState.d.ts +8 -8
  10. package/lib/infrastructure/hooks/useNotificationSettings.d.ts +2 -2
  11. package/lib/infrastructure/hooks/useNotifications.d.ts +21 -1
  12. package/lib/infrastructure/hooks/useNotifications.d.ts.map +1 -1
  13. package/lib/infrastructure/hooks/useNotifications.js +30 -9
  14. package/lib/infrastructure/hooks/useNotifications.js.map +1 -1
  15. package/lib/infrastructure/hooks/utils/useNotificationRefresh.d.ts +5 -10
  16. package/lib/infrastructure/hooks/utils/useNotificationRefresh.d.ts.map +1 -1
  17. package/lib/infrastructure/hooks/utils/useNotificationRefresh.js +32 -15
  18. package/lib/infrastructure/hooks/utils/useNotificationRefresh.js.map +1 -1
  19. package/lib/infrastructure/services/NotificationBadgeManager.d.ts +5 -0
  20. package/lib/infrastructure/services/NotificationBadgeManager.d.ts.map +1 -0
  21. package/lib/infrastructure/services/NotificationBadgeManager.js +29 -0
  22. package/lib/infrastructure/services/NotificationBadgeManager.js.map +1 -0
  23. package/lib/infrastructure/services/NotificationManager.d.ts +5 -84
  24. package/lib/infrastructure/services/NotificationManager.d.ts.map +1 -1
  25. package/lib/infrastructure/services/NotificationManager.js +36 -203
  26. package/lib/infrastructure/services/NotificationManager.js.map +1 -1
  27. package/lib/infrastructure/services/NotificationPermissions.d.ts +6 -0
  28. package/lib/infrastructure/services/NotificationPermissions.d.ts.map +1 -0
  29. package/lib/infrastructure/services/NotificationPermissions.js +75 -0
  30. package/lib/infrastructure/services/NotificationPermissions.js.map +1 -0
  31. package/lib/infrastructure/services/NotificationScheduler.d.ts +8 -0
  32. package/lib/infrastructure/services/NotificationScheduler.d.ts.map +1 -0
  33. package/lib/infrastructure/services/NotificationScheduler.js +72 -0
  34. package/lib/infrastructure/services/NotificationScheduler.js.map +1 -0
  35. package/lib/infrastructure/services/delivery/NotificationDelivery.d.ts +2 -8
  36. package/lib/infrastructure/services/delivery/NotificationDelivery.d.ts.map +1 -1
  37. package/lib/infrastructure/services/delivery/NotificationDelivery.js +27 -13
  38. package/lib/infrastructure/services/delivery/NotificationDelivery.js.map +1 -1
  39. package/lib/infrastructure/storage/NotificationsStore.d.ts +8 -1
  40. package/lib/infrastructure/storage/NotificationsStore.d.ts.map +1 -1
  41. package/lib/infrastructure/storage/NotificationsStore.js +2 -1
  42. package/lib/infrastructure/storage/NotificationsStore.js.map +1 -1
  43. package/lib/infrastructure/utils/dev.d.ts +5 -0
  44. package/lib/infrastructure/utils/dev.d.ts.map +1 -0
  45. package/lib/infrastructure/utils/dev.js +24 -0
  46. package/lib/infrastructure/utils/dev.js.map +1 -0
  47. package/lib/presentation/screens/NotificationsScreen.d.ts +14 -4
  48. package/lib/presentation/screens/NotificationsScreen.d.ts.map +1 -1
  49. package/lib/presentation/screens/NotificationsScreen.js +12 -15
  50. package/lib/presentation/screens/NotificationsScreen.js.map +1 -1
  51. package/package.json +1 -1
  52. package/src/__tests__/NotificationManager.test.ts +215 -0
  53. package/src/__tests__/useNotificationActions.test.ts +189 -0
  54. package/src/__tests__/useNotificationRefresh.test.ts +213 -0
  55. package/src/infrastructure/hooks/actions/useNotificationActions.ts +8 -110
  56. package/src/infrastructure/hooks/actions/useNotificationManagementActions.ts +131 -0
  57. package/src/infrastructure/hooks/useNotifications.ts +37 -11
  58. package/src/infrastructure/hooks/utils/useNotificationRefresh.ts +40 -16
  59. package/src/infrastructure/services/NotificationBadgeManager.ts +28 -0
  60. package/src/infrastructure/services/NotificationManager.ts +51 -217
  61. package/src/infrastructure/services/NotificationPermissions.ts +80 -0
  62. package/src/infrastructure/services/NotificationScheduler.ts +77 -0
  63. package/src/infrastructure/services/delivery/NotificationDelivery.ts +32 -14
  64. package/src/infrastructure/storage/NotificationsStore.ts +3 -2
  65. package/src/infrastructure/utils/dev.ts +25 -0
  66. package/src/presentation/screens/NotificationsScreen.tsx +31 -18
  67. package/src/types/global.d.ts +255 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationBadgeManager.js","sourceRoot":"","sources":["../../../src/infrastructure/services/NotificationBadgeManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,OAAO,wBAAwB;IACnC,KAAK,CAAC,aAAa;QACjB,IAAI,CAAC;YACH,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;gBAC1B,OAAO,MAAM,aAAa,CAAC,kBAAkB,EAAE,CAAC;YAClD,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,oDAAoD,EAAE,KAAK,CAAC,CAAC;YACtE,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,KAAa;QAC/B,IAAI,CAAC;YACH,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;gBAC1B,MAAM,aAAa,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,oDAAoD,EAAE,KAAK,CAAC,CAAC;YACtE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
@@ -1,27 +1,8 @@
1
1
  /**
2
- * NotificationManager
2
+ * NotificationManager - Core Notification Operations
3
3
  *
4
4
  * Offline-first notification system using expo-notifications.
5
5
  * Works in ALL apps (offline, online, hybrid) - no backend required.
6
- *
7
- * Features:
8
- * - Schedule notifications for specific dates/times
9
- * - Repeating notifications (daily, weekly, monthly)
10
- * - Android notification channels
11
- * - Permission handling
12
- * - Cancel individual or all notifications
13
- * - Works completely offline
14
- *
15
- * Use Cases:
16
- * - Reminders (bills, tasks, appointments)
17
- * - Habit tracking (daily streaks)
18
- * - Medication reminders
19
- * - Any app needing local notifications
20
- *
21
- * @module NotificationManager
22
- */
23
- /**
24
- * Trigger types for notifications
25
6
  */
26
7
  export type NotificationTrigger = {
27
8
  type: 'date';
@@ -41,9 +22,6 @@ export type NotificationTrigger = {
41
22
  hour: number;
42
23
  minute: number;
43
24
  };
44
- /**
45
- * Options for scheduling a notification
46
- */
47
25
  export interface ScheduleNotificationOptions {
48
26
  title: string;
49
27
  body: string;
@@ -53,9 +31,6 @@ export interface ScheduleNotificationOptions {
53
31
  badge?: number;
54
32
  categoryIdentifier?: string;
55
33
  }
56
- /**
57
- * Scheduled notification details
58
- */
59
34
  export interface ScheduledNotification {
60
35
  identifier: string;
61
36
  content: {
@@ -65,74 +40,20 @@ export interface ScheduledNotification {
65
40
  };
66
41
  trigger: any;
67
42
  }
68
- /**
69
- * NotificationManager
70
- *
71
- * Handles all notification operations using expo-notifications.
72
- * Works completely offline - no backend, no user IDs, just device-local notifications.
73
- */
74
43
  export declare class NotificationManager {
75
- /**
76
- * Configure notification handler (how notifications appear when app is in foreground)
77
- */
44
+ private permissions;
45
+ private scheduler;
46
+ private badgeManager;
47
+ constructor();
78
48
  static configure(): void;
79
- /**
80
- * Request notification permissions
81
- * iOS: Shows system permission dialog
82
- * Android: Permissions granted by default (Android 13+ requires runtime permission)
83
- */
84
49
  requestPermissions(): Promise<boolean>;
85
- /**
86
- * Check if notification permissions are granted
87
- */
88
50
  hasPermissions(): Promise<boolean>;
89
- /**
90
- * Create Android notification channels (required for Android 8+)
91
- */
92
- private createAndroidChannels;
93
- /**
94
- * Schedule a notification
95
- *
96
- * @example
97
- * // Specific date
98
- * const id = await manager.scheduleNotification({
99
- * title: 'Bill Reminder',
100
- * body: 'Electricity bill due today',
101
- * trigger: { type: 'date', date: new Date('2025-01-15T09:00:00') }
102
- * });
103
- *
104
- * @example
105
- * // Daily reminder
106
- * const id = await manager.scheduleNotification({
107
- * title: 'Daily Workout',
108
- * body: 'Time for your morning workout!',
109
- * trigger: { type: 'daily', hour: 7, minute: 0 }
110
- * });
111
- */
112
51
  scheduleNotification(options: ScheduleNotificationOptions): Promise<string>;
113
- /**
114
- * Cancel a scheduled notification
115
- */
116
52
  cancelNotification(notificationId: string): Promise<void>;
117
- /**
118
- * Cancel all scheduled notifications
119
- */
120
53
  cancelAllNotifications(): Promise<void>;
121
- /**
122
- * Get all scheduled notifications
123
- */
124
54
  getScheduledNotifications(): Promise<ScheduledNotification[]>;
125
- /**
126
- * Dismiss all delivered notifications (clear from notification center)
127
- */
128
55
  dismissAllNotifications(): Promise<void>;
129
- /**
130
- * Get notification badge count (iOS only)
131
- */
132
56
  getBadgeCount(): Promise<number>;
133
- /**
134
- * Set notification badge count (iOS only)
135
- */
136
57
  setBadgeCount(count: number): Promise<void>;
137
58
  }
138
59
  //# sourceMappingURL=NotificationManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationManager.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/NotificationManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAMH;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,I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,EAAE,mBAAmB,CAAC;IAC7B,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC3B,CAAC;IACF,OAAO,EAAE,GAAG,CAAC;CACd;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,SAAS,CAAwB;IACzC,OAAO,CAAC,YAAY,CAA2B;;IAQ/C,MAAM,CAAC,SAAS;IAYV,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAatC,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IASlC,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IAa3E,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWzD,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAWvC,yBAAyB,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAS7D,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IAWxC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAShC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAUlD"}
@@ -1,38 +1,20 @@
1
1
  /**
2
- * NotificationManager
2
+ * NotificationManager - Core Notification Operations
3
3
  *
4
4
  * Offline-first notification system using expo-notifications.
5
5
  * Works in ALL apps (offline, online, hybrid) - no backend required.
6
- *
7
- * Features:
8
- * - Schedule notifications for specific dates/times
9
- * - Repeating notifications (daily, weekly, monthly)
10
- * - Android notification channels
11
- * - Permission handling
12
- * - Cancel individual or all notifications
13
- * - Works completely offline
14
- *
15
- * Use Cases:
16
- * - Reminders (bills, tasks, appointments)
17
- * - Habit tracking (daily streaks)
18
- * - Medication reminders
19
- * - Any app needing local notifications
20
- *
21
- * @module NotificationManager
22
6
  */
23
7
  import * as Notifications from 'expo-notifications';
24
- import * as Device from 'expo-device';
25
- import { Platform } from 'react-native';
26
- /**
27
- * NotificationManager
28
- *
29
- * Handles all notification operations using expo-notifications.
30
- * Works completely offline - no backend, no user IDs, just device-local notifications.
31
- */
8
+ import { NotificationPermissions } from './NotificationPermissions';
9
+ import { NotificationScheduler } from './NotificationScheduler';
10
+ import { NotificationBadgeManager } from './NotificationBadgeManager';
11
+ import { devLog, devError } from '../utils/dev';
32
12
  export class NotificationManager {
33
- /**
34
- * Configure notification handler (how notifications appear when app is in foreground)
35
- */
13
+ constructor() {
14
+ this.permissions = new NotificationPermissions();
15
+ this.scheduler = new NotificationScheduler();
16
+ this.badgeManager = new NotificationBadgeManager();
17
+ }
36
18
  static configure() {
37
19
  Notifications.setNotificationHandler({
38
20
  handleNotification: async () => ({
@@ -41,243 +23,94 @@ export class NotificationManager {
41
23
  shouldSetBadge: true,
42
24
  }),
43
25
  });
26
+ devLog('[NotificationManager] Configured notification handler');
44
27
  }
45
- /**
46
- * Request notification permissions
47
- * iOS: Shows system permission dialog
48
- * Android: Permissions granted by default (Android 13+ requires runtime permission)
49
- */
50
28
  async requestPermissions() {
51
29
  try {
52
- if (!Device.isDevice) {
53
- console.warn('[NotificationManager] Notifications only work on physical devices');
54
- return false;
55
- }
56
- const permissionsResponse = await Notifications.getPermissionsAsync();
57
- const existingStatus = permissionsResponse.status || (permissionsResponse.granted ? 'granted' : 'denied');
58
- let finalStatus = existingStatus;
59
- if (existingStatus !== 'granted') {
60
- const requestResponse = await Notifications.requestPermissionsAsync();
61
- finalStatus = requestResponse.status || (requestResponse.granted ? 'granted' : 'denied');
62
- }
63
- if (Platform.OS === 'android') {
64
- await this.createAndroidChannels();
65
- }
66
- return finalStatus === 'granted';
30
+ const result = await this.permissions.requestPermissions();
31
+ devLog('[NotificationManager] Permissions requested:', result);
32
+ return result;
67
33
  }
68
34
  catch (error) {
69
- console.error('[NotificationManager] Permission request failed:', error);
35
+ devError('[NotificationManager] Permission request failed:', error);
70
36
  return false;
71
37
  }
72
38
  }
73
- /**
74
- * Check if notification permissions are granted
75
- */
76
39
  async hasPermissions() {
77
40
  try {
78
- if (!Device.isDevice)
79
- return false;
80
- const permissionsResponse = await Notifications.getPermissionsAsync();
81
- return permissionsResponse.status === 'granted' || permissionsResponse.granted === true;
41
+ return await this.permissions.hasPermissions();
82
42
  }
83
43
  catch (error) {
84
- console.error('[NotificationManager] Permission check failed:', error);
44
+ devError('[NotificationManager] Permission check failed:', error);
85
45
  return false;
86
46
  }
87
47
  }
88
- /**
89
- * Create Android notification channels (required for Android 8+)
90
- */
91
- async createAndroidChannels() {
92
- if (Platform.OS !== 'android')
93
- return;
94
- try {
95
- await Notifications.setNotificationChannelAsync('default', {
96
- name: 'Default',
97
- importance: Notifications.AndroidImportance.DEFAULT,
98
- vibrationPattern: [0, 250, 250, 250],
99
- sound: 'default',
100
- lightColor: '#3B82F6',
101
- });
102
- await Notifications.setNotificationChannelAsync('reminders', {
103
- name: 'Reminders',
104
- importance: Notifications.AndroidImportance.HIGH,
105
- vibrationPattern: [0, 250, 250, 250],
106
- sound: 'default',
107
- lightColor: '#3B82F6',
108
- enableVibrate: true,
109
- });
110
- await Notifications.setNotificationChannelAsync('urgent', {
111
- name: 'Urgent',
112
- importance: Notifications.AndroidImportance.MAX,
113
- vibrationPattern: [0, 500, 250, 500],
114
- sound: 'default',
115
- lightColor: '#EF4444',
116
- enableVibrate: true,
117
- });
118
- }
119
- catch (error) {
120
- console.error('[NotificationManager] Android channel creation failed:', error);
121
- }
122
- }
123
- /**
124
- * Schedule a notification
125
- *
126
- * @example
127
- * // Specific date
128
- * const id = await manager.scheduleNotification({
129
- * title: 'Bill Reminder',
130
- * body: 'Electricity bill due today',
131
- * trigger: { type: 'date', date: new Date('2025-01-15T09:00:00') }
132
- * });
133
- *
134
- * @example
135
- * // Daily reminder
136
- * const id = await manager.scheduleNotification({
137
- * title: 'Daily Workout',
138
- * body: 'Time for your morning workout!',
139
- * trigger: { type: 'daily', hour: 7, minute: 0 }
140
- * });
141
- */
142
48
  async scheduleNotification(options) {
143
49
  try {
144
- const { title, body, data = {}, trigger, sound = true, badge, categoryIdentifier } = options;
145
- let notificationTrigger;
146
- if (trigger.type === 'date') {
147
- notificationTrigger = {
148
- date: trigger.date,
149
- channelId: categoryIdentifier || 'default',
150
- };
151
- }
152
- else if (trigger.type === 'daily') {
153
- notificationTrigger = {
154
- hour: trigger.hour,
155
- minute: trigger.minute,
156
- repeats: true,
157
- channelId: categoryIdentifier || 'reminders',
158
- };
159
- }
160
- else if (trigger.type === 'weekly') {
161
- notificationTrigger = {
162
- weekday: trigger.weekday,
163
- hour: trigger.hour,
164
- minute: trigger.minute,
165
- repeats: true,
166
- channelId: categoryIdentifier || 'reminders',
167
- };
168
- }
169
- else if (trigger.type === 'monthly') {
170
- notificationTrigger = {
171
- day: trigger.day,
172
- hour: trigger.hour,
173
- minute: trigger.minute,
174
- repeats: true,
175
- channelId: categoryIdentifier || 'reminders',
176
- };
177
- }
178
- const notificationId = await Notifications.scheduleNotificationAsync({
179
- content: {
180
- title,
181
- body,
182
- data,
183
- sound: sound === true ? 'default' : sound || undefined,
184
- badge,
185
- categoryIdentifier,
186
- priority: Notifications.AndroidNotificationPriority.HIGH,
187
- vibrate: [0, 250, 250, 250],
188
- },
189
- trigger: notificationTrigger,
190
- });
191
- return notificationId;
50
+ const id = await this.scheduler.scheduleNotification(options);
51
+ devLog('[NotificationManager] Notification scheduled:', id);
52
+ return id;
192
53
  }
193
54
  catch (error) {
194
- console.error('[NotificationManager] Schedule notification failed:', error);
55
+ devError('[NotificationManager] Schedule notification failed:', error);
195
56
  throw error;
196
57
  }
197
58
  }
198
- /**
199
- * Cancel a scheduled notification
200
- */
201
59
  async cancelNotification(notificationId) {
202
60
  try {
203
- await Notifications.cancelScheduledNotificationAsync(notificationId);
61
+ await this.scheduler.cancelNotification(notificationId);
62
+ devLog('[NotificationManager] Notification cancelled:', notificationId);
204
63
  }
205
64
  catch (error) {
206
- console.error('[NotificationManager] Cancel notification failed:', error);
65
+ devError('[NotificationManager] Cancel notification failed:', error);
207
66
  throw error;
208
67
  }
209
68
  }
210
- /**
211
- * Cancel all scheduled notifications
212
- */
213
69
  async cancelAllNotifications() {
214
70
  try {
215
- await Notifications.cancelAllScheduledNotificationsAsync();
71
+ await this.scheduler.cancelAllNotifications();
72
+ devLog('[NotificationManager] All notifications cancelled');
216
73
  }
217
74
  catch (error) {
218
- console.error('[NotificationManager] Cancel all notifications failed:', error);
75
+ devError('[NotificationManager] Cancel all notifications failed:', error);
219
76
  throw error;
220
77
  }
221
78
  }
222
- /**
223
- * Get all scheduled notifications
224
- */
225
79
  async getScheduledNotifications() {
226
80
  try {
227
- const notifications = await Notifications.getAllScheduledNotificationsAsync();
228
- return notifications.map(notification => ({
229
- identifier: notification.identifier,
230
- content: {
231
- title: notification.content.title || '',
232
- body: notification.content.body || '',
233
- data: notification.content.data,
234
- },
235
- trigger: notification.trigger,
236
- }));
81
+ return await this.scheduler.getScheduledNotifications();
237
82
  }
238
83
  catch (error) {
239
- console.error('[NotificationManager] Get scheduled notifications failed:', error);
84
+ devError('[NotificationManager] Get scheduled notifications failed:', error);
240
85
  return [];
241
86
  }
242
87
  }
243
- /**
244
- * Dismiss all delivered notifications (clear from notification center)
245
- */
246
88
  async dismissAllNotifications() {
247
89
  try {
248
90
  await Notifications.dismissAllNotificationsAsync();
91
+ devLog('[NotificationManager] All notifications dismissed');
249
92
  }
250
93
  catch (error) {
251
- console.error('[NotificationManager] Dismiss all notifications failed:', error);
94
+ devError('[NotificationManager] Dismiss all notifications failed:', error);
252
95
  throw error;
253
96
  }
254
97
  }
255
- /**
256
- * Get notification badge count (iOS only)
257
- */
258
98
  async getBadgeCount() {
259
99
  try {
260
- if (Platform.OS === 'ios') {
261
- return await Notifications.getBadgeCountAsync();
262
- }
263
- return 0;
100
+ return await this.badgeManager.getBadgeCount();
264
101
  }
265
102
  catch (error) {
266
- console.error('[NotificationManager] Get badge count failed:', error);
103
+ devError('[NotificationManager] Get badge count failed:', error);
267
104
  return 0;
268
105
  }
269
106
  }
270
- /**
271
- * Set notification badge count (iOS only)
272
- */
273
107
  async setBadgeCount(count) {
274
108
  try {
275
- if (Platform.OS === 'ios') {
276
- await Notifications.setBadgeCountAsync(count);
277
- }
109
+ await this.badgeManager.setBadgeCount(count);
110
+ devLog('[NotificationManager] Badge count set:', count);
278
111
  }
279
112
  catch (error) {
280
- console.error('[NotificationManager] Set badge count failed:', error);
113
+ devError('[NotificationManager] Set badge count failed:', error);
281
114
  throw error;
282
115
  }
283
116
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationManager.js","sourceRoot":"","sources":["../../../src/infrastructure/services/NotificationManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAqCxC;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAC9B;;OAEG;IACH,MAAM,CAAC,SAAS;QACd,aAAa,CAAC,sBAAsB,CAAC;YACnC,kBAAkB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;gBAC/B,eAAe,EAAE,IAAI;gBACrB,eAAe,EAAE,IAAI;gBACrB,cAAc,EAAE,IAAI;aACrB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,kBAAkB;QACtB,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gB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CAAC;YAChD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;YACtE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
1
+ {"version":3,"file":"NotificationManager.js","sourceRoot":"","sources":["../../../src/infrastructure/services/NotificationManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AA4BhD,MAAM,OAAO,mBAAmB;IAK9B;QACE,IAAI,CAAC,WAAW,GAAG,IAAI,uBAAuB,EAAE,CAAC;QACjD,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAC7C,IAAI,CAAC,YAAY,GAAG,IAAI,wBAAwB,EAAE,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,SAAS;QACd,aAAa,CAAC,sBAAsB,CAAC;YACnC,kBAAkB,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;gBAC/B,eAAe,EAAE,IAAI;gBACrB,eAAe,EAAE,IAAI;gBACrB,cAAc,EAAE,IAAI;aACrB,CAAC;SACH,CAAC,CAAC;QAEH,MAAM,CAAC,uDAAuD,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAC;YAE3D,MAAM,CAAC,8CAA8C,EAAE,MAAM,CAAC,CAAC;YAE/D,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,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(): Promise<boolean>;
4
+ private createAndroidChannels;
5
+ }
6
+ //# sourceMappingURL=NotificationPermissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationPermissions.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/NotificationPermissions.ts"],"names":[],"mappings":"AAKA,qBAAa,uBAAuB;IAC5B,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IA2BtC,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;YAW1B,qBAAqB;CAmCpC"}
@@ -0,0 +1,75 @@
1
+ import * as Notifications from 'expo-notifications';
2
+ import * as Device from 'expo-device';
3
+ import { Platform } from 'react-native';
4
+ import { devWarn, devError, devLog } from '../utils/dev';
5
+ export class NotificationPermissions {
6
+ async requestPermissions() {
7
+ try {
8
+ if (!Device.isDevice) {
9
+ devWarn('[NotificationPermissions] Notifications only work on physical devices');
10
+ return false;
11
+ }
12
+ const permissionsResponse = await Notifications.getPermissionsAsync();
13
+ const existingStatus = permissionsResponse.status || (permissionsResponse.granted ? 'granted' : 'denied');
14
+ let finalStatus = existingStatus;
15
+ if (existingStatus !== 'granted') {
16
+ const requestResponse = await Notifications.requestPermissionsAsync();
17
+ finalStatus = requestResponse.status || (requestResponse.granted ? 'granted' : 'denied');
18
+ }
19
+ if (Platform.OS === 'android') {
20
+ await this.createAndroidChannels();
21
+ }
22
+ return finalStatus === 'granted';
23
+ }
24
+ catch (error) {
25
+ devError('[NotificationPermissions] Permission request failed:', error);
26
+ return false;
27
+ }
28
+ }
29
+ async hasPermissions() {
30
+ try {
31
+ if (!Device.isDevice)
32
+ return false;
33
+ const permissionsResponse = await Notifications.getPermissionsAsync();
34
+ return permissionsResponse.status === 'granted' || permissionsResponse.granted === true;
35
+ }
36
+ catch (error) {
37
+ devError('[NotificationPermissions] Permission check failed:', error);
38
+ return false;
39
+ }
40
+ }
41
+ async createAndroidChannels() {
42
+ if (Platform.OS !== 'android')
43
+ return;
44
+ try {
45
+ await Notifications.setNotificationChannelAsync('default', {
46
+ name: 'Default',
47
+ importance: Notifications.AndroidImportance.DEFAULT,
48
+ vibrationPattern: [0, 250, 250, 250],
49
+ sound: 'default',
50
+ lightColor: '#3B82F6',
51
+ });
52
+ await Notifications.setNotificationChannelAsync('reminders', {
53
+ name: 'Reminders',
54
+ importance: Notifications.AndroidImportance.HIGH,
55
+ vibrationPattern: [0, 250, 250, 250],
56
+ sound: 'default',
57
+ lightColor: '#3B82F6',
58
+ enableVibrate: true,
59
+ });
60
+ await Notifications.setNotificationChannelAsync('urgent', {
61
+ name: 'Urgent',
62
+ importance: Notifications.AndroidImportance.MAX,
63
+ vibrationPattern: [0, 500, 250, 500],
64
+ sound: 'default',
65
+ lightColor: '#EF4444',
66
+ enableVibrate: true,
67
+ });
68
+ devLog('[NotificationPermissions] Android channels created');
69
+ }
70
+ catch (error) {
71
+ devError('[NotificationPermissions] Android channel creation failed:', error);
72
+ }
73
+ }
74
+ }
75
+ //# sourceMappingURL=NotificationPermissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationPermissions.js","sourceRoot":"","sources":["../../../src/infrastructure/services/NotificationPermissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,OAAO,uBAAuB;IAClC,KAAK,CAAC,kBAAkB;QACtB,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACrB,OAAO,CAAC,uEAAuE,CAAC,CAAC;gBACjF,OAAO,KAAK,CAAC;YACf,CAAC;YAED,MAAM,mBAAmB,GAAG,MAAM,aAAa,CAAC,mBAAmB,EAAE,CAAC;YACtE,MAAM,cAAc,GAAI,mBAA2B,CA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,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,OAAO;gBACnD,gBAAgB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;gBACpC,KAAK,EAAE,SAAS;gBAChB,UAAU,EAAE,SAAS;aACtB,CAAC,CAAC;YAEH,MAAM,aAAa,CAAC,2BAA2B,CAAC,WAAW,EAAE;gBAC3D,IAAI,EAAE,WAAW;gBACjB,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,IAAI;gBAChD,gBAAgB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;gBACpC,KAAK,EAAE,SAAS;gBAChB,UAAU,EAAE,SAAS;gBACrB,aAAa,EAAE,IAAI;aACpB,CAAC,CAAC;YAEH,MAAM,aAAa,CAAC,2BAA2B,CAAC,QAAQ,EAAE;gBACxD,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,aAAa,CAAC,iBAAiB,CAAC,GAAG;gBAC/C,gBAAgB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;gBACpC,KAAK,EAAE,SAAS;gBAChB,UAAU,EAAE,SAAS;gBACrB,aAAa,EAAE,IAAI;aACpB,CAAC,CAAC;YAEH,MAAM,CAAC,oDAAoD,CAAC,CAAC;QAC/D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,4DAA4D,EAAE,KAAK,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import type { ScheduleNotificationOptions, ScheduledNotification } from './NotificationManager';
2
+ export declare class NotificationScheduler {
3
+ scheduleNotification(options: ScheduleNotificationOptions): Promise<string>;
4
+ cancelNotification(notificationId: string): Promise<void>;
5
+ cancelAllNotifications(): Promise<void>;
6
+ getScheduledNotifications(): Promise<ScheduledNotification[]>;
7
+ }
8
+ //# sourceMappingURL=NotificationScheduler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationScheduler.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/services/NotificationScheduler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAErH,qBAAa,qBAAqB;IAC1B,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IAoD3E,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvC,yBAAyB,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;CAYpE"}