react-native-notification-sdk 1.0.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 (103) hide show
  1. package/README.md +3082 -0
  2. package/dist/NotificationSDK.d.ts +6 -0
  3. package/dist/NotificationSDK.d.ts.map +1 -0
  4. package/dist/background/BackgroundHandler.d.ts +7 -0
  5. package/dist/background/BackgroundHandler.d.ts.map +1 -0
  6. package/dist/background/registerBackgroundHandler.d.ts +5 -0
  7. package/dist/background/registerBackgroundHandler.d.ts.map +1 -0
  8. package/dist/constants/SDK.d.ts +2 -0
  9. package/dist/constants/SDK.d.ts.map +1 -0
  10. package/dist/core/NotificationManager.d.ts +28 -0
  11. package/dist/core/NotificationManager.d.ts.map +1 -0
  12. package/dist/core/NotificationSDK.d.ts +25 -0
  13. package/dist/core/NotificationSDK.d.ts.map +1 -0
  14. package/dist/core/SDKContainer.d.ts +16 -0
  15. package/dist/core/SDKContainer.d.ts.map +1 -0
  16. package/dist/errors/FirebaseInitializationError.d.ts +5 -0
  17. package/dist/errors/FirebaseInitializationError.d.ts.map +1 -0
  18. package/dist/errors/InvalidNotificationError.d.ts +5 -0
  19. package/dist/errors/InvalidNotificationError.d.ts.map +1 -0
  20. package/dist/errors/NotifeeInitializationError.d.ts +5 -0
  21. package/dist/errors/NotifeeInitializationError.d.ts.map +1 -0
  22. package/dist/errors/NotificationSDKError.d.ts +4 -0
  23. package/dist/errors/NotificationSDKError.d.ts.map +1 -0
  24. package/dist/errors/PermissionDeniedError.d.ts +5 -0
  25. package/dist/errors/PermissionDeniedError.d.ts.map +1 -0
  26. package/dist/errors/SDKNotInitializedError.d.ts +5 -0
  27. package/dist/errors/SDKNotInitializedError.d.ts.map +1 -0
  28. package/dist/errors/index.d.ts +7 -0
  29. package/dist/errors/index.d.ts.map +1 -0
  30. package/dist/events/EventBus.d.ts +11 -0
  31. package/dist/events/EventBus.d.ts.map +1 -0
  32. package/dist/firebase/FirebaseListener.d.ts +28 -0
  33. package/dist/firebase/FirebaseListener.d.ts.map +1 -0
  34. package/dist/firebase/FirebaseService.d.ts +24 -0
  35. package/dist/firebase/FirebaseService.d.ts.map +1 -0
  36. package/dist/index.cjs +858 -0
  37. package/dist/index.cjs.map +1 -0
  38. package/dist/index.d.ts +228 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +853 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/interfaces/IEventManager.d.ts +18 -0
  43. package/dist/interfaces/IEventManager.d.ts.map +1 -0
  44. package/dist/interfaces/ILogger.d.ts +6 -0
  45. package/dist/interfaces/ILogger.d.ts.map +1 -0
  46. package/dist/logger/Logger.d.ts +9 -0
  47. package/dist/logger/Logger.d.ts.map +1 -0
  48. package/dist/logging/ConsoleLogger.d.ts +9 -0
  49. package/dist/logging/ConsoleLogger.d.ts.map +1 -0
  50. package/dist/mappers/NotificationMapper.d.ts +14 -0
  51. package/dist/mappers/NotificationMapper.d.ts.map +1 -0
  52. package/dist/notifee/NotifeeService.d.ts +52 -0
  53. package/dist/notifee/NotifeeService.d.ts.map +1 -0
  54. package/dist/permissions/PermissionService.d.ts +35 -0
  55. package/dist/permissions/PermissionService.d.ts.map +1 -0
  56. package/dist/sdk/NotificationContainer.d.ts +16 -0
  57. package/dist/sdk/NotificationContainer.d.ts.map +1 -0
  58. package/dist/sdk/NotificationManager.d.ts +30 -0
  59. package/dist/sdk/NotificationManager.d.ts.map +1 -0
  60. package/dist/sdk/NotificationSDK.d.ts +29 -0
  61. package/dist/sdk/NotificationSDK.d.ts.map +1 -0
  62. package/dist/types/AndroidNotificationOptions.d.ts +12 -0
  63. package/dist/types/AndroidNotificationOptions.d.ts.map +1 -0
  64. package/dist/types/DisplayNotification.d.ts +37 -0
  65. package/dist/types/DisplayNotification.d.ts.map +1 -0
  66. package/dist/types/IOSNotificationOptions.d.ts +6 -0
  67. package/dist/types/IOSNotificationOptions.d.ts.map +1 -0
  68. package/dist/types/NotificationAction.d.ts +9 -0
  69. package/dist/types/NotificationAction.d.ts.map +1 -0
  70. package/dist/types/NotificationChannel.d.ts +11 -0
  71. package/dist/types/NotificationChannel.d.ts.map +1 -0
  72. package/dist/types/NotificationConfig.d.ts +47 -0
  73. package/dist/types/NotificationConfig.d.ts.map +1 -0
  74. package/dist/types/NotificationEvents.d.ts +30 -0
  75. package/dist/types/NotificationEvents.d.ts.map +1 -0
  76. package/dist/types/NotificationPayload.d.ts +15 -0
  77. package/dist/types/NotificationPayload.d.ts.map +1 -0
  78. package/dist/types/NotificationSDKStatus.d.ts +11 -0
  79. package/dist/types/NotificationSDKStatus.d.ts.map +1 -0
  80. package/dist/types/NotificationTrigger.d.ts +20 -0
  81. package/dist/types/NotificationTrigger.d.ts.map +1 -0
  82. package/dist/types/PermissionStatus.d.ts +2 -0
  83. package/dist/types/PermissionStatus.d.ts.map +1 -0
  84. package/dist/types/ScheduledNotification.d.ts +6 -0
  85. package/dist/types/ScheduledNotification.d.ts.map +1 -0
  86. package/dist/types/index.d.ts +10 -0
  87. package/dist/types/index.d.ts.map +1 -0
  88. package/dist/utils/NotificationMapper.d.ts +14 -0
  89. package/dist/utils/NotificationMapper.d.ts.map +1 -0
  90. package/dist/validators/DisplayNotificationValidator.d.ts +5 -0
  91. package/dist/validators/DisplayNotificationValidator.d.ts.map +1 -0
  92. package/dist/validators/NotificationActionValidator.d.ts +5 -0
  93. package/dist/validators/NotificationActionValidator.d.ts.map +1 -0
  94. package/dist/validators/NotificationChannelValidator.d.ts +5 -0
  95. package/dist/validators/NotificationChannelValidator.d.ts.map +1 -0
  96. package/dist/validators/ScheduledNotificationValidator.d.ts +5 -0
  97. package/dist/validators/ScheduledNotificationValidator.d.ts.map +1 -0
  98. package/dist/validators/ValidationAssertions.d.ts +6 -0
  99. package/dist/validators/ValidationAssertions.d.ts.map +1 -0
  100. package/package.json +77 -0
  101. package/plugins/android/withMaven.js +22 -0
  102. package/plugins/app.plugin.js +7 -0
  103. package/plugins/ios/withModularHeaders.js +16 -0
package/README.md ADDED
@@ -0,0 +1,3082 @@
1
+ # React Native Notification SDK
2
+
3
+ <p align="center">
4
+ <img src="./assets/logo.png" width="180" alt="Omnics Technologies Logo"/>
5
+ </p>
6
+
7
+ <p align="center">
8
+ A complete Push Notification SDK for React Native with built-in support for Firebase Cloud Messaging (FCM), Notifee, React Native CLI, and Expo Development Builds.
9
+ </p>
10
+
11
+ ---
12
+
13
+ ## Features
14
+
15
+ - 🚀 Simple SDK initialization
16
+ - 🔔 Local Notifications
17
+ - ☁️ Firebase Cloud Messaging (FCM)
18
+ - 📅 Scheduled Notifications
19
+ - 🎯 Notification Actions
20
+ - 📲 Notification Open Events
21
+ - 🗑 Notification Dismiss Events
22
+ - 🔄 Automatic Token Refresh Handling
23
+ - 🔐 Permission Management
24
+ - 📡 Background Notification Handling
25
+ - 📥 Foreground Notification Handling
26
+ - 🏗 Android Notification Channels
27
+ - 🍎 iOS Notification Categories
28
+ - 📱 React Native CLI Support
29
+ - ⚡ Expo Development Build Support
30
+ - 🧩 Built on Firebase Messaging + Notifee
31
+ - 🛠 TypeScript Support
32
+ - 🎯 Strongly Typed APIs
33
+ - 📖 Comprehensive Event System
34
+
35
+ ---
36
+
37
+ # Why use this SDK?
38
+
39
+ Integrating Firebase Cloud Messaging and Notifee manually requires configuring multiple native modules, handling permissions, creating notification channels, managing foreground and background events, and dealing with platform-specific APIs.
40
+
41
+ This SDK abstracts those complexities into a single, easy-to-use API while still exposing advanced capabilities when needed.
42
+
43
+ ---
44
+
45
+ # Supported Platforms
46
+
47
+ | Platform | Supported |
48
+ | ----------------------- | --------- |
49
+ | Android | ✅ |
50
+ | iOS | ✅ |
51
+ | React Native CLI | ✅ |
52
+ | Expo Development Builds | ✅ |
53
+ | Expo Go | ❌ |
54
+
55
+ > **Expo Go is not supported** because Firebase Messaging and Notifee require native native modules that are unavailable in Expo Go.
56
+
57
+ ---
58
+
59
+ # Compatibility
60
+
61
+ | Dependency | Version |
62
+ | -------------------------------- | -------------------------- |
63
+ | React Native | >= 0.80 |
64
+ | React | >= 19 |
65
+ | Expo SDK | >= 53 (Development Builds) |
66
+ | @react-native-firebase/app | >= 24 |
67
+ | @react-native-firebase/messaging | >= 24 |
68
+ | @notifee/react-native | >= 9 |
69
+
70
+ ---
71
+
72
+ # Installation
73
+
74
+ ## npm
75
+
76
+ ```bash
77
+ npm install react-native-notification-sdk
78
+ ```
79
+
80
+ ## yarn
81
+
82
+ ```bash
83
+ yarn add react-native-notification-sdk
84
+ ```
85
+
86
+ ## pnpm
87
+
88
+ ```bash
89
+ pnpm add react-native-notification-sdk
90
+ ```
91
+
92
+ ---
93
+
94
+ # Install Peer Dependencies
95
+
96
+ The SDK relies on Firebase Messaging and Notifee.
97
+
98
+ Install them using your preferred package manager.
99
+
100
+ ### npm
101
+
102
+ ```bash
103
+ npm install @react-native-firebase/app
104
+ npm install @react-native-firebase/messaging
105
+ npm install @notifee/react-native
106
+ ```
107
+
108
+ ### yarn
109
+
110
+ ```bash
111
+ yarn add @react-native-firebase/app
112
+ yarn add @react-native-firebase/messaging
113
+ yarn add @notifee/react-native
114
+ ```
115
+
116
+ ### pnpm
117
+
118
+ ```bash
119
+ pnpm add @react-native-firebase/app
120
+ pnpm add @react-native-firebase/messaging
121
+ pnpm add @notifee/react-native
122
+ ```
123
+
124
+ ---
125
+
126
+ # React Native CLI Setup
127
+
128
+ ## Android
129
+
130
+ Nothing additional is required.
131
+
132
+ React Native's autolinking will automatically link Firebase and Notifee.
133
+
134
+ ## iOS
135
+
136
+ After installing dependencies:
137
+
138
+ ```bash
139
+ cd ios
140
+ pod install
141
+ ```
142
+
143
+ ---
144
+
145
+ # Expo Development Build Setup
146
+
147
+ Add the following plugins to your `app.json`.
148
+
149
+ ```json
150
+ {
151
+ "expo": {
152
+ "plugins": [
153
+ "@react-native-firebase/app",
154
+ "@react-native-firebase/messaging",
155
+ "react-native-notification-sdk/plugins"
156
+ ]
157
+ }
158
+ }
159
+ ```
160
+
161
+ Generate native projects:
162
+
163
+ ```bash
164
+ npx expo prebuild --clean
165
+ ```
166
+
167
+ Run Android:
168
+
169
+ ```bash
170
+ npx expo run:android
171
+ ```
172
+
173
+ Run iOS:
174
+
175
+ ```bash
176
+ npx expo run:ios
177
+ ```
178
+
179
+ ---
180
+
181
+ # Firebase Setup
182
+
183
+ Before using the SDK, you must configure a Firebase project.
184
+
185
+ ---
186
+
187
+ ## Step 1 – Create Firebase Project
188
+
189
+ 1. Open Firebase Console.
190
+ 2. Click **Create Project**.
191
+ 3. Enter your project name.
192
+ 4. Continue through the wizard.
193
+ 5. Finish project creation.
194
+
195
+ ---
196
+
197
+ ## Step 2 – Register Android App
198
+
199
+ Inside Firebase:
200
+
201
+ **Project Settings**
202
+
203
+
204
+
205
+ **General**
206
+
207
+
208
+
209
+ **Add App**
210
+
211
+
212
+
213
+ **Android**
214
+
215
+ Enter:
216
+
217
+ - Android Package Name
218
+ - App Nickname (optional)
219
+
220
+ Example:
221
+
222
+ ```
223
+ com.example.myapp
224
+ ```
225
+
226
+ > **Important**
227
+
228
+ The package name entered here **must exactly match** the package name used in your Android application.
229
+
230
+ If it does not match, Gradle will fail with:
231
+
232
+ ```
233
+ No matching client found for package name
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Step 3 – Download google-services.json
239
+
240
+ Firebase will generate:
241
+
242
+ ```
243
+ google-services.json
244
+ ```
245
+
246
+ Copy it to:
247
+
248
+ ```
249
+ android/app/google-services.json
250
+ ```
251
+
252
+ ---
253
+
254
+ ## Step 4 – Register iOS App
255
+
256
+ Again in Firebase:
257
+
258
+ **Add App**
259
+
260
+
261
+
262
+ **iOS**
263
+
264
+ Enter:
265
+
266
+ Bundle Identifier
267
+
268
+ Example:
269
+
270
+ ```
271
+ com.example.myapp
272
+ ```
273
+
274
+ Again, this **must exactly match** your Xcode Bundle Identifier.
275
+
276
+ ---
277
+
278
+ ## Step 5 – Download GoogleService-Info.plist
279
+
280
+ Firebase generates:
281
+
282
+ ```
283
+ GoogleService-Info.plist
284
+ ```
285
+
286
+ Add it to your iOS project root.
287
+
288
+ For Expo:
289
+
290
+ ```
291
+ GoogleService-Info.plist
292
+ ```
293
+
294
+ should be referenced in:
295
+
296
+ ```json
297
+ {
298
+ "expo": {
299
+ "ios": {
300
+ "googleServicesFile": "./GoogleService-Info.plist"
301
+ }
302
+ }
303
+ }
304
+ ```
305
+
306
+ ---
307
+
308
+ # Configuring APNs (iOS Push Notifications)
309
+
310
+ Apple devices receive notifications through the **Apple Push Notification service (APNs)**.
311
+
312
+ Without APNs, Firebase Cloud Messaging cannot deliver notifications to iOS devices.
313
+
314
+ ---
315
+
316
+ ## Step 1 – Apple Developer Account
317
+
318
+ Log in to:
319
+
320
+ https://developer.apple.com
321
+
322
+ Open:
323
+
324
+ Certificates, Identifiers & Profiles
325
+
326
+ ---
327
+
328
+ ## Step 2 – Create or Select an App ID
329
+
330
+ Open **Identifiers**.
331
+
332
+ Select your application.
333
+
334
+ Enable:
335
+
336
+ - Push Notifications
337
+
338
+ Save the changes.
339
+
340
+ ---
341
+
342
+ ## Step 3 – Create an APNs Authentication Key
343
+
344
+ Navigate to:
345
+
346
+ Keys
347
+
348
+
349
+
350
+ Create a new key.
351
+
352
+ Enable:
353
+
354
+ **Apple Push Notifications service (APNs)**
355
+
356
+ Download the generated `.p8` file.
357
+
358
+ > **Important:** Apple allows the `.p8` key to be downloaded only once. Store it securely.
359
+
360
+ Record the following values:
361
+
362
+ - Key ID
363
+ - Team ID
364
+
365
+ ---
366
+
367
+ ## Step 4 – Upload APNs Key to Firebase
368
+
369
+ Open Firebase Console.
370
+
371
+ Navigate to:
372
+
373
+ Project Settings
374
+
375
+
376
+
377
+ Cloud Messaging
378
+
379
+
380
+
381
+ Apple App Configuration
382
+
383
+ Upload:
384
+
385
+ - APNs Authentication Key (`.p8`)
386
+ - Key ID
387
+ - Team ID
388
+
389
+ Click **Save**.
390
+
391
+ ---
392
+
393
+ ## Step 5 – Enable Capabilities in Xcode
394
+
395
+ Open your iOS project in Xcode.
396
+
397
+ Select your target.
398
+
399
+ Open:
400
+
401
+ Signing & Capabilities
402
+
403
+ Enable:
404
+
405
+ - Push Notifications
406
+ - Background Modes
407
+
408
+ Inside Background Modes enable:
409
+
410
+ - Remote Notifications
411
+
412
+ ---
413
+
414
+ # Notification Flow
415
+
416
+ Android
417
+
418
+ ```
419
+ Server
420
+
421
+ Firebase Cloud Messaging
422
+
423
+ Android Device
424
+
425
+ Notification SDK
426
+ ```
427
+
428
+ iOS
429
+
430
+ ```
431
+ Server
432
+
433
+ Firebase Cloud Messaging
434
+
435
+ Apple Push Notification Service (APNs)
436
+
437
+ iPhone
438
+
439
+ Notification SDK
440
+ ```
441
+
442
+ ---
443
+
444
+ # Project Ready
445
+
446
+ After completing the above steps:
447
+
448
+ ✅ Firebase configured
449
+
450
+ ✅ Android configured
451
+
452
+ ✅ iOS configured
453
+
454
+ ✅ Expo configured (if applicable)
455
+
456
+ You are now ready to initialize the Notification SDK.
457
+
458
+ ➡️ Continue to **Part 2 – SDK Initialization & Configuration**
459
+
460
+ # SDK Initialization & Configuration
461
+
462
+ After completing the native platform setup, initialize the SDK when your application starts.
463
+
464
+ Typically, this is done inside your root component (`App.tsx`) or your application's entry point.
465
+
466
+ ---
467
+
468
+ # Basic Initialization
469
+
470
+ ```tsx
471
+ import Notifications from "react-native-notification-sdk";
472
+
473
+ await Notifications.initialize({
474
+ debug: true,
475
+ });
476
+ ```
477
+
478
+ ---
479
+
480
+ # Production Initialization
481
+
482
+ ```tsx
483
+ import Notifications from "react-native-notification-sdk";
484
+
485
+ await Notifications.initialize({
486
+ debug: false,
487
+
488
+ foreground: {
489
+ displayNotifications: true,
490
+ },
491
+
492
+ background: {
493
+ displayNotifications: true,
494
+ },
495
+ });
496
+ ```
497
+
498
+ ---
499
+
500
+ # Advanced Initialization
501
+
502
+ ```tsx
503
+ import Notifications from "react-native-notification-sdk";
504
+
505
+ await Notifications.initialize({
506
+ debug: true,
507
+
508
+ foreground: {
509
+ displayNotifications: true,
510
+ },
511
+
512
+ background: {
513
+ displayNotifications: true,
514
+ },
515
+
516
+ channels: [
517
+ {
518
+ id: "default",
519
+ name: "Default Notifications",
520
+ importance: "high",
521
+ },
522
+
523
+ {
524
+ id: "orders",
525
+ name: "Orders",
526
+ importance: "high",
527
+ },
528
+
529
+ {
530
+ id: "marketing",
531
+ name: "Marketing",
532
+ importance: "default",
533
+ },
534
+ ],
535
+ });
536
+ ```
537
+
538
+ ---
539
+
540
+ # Initialize Only Once
541
+
542
+ The SDK is designed as a singleton.
543
+
544
+ Calling:
545
+
546
+ ```tsx
547
+ await Notifications.initialize(...)
548
+ ```
549
+
550
+ multiple times is safe.
551
+
552
+ Subsequent calls are ignored after the SDK has been initialized.
553
+
554
+ ---
555
+
556
+ # Configuration Reference
557
+
558
+ ## debug
559
+
560
+ Enables SDK logs.
561
+
562
+ ```tsx
563
+ debug: true;
564
+ ```
565
+
566
+ Default
567
+
568
+ ```tsx
569
+ false;
570
+ ```
571
+
572
+ When enabled you'll see logs such as:
573
+
574
+ ```
575
+ [NotificationSDK] Initializing SDK...
576
+ [NotificationSDK] Firebase initialized
577
+ [NotificationSDK] Token Generated
578
+ [NotificationSDK] Notification Received
579
+ ```
580
+
581
+ ---
582
+
583
+ # foreground
584
+
585
+ Automatically display notifications received while the application is open.
586
+
587
+ ```tsx
588
+ foreground: {
589
+ displayNotifications: true;
590
+ }
591
+ ```
592
+
593
+ Default
594
+
595
+ ```tsx
596
+ false;
597
+ ```
598
+
599
+ When disabled, you'll still receive the event:
600
+
601
+ ```tsx
602
+ Notifications.on("notificationReceived", ...)
603
+ ```
604
+
605
+ and can display your own UI.
606
+
607
+ ---
608
+
609
+ # background
610
+
611
+ Automatically display background **data** notifications.
612
+
613
+ ```tsx
614
+ background: {
615
+ displayNotifications: true;
616
+ }
617
+ ```
618
+
619
+ Default
620
+
621
+ ```tsx
622
+ true;
623
+ ```
624
+
625
+ If disabled, only your registered background handler will execute.
626
+
627
+ ---
628
+
629
+ # channels
630
+
631
+ Configure Android notification channels.
632
+
633
+ Example:
634
+
635
+ ```tsx
636
+ channels: [
637
+ {
638
+ id: "orders",
639
+ name: "Orders",
640
+ importance: "high",
641
+ },
642
+ ];
643
+ ```
644
+
645
+ If omitted, the SDK automatically creates:
646
+
647
+ | Property | Value |
648
+ | ---------- | ------- |
649
+ | ID | default |
650
+ | Name | Default |
651
+ | Importance | High |
652
+
653
+ ---
654
+
655
+ # iOS Configuration
656
+
657
+ Automatically request notification permission during initialization.
658
+
659
+ ```tsx
660
+ ios: {
661
+ requestPermissionOnLaunch: true;
662
+ }
663
+ ```
664
+
665
+ Default
666
+
667
+ ```tsx
668
+ false;
669
+ ```
670
+
671
+ ---
672
+
673
+ # Permission Management
674
+
675
+ Push notifications require user permission.
676
+
677
+ ---
678
+
679
+ ## Request Permission
680
+
681
+ ```tsx
682
+ const status = await Notifications.requestPermission();
683
+
684
+ console.log(status);
685
+ ```
686
+
687
+ Possible values:
688
+
689
+ | Status |
690
+ | ----------------- |
691
+ | granted |
692
+ | denied |
693
+ | blocked |
694
+ | provisional (iOS) |
695
+
696
+ ---
697
+
698
+ ## Check Current Permission
699
+
700
+ ```tsx
701
+ const status = await Notifications.getPermissionStatus();
702
+ ```
703
+
704
+ Useful for determining whether permission has already been granted.
705
+
706
+ ---
707
+
708
+ # Recommended Permission Flow
709
+
710
+ ```tsx
711
+ await Notifications.initialize({
712
+ debug: true,
713
+ });
714
+
715
+ const permission = await Notifications.requestPermission();
716
+
717
+ if (permission === "granted") {
718
+ const token = await Notifications.getToken();
719
+
720
+ console.log(token);
721
+ }
722
+ ```
723
+
724
+ ---
725
+
726
+ # FCM Token Management
727
+
728
+ The Firebase Cloud Messaging token uniquely identifies the device.
729
+
730
+ This token should usually be sent to your backend server.
731
+
732
+ ---
733
+
734
+ ## Get Device Token
735
+
736
+ ```tsx
737
+ const token = await Notifications.getToken();
738
+
739
+ console.log(token);
740
+ ```
741
+
742
+ Example:
743
+
744
+ ```
745
+ eVx9s8w.......
746
+ ```
747
+
748
+ ---
749
+
750
+ ## Delete Token
751
+
752
+ Deletes the current FCM token.
753
+
754
+ ```tsx
755
+ await Notifications.deleteToken();
756
+ ```
757
+
758
+ This is useful during logout.
759
+
760
+ ---
761
+
762
+ # Token Refresh
763
+
764
+ Firebase may rotate tokens.
765
+
766
+ Listen for updates.
767
+
768
+ ```tsx
769
+ Notifications.on("tokenRefresh", ({ token }) => {
770
+ console.log(token);
771
+ });
772
+ ```
773
+
774
+ Whenever Firebase issues a new token, update your backend.
775
+
776
+ ---
777
+
778
+ # SDK Lifecycle
779
+
780
+ ## Destroy SDK
781
+
782
+ Destroy all listeners.
783
+
784
+ ```tsx
785
+ Notifications.destroy();
786
+ ```
787
+
788
+ This removes:
789
+
790
+ - Firebase listeners
791
+ - Event listeners
792
+ - Internal SDK state
793
+
794
+ Normally this method is **not** required unless you're intentionally shutting down the SDK.
795
+
796
+ ---
797
+
798
+ # Common Initialization Example
799
+
800
+ ```tsx
801
+ import { useEffect } from "react";
802
+ import Notifications from "react-native-notification-sdk";
803
+
804
+ export default function App() {
805
+ useEffect(() => {
806
+ async function initialize() {
807
+ await Notifications.initialize({
808
+ debug: true,
809
+
810
+ foreground: {
811
+ displayNotifications: true,
812
+ },
813
+
814
+ background: {
815
+ displayNotifications: true,
816
+ },
817
+ });
818
+
819
+ const permission = await Notifications.requestPermission();
820
+
821
+ if (permission === "granted") {
822
+ const token = await Notifications.getToken();
823
+
824
+ console.log(token);
825
+ }
826
+ }
827
+
828
+ initialize();
829
+ }, []);
830
+
831
+ return null;
832
+ }
833
+ ```
834
+
835
+ ---
836
+
837
+ # Best Practices
838
+
839
+ ✅ Initialize the SDK once during application startup.
840
+
841
+ ✅ Request notification permission only when appropriate for your user experience.
842
+
843
+ ✅ Store the FCM token on your backend.
844
+
845
+ ✅ Update the stored token whenever the `tokenRefresh` event is emitted.
846
+
847
+ ✅ Keep `debug` disabled in production builds.
848
+
849
+ ---
850
+
851
+ # What's Next?
852
+
853
+ Now that the SDK is initialized, the next section covers:
854
+
855
+ - Local Notifications
856
+ - Scheduled Notifications
857
+ - Notification Channels
858
+ - Notification Actions
859
+ - Android & iOS Notification Options
860
+
861
+ ➡️ Continue to **Part 3 – Notifications**
862
+
863
+ # Notifications
864
+
865
+ The SDK supports:
866
+
867
+ - Local Notifications
868
+ - Scheduled Notifications
869
+ - Notification Actions
870
+ - Android Notification Channels
871
+ - Android & iOS specific notification options
872
+
873
+ ---
874
+
875
+ # Display a Local Notification
876
+
877
+ Display a notification immediately.
878
+
879
+ ```tsx
880
+ import Notifications from "react-native-notification-sdk";
881
+
882
+ await Notifications.displayNotification({
883
+ title: "Welcome 👋",
884
+ body: "Thanks for installing the Notification SDK.",
885
+ });
886
+ ```
887
+
888
+ ---
889
+
890
+ # Complete Notification Example
891
+
892
+ ```tsx
893
+ await Notifications.displayNotification({
894
+ title: "Order Received",
895
+ body: "Your order has been placed successfully.",
896
+
897
+ subtitle: "Order #1024",
898
+
899
+ data: {
900
+ orderId: "1024",
901
+ screen: "orders",
902
+ },
903
+
904
+ android: {
905
+ channelId: "orders",
906
+ color: "#1976D2",
907
+ autoCancel: true,
908
+ pressActionId: "default",
909
+ },
910
+
911
+ ios: {
912
+ badge: 1,
913
+ sound: "default",
914
+ },
915
+ });
916
+ ```
917
+
918
+ ---
919
+
920
+ # DisplayNotification Interface
921
+
922
+ ## id
923
+
924
+ Optional notification identifier.
925
+
926
+ ```tsx
927
+ id: "notification_1";
928
+ ```
929
+
930
+ If omitted, Notifee automatically generates one.
931
+
932
+ ---
933
+
934
+ ## title
935
+
936
+ Notification title.
937
+
938
+ ```tsx
939
+ title: "Hello";
940
+ ```
941
+
942
+ Required.
943
+
944
+ ---
945
+
946
+ ## body
947
+
948
+ Notification body.
949
+
950
+ ```tsx
951
+ body: "Welcome to Notification SDK";
952
+ ```
953
+
954
+ Required.
955
+
956
+ ---
957
+
958
+ ## subtitle
959
+
960
+ Optional subtitle.
961
+
962
+ ```tsx
963
+ subtitle: "Today's Updates";
964
+ ```
965
+
966
+ ---
967
+
968
+ ## data
969
+
970
+ Attach custom key/value data.
971
+
972
+ ```tsx
973
+ data: {
974
+ screen: "orders",
975
+ orderId: "1001"
976
+ }
977
+ ```
978
+
979
+ Retrieve this data when the notification is opened.
980
+
981
+ ---
982
+
983
+ # Android Options
984
+
985
+ ```tsx
986
+ android: {
987
+ channelId: "orders",
988
+ pressActionId: "default",
989
+ smallIcon: "ic_notification",
990
+ largeIcon: "https://example.com/logo.png",
991
+ color: "#2196F3",
992
+ autoCancel: true
993
+ }
994
+ ```
995
+
996
+ ---
997
+
998
+ ## channelId
999
+
1000
+ Notification channel.
1001
+
1002
+ ```tsx
1003
+ channelId: "orders";
1004
+ ```
1005
+
1006
+ If omitted, the SDK uses the default channel.
1007
+
1008
+ ---
1009
+
1010
+ ## pressActionId
1011
+
1012
+ Press action identifier.
1013
+
1014
+ ```tsx
1015
+ pressActionId: "default";
1016
+ ```
1017
+
1018
+ ---
1019
+
1020
+ ## smallIcon
1021
+
1022
+ Android notification icon.
1023
+
1024
+ ```tsx
1025
+ smallIcon: "ic_notification";
1026
+ ```
1027
+
1028
+ This icon must exist inside:
1029
+
1030
+ ```
1031
+ android/app/src/main/res/drawable
1032
+ ```
1033
+
1034
+ ---
1035
+
1036
+ ## largeIcon
1037
+
1038
+ Large notification icon.
1039
+
1040
+ Supports:
1041
+
1042
+ - Remote URL
1043
+ - Local resource
1044
+
1045
+ Example:
1046
+
1047
+ ```tsx
1048
+ largeIcon: "https://example.com/logo.png";
1049
+ ```
1050
+
1051
+ ---
1052
+
1053
+ ## color
1054
+
1055
+ Notification accent color.
1056
+
1057
+ ```tsx
1058
+ color: "#FF5722";
1059
+ ```
1060
+
1061
+ ---
1062
+
1063
+ ## autoCancel
1064
+
1065
+ Automatically remove the notification when tapped.
1066
+
1067
+ ```tsx
1068
+ autoCancel: true;
1069
+ ```
1070
+
1071
+ Default
1072
+
1073
+ ```tsx
1074
+ true;
1075
+ ```
1076
+
1077
+ ---
1078
+
1079
+ # iOS Options
1080
+
1081
+ ```tsx
1082
+ ios: {
1083
+ badge: 5,
1084
+ sound: "default",
1085
+ categoryId: "ORDER_ACTIONS"
1086
+ }
1087
+ ```
1088
+
1089
+ ---
1090
+
1091
+ ## badge
1092
+
1093
+ Application badge count.
1094
+
1095
+ ```tsx
1096
+ badge: 10;
1097
+ ```
1098
+
1099
+ ---
1100
+
1101
+ ## sound
1102
+
1103
+ Notification sound.
1104
+
1105
+ ```tsx
1106
+ sound: "default";
1107
+ ```
1108
+
1109
+ or
1110
+
1111
+ ```tsx
1112
+ sound: "notification.wav";
1113
+ ```
1114
+
1115
+ ---
1116
+
1117
+ ## categoryId
1118
+
1119
+ Notification category identifier.
1120
+
1121
+ Useful for notification actions on iOS.
1122
+
1123
+ ---
1124
+
1125
+ # Notification Actions
1126
+
1127
+ Interactive notification buttons.
1128
+
1129
+ Example:
1130
+
1131
+ ```tsx
1132
+ await Notifications.displayNotification({
1133
+ title: "Incoming Order",
1134
+ body: "Accept this order?",
1135
+
1136
+ actions: [
1137
+ {
1138
+ id: "accept",
1139
+ title: "Accept",
1140
+ },
1141
+
1142
+ {
1143
+ id: "reject",
1144
+ title: "Reject",
1145
+ destructive: true,
1146
+ },
1147
+ ],
1148
+ });
1149
+ ```
1150
+
1151
+ ---
1152
+
1153
+ # NotificationAction Interface
1154
+
1155
+ ```tsx
1156
+ {
1157
+ id: string
1158
+ title: string
1159
+ launchActivity?: "default"
1160
+ destructive?: boolean
1161
+ input?: boolean
1162
+ }
1163
+ ```
1164
+
1165
+ ---
1166
+
1167
+ ## id
1168
+
1169
+ Unique action identifier.
1170
+
1171
+ ```tsx
1172
+ id: "accept";
1173
+ ```
1174
+
1175
+ ---
1176
+
1177
+ ## title
1178
+
1179
+ Button text.
1180
+
1181
+ ```tsx
1182
+ title: "Accept";
1183
+ ```
1184
+
1185
+ ---
1186
+
1187
+ ## destructive
1188
+
1189
+ Android only.
1190
+
1191
+ Displays the action as destructive.
1192
+
1193
+ ```tsx
1194
+ destructive: true;
1195
+ ```
1196
+
1197
+ ---
1198
+
1199
+ ## launchActivity
1200
+
1201
+ Launches the application.
1202
+
1203
+ ```tsx
1204
+ launchActivity: "default";
1205
+ ```
1206
+
1207
+ ---
1208
+
1209
+ ## input
1210
+
1211
+ Allows inline reply.
1212
+
1213
+ ```tsx
1214
+ input: true;
1215
+ ```
1216
+
1217
+ ---
1218
+
1219
+ # Listen for Notification Actions
1220
+
1221
+ ```tsx
1222
+ Notifications.on(
1223
+ "notificationActionPressed",
1224
+
1225
+ ({ notification, actionId, input }) => {
1226
+ console.log(actionId);
1227
+
1228
+ console.log(input);
1229
+ },
1230
+ );
1231
+ ```
1232
+
1233
+ ---
1234
+
1235
+ # Scheduled Notifications
1236
+
1237
+ Schedule notifications to appear later.
1238
+
1239
+ ---
1240
+
1241
+ ## Timestamp Trigger
1242
+
1243
+ ```tsx
1244
+ const id = await Notifications.scheduleNotification({
1245
+ title: "Meeting",
1246
+
1247
+ body: "Standup starts in 10 minutes",
1248
+
1249
+ trigger: {
1250
+ type: "timestamp",
1251
+ timestamp: Date.now() + 600000,
1252
+ },
1253
+ });
1254
+ ```
1255
+
1256
+ Returns:
1257
+
1258
+ ```tsx
1259
+ notification - id;
1260
+ ```
1261
+
1262
+ ---
1263
+
1264
+ # ScheduledNotification Interface
1265
+
1266
+ ```tsx
1267
+ {
1268
+ ...DisplayNotification
1269
+
1270
+ trigger: NotificationTrigger
1271
+ }
1272
+ ```
1273
+
1274
+ ---
1275
+
1276
+ # NotificationTrigger
1277
+
1278
+ ```tsx
1279
+ {
1280
+ type: "timestamp";
1281
+ timestamp: number;
1282
+ }
1283
+ ```
1284
+
1285
+ ---
1286
+
1287
+ # Cancel Scheduled Notification
1288
+
1289
+ ```tsx
1290
+ await Notifications.cancelScheduledNotification(id);
1291
+ ```
1292
+
1293
+ ---
1294
+
1295
+ # Cancel All Scheduled Notifications
1296
+
1297
+ ```tsx
1298
+ await Notifications.cancelAllScheduledNotifications();
1299
+ ```
1300
+
1301
+ ---
1302
+
1303
+ # Get Scheduled Notifications
1304
+
1305
+ ```tsx
1306
+ const notifications = await Notifications.getScheduledNotifications();
1307
+
1308
+ console.log(notifications);
1309
+ ```
1310
+
1311
+ ---
1312
+
1313
+ # Cancel a Displayed Notification
1314
+
1315
+ ```tsx
1316
+ await Notifications.cancelNotification(notificationId);
1317
+ ```
1318
+
1319
+ ---
1320
+
1321
+ # Cancel All Notifications
1322
+
1323
+ ```tsx
1324
+ await Notifications.cancelAllNotifications();
1325
+ ```
1326
+
1327
+ ---
1328
+
1329
+ # Android Notification Channels
1330
+
1331
+ Channels allow Android users to manage notification behavior.
1332
+
1333
+ Example:
1334
+
1335
+ ```tsx
1336
+ await Notifications.initialize({
1337
+ channels: [
1338
+ {
1339
+ id: "orders",
1340
+ name: "Orders",
1341
+ importance: "high",
1342
+ },
1343
+
1344
+ {
1345
+ id: "marketing",
1346
+ name: "Marketing",
1347
+ importance: "default",
1348
+ },
1349
+ ],
1350
+ });
1351
+ ```
1352
+
1353
+ ---
1354
+
1355
+ # NotificationChannel Interface
1356
+
1357
+ ```tsx
1358
+ {
1359
+ id: string
1360
+
1361
+ name: string
1362
+
1363
+ description?: string
1364
+
1365
+ importance?:
1366
+ | "none"
1367
+ | "min"
1368
+ | "low"
1369
+ | "default"
1370
+ | "high"
1371
+ | "max"
1372
+ }
1373
+ ```
1374
+
1375
+ ---
1376
+
1377
+ # Importance Levels
1378
+
1379
+ | Value | Description |
1380
+ | ------- | ---------------- |
1381
+ | none | Disabled |
1382
+ | min | Silent |
1383
+ | low | Low Priority |
1384
+ | default | Standard |
1385
+ | high | High Priority |
1386
+ | max | Maximum Priority |
1387
+
1388
+ ---
1389
+
1390
+ # Best Practices
1391
+
1392
+ ✅ Use notification channels to categorize notifications.
1393
+
1394
+ ✅ Use custom `data` instead of parsing notification text.
1395
+
1396
+ ✅ Keep notification titles concise.
1397
+
1398
+ ✅ Provide meaningful action buttons.
1399
+
1400
+ ✅ Use scheduled notifications for reminders instead of background timers.
1401
+
1402
+ ✅ Use separate channels for marketing and transactional notifications.
1403
+
1404
+ ---
1405
+
1406
+ # What's Next?
1407
+
1408
+ The next section covers:
1409
+
1410
+ - Notification Events
1411
+ - Foreground Notifications
1412
+ - Background Notifications
1413
+ - Deep Linking
1414
+ - Notification Lifecycle
1415
+ - Event System
1416
+
1417
+ ➡️ Continue to **Part 4 – Events & Background Handling**
1418
+
1419
+ # Events & Background Handling
1420
+
1421
+ The SDK exposes a strongly typed event system for listening to notification lifecycle events.
1422
+
1423
+ Events can be subscribed to using:
1424
+
1425
+ ```tsx
1426
+ Notifications.on(eventName, listener);
1427
+ ```
1428
+
1429
+ and removed using:
1430
+
1431
+ ```tsx
1432
+ Notifications.off(eventName, listener);
1433
+ ```
1434
+
1435
+ The `on()` method also returns an unsubscribe function.
1436
+
1437
+ ```tsx
1438
+ const unsubscribe = Notifications.on(
1439
+ "notificationReceived",
1440
+ ({ notification }) => {
1441
+ console.log(notification);
1442
+ },
1443
+ );
1444
+
1445
+ unsubscribe();
1446
+ ```
1447
+
1448
+ ---
1449
+
1450
+ # Event Lifecycle
1451
+
1452
+ ```
1453
+ FCM Notification
1454
+
1455
+
1456
+ Firebase Messaging
1457
+
1458
+
1459
+ Notification SDK
1460
+
1461
+ ├──────── notificationReceived
1462
+
1463
+ ├──────── notificationOpened
1464
+
1465
+ ├──────── notificationDismissed
1466
+
1467
+ ├──────── notificationActionPressed
1468
+
1469
+ ├──────── tokenRefresh
1470
+
1471
+ └──────── permissionChanged
1472
+ ```
1473
+
1474
+ ---
1475
+
1476
+ # Available Events
1477
+
1478
+ | Event | Description |
1479
+ | ------------------------- | ------------------------------------------ |
1480
+ | initialized | SDK initialization completed |
1481
+ | tokenGenerated | Initial FCM token generated |
1482
+ | tokenRefresh | Firebase refreshed the FCM token |
1483
+ | notificationReceived | Notification received while app is running |
1484
+ | notificationOpened | User tapped a notification |
1485
+ | notificationDismissed | User dismissed a notification |
1486
+ | notificationActionPressed | User pressed a notification action button |
1487
+ | permissionChanged | Notification permission changed |
1488
+
1489
+ ---
1490
+
1491
+ # initialized
1492
+
1493
+ Triggered once the SDK has finished initialization.
1494
+
1495
+ ```tsx
1496
+ Notifications.on("initialized", () => {
1497
+ console.log("SDK Ready");
1498
+ });
1499
+ ```
1500
+
1501
+ ---
1502
+
1503
+ # tokenGenerated
1504
+
1505
+ Called after requesting the initial FCM token.
1506
+
1507
+ ```tsx
1508
+ Notifications.on("tokenGenerated", ({ token }) => {
1509
+ console.log(token);
1510
+ });
1511
+ ```
1512
+
1513
+ Payload
1514
+
1515
+ ```ts
1516
+ {
1517
+ token: string;
1518
+ }
1519
+ ```
1520
+
1521
+ ---
1522
+
1523
+ # tokenRefresh
1524
+
1525
+ Firebase may periodically rotate device tokens.
1526
+
1527
+ Always update your backend.
1528
+
1529
+ ```tsx
1530
+ Notifications.on("tokenRefresh", ({ token }) => {
1531
+ await api.updateToken(token);
1532
+ });
1533
+ ```
1534
+
1535
+ Payload
1536
+
1537
+ ```ts
1538
+ {
1539
+ token: string;
1540
+ }
1541
+ ```
1542
+
1543
+ ---
1544
+
1545
+ # notificationReceived
1546
+
1547
+ Triggered whenever a notification is received while the application is in the foreground.
1548
+
1549
+ ```tsx
1550
+ Notifications.on(
1551
+ "notificationReceived",
1552
+
1553
+ ({ notification }) => {
1554
+ console.log(notification);
1555
+ },
1556
+ );
1557
+ ```
1558
+
1559
+ Payload
1560
+
1561
+ ```ts
1562
+ {
1563
+ notification: NotificationPayload;
1564
+ }
1565
+ ```
1566
+
1567
+ ---
1568
+
1569
+ # notificationOpened
1570
+
1571
+ Triggered when the user taps a notification.
1572
+
1573
+ ```tsx
1574
+ Notifications.on(
1575
+ "notificationOpened",
1576
+
1577
+ ({ notification }) => {
1578
+ console.log(notification.data);
1579
+ },
1580
+ );
1581
+ ```
1582
+
1583
+ Typical usage
1584
+
1585
+ ```tsx
1586
+ Notifications.on(
1587
+ "notificationOpened",
1588
+
1589
+ ({ notification }) => {
1590
+ if (notification.data?.screen === "orders") {
1591
+ navigation.navigate("Orders");
1592
+ }
1593
+ },
1594
+ );
1595
+ ```
1596
+
1597
+ ---
1598
+
1599
+ # notificationDismissed
1600
+
1601
+ Triggered when a notification is dismissed by the user.
1602
+
1603
+ ```tsx
1604
+ Notifications.on(
1605
+ "notificationDismissed",
1606
+
1607
+ ({ notification }) => {
1608
+ console.log(notification);
1609
+ },
1610
+ );
1611
+ ```
1612
+
1613
+ Useful for analytics.
1614
+
1615
+ ---
1616
+
1617
+ # notificationActionPressed
1618
+
1619
+ Triggered when an action button is pressed.
1620
+
1621
+ ```tsx
1622
+ Notifications.on(
1623
+ "notificationActionPressed",
1624
+
1625
+ ({ notification, actionId, input }) => {
1626
+ switch (actionId) {
1627
+ case "accept":
1628
+ console.log("Accepted");
1629
+
1630
+ break;
1631
+
1632
+ case "reject":
1633
+ console.log("Rejected");
1634
+
1635
+ break;
1636
+ }
1637
+ },
1638
+ );
1639
+ ```
1640
+
1641
+ Payload
1642
+
1643
+ ```ts
1644
+ {
1645
+ notification: NotificationPayload
1646
+ actionId: string
1647
+ input?: string
1648
+ }
1649
+ ```
1650
+
1651
+ ---
1652
+
1653
+ # permissionChanged
1654
+
1655
+ Triggered whenever notification permission changes.
1656
+
1657
+ ```tsx
1658
+ Notifications.on(
1659
+ "permissionChanged",
1660
+
1661
+ ({ status }) => {
1662
+ console.log(status);
1663
+ },
1664
+ );
1665
+ ```
1666
+
1667
+ Payload
1668
+
1669
+ ```ts
1670
+ {
1671
+ status: PermissionStatus;
1672
+ }
1673
+ ```
1674
+
1675
+ Possible values
1676
+
1677
+ - granted
1678
+ - denied
1679
+ - blocked
1680
+ - provisional (iOS)
1681
+
1682
+ ---
1683
+
1684
+ # Background Notifications
1685
+
1686
+ Background messages are delivered when the application is:
1687
+
1688
+ - Backgrounded
1689
+ - Swiped away (Android)
1690
+ - Terminated (Android data messages)
1691
+ - Inactive
1692
+
1693
+ Register a background handler **before your application starts**.
1694
+
1695
+ Example (`index.js`)
1696
+
1697
+ ```tsx
1698
+ import Notifications from "react-native-notification-sdk";
1699
+
1700
+ Notifications.registerBackgroundHandler(async (notification) => {
1701
+ console.log("Background Notification");
1702
+
1703
+ console.log(notification);
1704
+ });
1705
+ ```
1706
+
1707
+ Only one background handler should be registered.
1708
+
1709
+ ---
1710
+
1711
+ # Automatic Background Display
1712
+
1713
+ By default
1714
+
1715
+ ```tsx
1716
+ background: {
1717
+ displayNotifications: true;
1718
+ }
1719
+ ```
1720
+
1721
+ The SDK automatically converts Firebase data messages into local notifications using Notifee.
1722
+
1723
+ Disable automatic display
1724
+
1725
+ ```tsx
1726
+ await Notifications.initialize({
1727
+ background: {
1728
+ displayNotifications: false,
1729
+ },
1730
+ });
1731
+ ```
1732
+
1733
+ Now only your background handler will execute.
1734
+
1735
+ ---
1736
+
1737
+ # Foreground Notifications
1738
+
1739
+ Normally Android and iOS do **not** display FCM notifications while the application is open.
1740
+
1741
+ Enable automatic display
1742
+
1743
+ ```tsx
1744
+ await Notifications.initialize({
1745
+ foreground: {
1746
+ displayNotifications: true,
1747
+ },
1748
+ });
1749
+ ```
1750
+
1751
+ Now incoming foreground messages are automatically displayed using Notifee.
1752
+
1753
+ Disable automatic display
1754
+
1755
+ ```tsx
1756
+ foreground: {
1757
+ displayNotifications: false;
1758
+ }
1759
+ ```
1760
+
1761
+ Then manually display notifications.
1762
+
1763
+ ```tsx
1764
+ Notifications.on(
1765
+ "notificationReceived",
1766
+
1767
+ async ({ notification }) => {
1768
+ await Notifications.displayNotification({
1769
+ title: notification.title,
1770
+
1771
+ body: notification.body,
1772
+
1773
+ data: notification.data,
1774
+ });
1775
+ },
1776
+ );
1777
+ ```
1778
+
1779
+ ---
1780
+
1781
+ # Notification Payload
1782
+
1783
+ Every notification received by the SDK is mapped into a common structure.
1784
+
1785
+ ```ts
1786
+ interface NotificationPayload {
1787
+ id?: string;
1788
+
1789
+ title?: string;
1790
+
1791
+ body?: string;
1792
+
1793
+ subtitle?: string;
1794
+
1795
+ data?: Record<string, string>;
1796
+
1797
+ imageUrl?: string;
1798
+
1799
+ sentTime?: number;
1800
+
1801
+ from?: string;
1802
+ }
1803
+ ```
1804
+
1805
+ This provides a consistent payload across Android and iOS.
1806
+
1807
+ ---
1808
+
1809
+ # Deep Linking
1810
+
1811
+ Use notification data to navigate users to a specific screen.
1812
+
1813
+ Example payload
1814
+
1815
+ ```json
1816
+ {
1817
+ "screen": "orders",
1818
+ "orderId": "1001"
1819
+ }
1820
+ ```
1821
+
1822
+ Handle navigation
1823
+
1824
+ ```tsx
1825
+ Notifications.on(
1826
+ "notificationOpened",
1827
+
1828
+ ({ notification }) => {
1829
+ const screen = notification.data?.screen;
1830
+
1831
+ if (screen === "orders") {
1832
+ navigation.navigate("Orders", {
1833
+ id: notification.data?.orderId,
1834
+ });
1835
+ }
1836
+ },
1837
+ );
1838
+ ```
1839
+
1840
+ ---
1841
+
1842
+ # Complete Event Registration Example
1843
+
1844
+ ```tsx
1845
+ useEffect(() => {
1846
+ const subscriptions = [
1847
+ Notifications.on("initialized", () => {
1848
+ console.log("SDK Ready");
1849
+ }),
1850
+
1851
+ Notifications.on("tokenGenerated", ({ token }) => {
1852
+ console.log(token);
1853
+ }),
1854
+
1855
+ Notifications.on("tokenRefresh", ({ token }) => {
1856
+ console.log(token);
1857
+ }),
1858
+
1859
+ Notifications.on("notificationReceived", ({ notification }) => {
1860
+ console.log(notification);
1861
+ }),
1862
+
1863
+ Notifications.on("notificationOpened", ({ notification }) => {
1864
+ console.log(notification);
1865
+ }),
1866
+
1867
+ Notifications.on("notificationDismissed", ({ notification }) => {
1868
+ console.log(notification);
1869
+ }),
1870
+
1871
+ Notifications.on("notificationActionPressed", ({ actionId }) => {
1872
+ console.log(actionId);
1873
+ }),
1874
+
1875
+ Notifications.on("permissionChanged", ({ status }) => {
1876
+ console.log(status);
1877
+ }),
1878
+ ];
1879
+
1880
+ return () => {
1881
+ subscriptions.forEach((unsubscribe) => unsubscribe());
1882
+ };
1883
+ }, []);
1884
+ ```
1885
+
1886
+ ---
1887
+
1888
+ # Best Practices
1889
+
1890
+ ✅ Register listeners once during application startup.
1891
+
1892
+ ✅ Always unsubscribe listeners when appropriate.
1893
+
1894
+ ✅ Update your backend whenever the FCM token changes.
1895
+
1896
+ ✅ Use notification `data` for navigation instead of parsing titles or bodies.
1897
+
1898
+ ✅ Register the background handler before rendering your application.
1899
+
1900
+ ✅ Keep background handlers lightweight—perform only essential work.
1901
+
1902
+ ---
1903
+
1904
+ # Common Notification Flows
1905
+
1906
+ ### Foreground
1907
+
1908
+ ```
1909
+ Server
1910
+
1911
+
1912
+ Firebase
1913
+
1914
+
1915
+ notificationReceived
1916
+
1917
+
1918
+ Display Notification (optional)
1919
+ ```
1920
+
1921
+ ### Background
1922
+
1923
+ ```
1924
+ Server
1925
+
1926
+
1927
+ Firebase
1928
+
1929
+
1930
+ Background Handler
1931
+
1932
+
1933
+ Display Notification (automatic or manual)
1934
+ ```
1935
+
1936
+ ### User Interaction
1937
+
1938
+ ```
1939
+ Notification
1940
+
1941
+
1942
+ User taps notification
1943
+
1944
+
1945
+ notificationOpened
1946
+
1947
+
1948
+ Navigate to screen
1949
+ ```
1950
+
1951
+ ---
1952
+
1953
+ # What's Next?
1954
+
1955
+ The next section contains the **complete API Reference**, including:
1956
+
1957
+ - Every public method
1958
+ - Every interface
1959
+ - Every type
1960
+ - Error classes
1961
+ - Validators
1962
+ - Complete code examples
1963
+
1964
+ ➡️ Continue to **Part 5 – API Reference**
1965
+
1966
+ # API Reference
1967
+
1968
+ This section documents every public method exposed by the SDK.
1969
+
1970
+ Import the SDK:
1971
+
1972
+ ```tsx
1973
+ import Notifications from "react-native-notification-sdk";
1974
+ ```
1975
+
1976
+ ---
1977
+
1978
+ # initialize()
1979
+
1980
+ Initializes the Notification SDK.
1981
+
1982
+ Must be called before using any other SDK method.
1983
+
1984
+ ## Signature
1985
+
1986
+ ```ts
1987
+ initialize(config: NotificationConfig): Promise<void>
1988
+ ```
1989
+
1990
+ ## Example
1991
+
1992
+ ```tsx
1993
+ await Notifications.initialize({
1994
+ debug: true,
1995
+
1996
+ foreground: {
1997
+ displayNotifications: true,
1998
+ },
1999
+
2000
+ background: {
2001
+ displayNotifications: true,
2002
+ },
2003
+ });
2004
+ ```
2005
+
2006
+ ## Parameters
2007
+
2008
+ | Property | Type | Required | Description |
2009
+ | -------- | ------------------ | -------- | ----------------- |
2010
+ | config | NotificationConfig | ✅ | SDK configuration |
2011
+
2012
+ ---
2013
+
2014
+ # requestPermission()
2015
+
2016
+ Requests notification permission.
2017
+
2018
+ ## Signature
2019
+
2020
+ ```ts
2021
+ requestPermission(): Promise<PermissionStatus>
2022
+ ```
2023
+
2024
+ ## Example
2025
+
2026
+ ```tsx
2027
+ const status = await Notifications.requestPermission();
2028
+ ```
2029
+
2030
+ Returns
2031
+
2032
+ ```ts
2033
+ PermissionStatus;
2034
+ ```
2035
+
2036
+ Possible values
2037
+
2038
+ - granted
2039
+ - denied
2040
+ - blocked
2041
+ - provisional (iOS)
2042
+
2043
+ ---
2044
+
2045
+ # getPermissionStatus()
2046
+
2047
+ Returns the current notification permission.
2048
+
2049
+ ## Signature
2050
+
2051
+ ```ts
2052
+ getPermissionStatus(): Promise<PermissionStatus>
2053
+ ```
2054
+
2055
+ Example
2056
+
2057
+ ```tsx
2058
+ const permission = await Notifications.getPermissionStatus();
2059
+ ```
2060
+
2061
+ ---
2062
+
2063
+ # getToken()
2064
+
2065
+ Returns the Firebase Cloud Messaging token.
2066
+
2067
+ ## Signature
2068
+
2069
+ ```ts
2070
+ getToken(): Promise<string>
2071
+ ```
2072
+
2073
+ Example
2074
+
2075
+ ```tsx
2076
+ const token = await Notifications.getToken();
2077
+ ```
2078
+
2079
+ ---
2080
+
2081
+ # deleteToken()
2082
+
2083
+ Deletes the FCM token.
2084
+
2085
+ Useful when logging out.
2086
+
2087
+ ## Signature
2088
+
2089
+ ```ts
2090
+ deleteToken(): Promise<void>
2091
+ ```
2092
+
2093
+ Example
2094
+
2095
+ ```tsx
2096
+ await Notifications.deleteToken();
2097
+ ```
2098
+
2099
+ ---
2100
+
2101
+ # displayNotification()
2102
+
2103
+ Displays a local notification.
2104
+
2105
+ ## Signature
2106
+
2107
+ ```ts
2108
+ displayNotification(
2109
+ notification: DisplayNotification
2110
+ ): Promise<void>
2111
+ ```
2112
+
2113
+ Example
2114
+
2115
+ ```tsx
2116
+ await Notifications.displayNotification({
2117
+ title: "Hello",
2118
+
2119
+ body: "Notification SDK",
2120
+ });
2121
+ ```
2122
+
2123
+ ---
2124
+
2125
+ # scheduleNotification()
2126
+
2127
+ Schedules a local notification.
2128
+
2129
+ ## Signature
2130
+
2131
+ ```ts
2132
+ scheduleNotification(
2133
+ notification: ScheduledNotification
2134
+ ): Promise<string>
2135
+ ```
2136
+
2137
+ Returns
2138
+
2139
+ Notification ID
2140
+
2141
+ Example
2142
+
2143
+ ```tsx
2144
+ const id = await Notifications.scheduleNotification({
2145
+ title: "Meeting",
2146
+
2147
+ body: "Standup",
2148
+
2149
+ trigger: {
2150
+ type: "timestamp",
2151
+
2152
+ timestamp: Date.now() + 60000,
2153
+ },
2154
+ });
2155
+ ```
2156
+
2157
+ ---
2158
+
2159
+ # cancelNotification()
2160
+
2161
+ Cancels a displayed notification.
2162
+
2163
+ ## Signature
2164
+
2165
+ ```ts
2166
+ cancelNotification(
2167
+ id: string
2168
+ ): Promise<void>
2169
+ ```
2170
+
2171
+ ---
2172
+
2173
+ # cancelAllNotifications()
2174
+
2175
+ Removes all displayed notifications.
2176
+
2177
+ ## Signature
2178
+
2179
+ ```ts
2180
+ cancelAllNotifications(): Promise<void>
2181
+ ```
2182
+
2183
+ ---
2184
+
2185
+ # cancelScheduledNotification()
2186
+
2187
+ Cancels a scheduled notification.
2188
+
2189
+ ## Signature
2190
+
2191
+ ```ts
2192
+ cancelScheduledNotification(
2193
+ id: string
2194
+ ): Promise<void>
2195
+ ```
2196
+
2197
+ ---
2198
+
2199
+ # cancelAllScheduledNotifications()
2200
+
2201
+ Cancels every scheduled notification.
2202
+
2203
+ ## Signature
2204
+
2205
+ ```ts
2206
+ cancelAllScheduledNotifications(): Promise<void>
2207
+ ```
2208
+
2209
+ ---
2210
+
2211
+ # getScheduledNotifications()
2212
+
2213
+ Returns all scheduled notifications.
2214
+
2215
+ ## Signature
2216
+
2217
+ ```ts
2218
+ getScheduledNotifications(): Promise<ScheduledNotification[]>
2219
+ ```
2220
+
2221
+ Example
2222
+
2223
+ ```tsx
2224
+ const notifications = await Notifications.getScheduledNotifications();
2225
+ ```
2226
+
2227
+ ---
2228
+
2229
+ # registerBackgroundHandler()
2230
+
2231
+ Registers the Firebase background handler.
2232
+
2233
+ Only one handler should be registered.
2234
+
2235
+ Register before rendering the application.
2236
+
2237
+ ## Signature
2238
+
2239
+ ```ts
2240
+ registerBackgroundHandler(
2241
+ handler:
2242
+ (
2243
+ notification: NotificationPayload
2244
+ ) => Promise<void>
2245
+ ): void
2246
+ ```
2247
+
2248
+ Example
2249
+
2250
+ ```tsx
2251
+ Notifications.registerBackgroundHandler(async (notification) => {
2252
+ console.log(notification);
2253
+ });
2254
+ ```
2255
+
2256
+ ---
2257
+
2258
+ # destroy()
2259
+
2260
+ Destroys the SDK.
2261
+
2262
+ Removes listeners and internal state.
2263
+
2264
+ Normally this is not required.
2265
+
2266
+ ## Signature
2267
+
2268
+ ```ts
2269
+ destroy(): void
2270
+ ```
2271
+
2272
+ ---
2273
+
2274
+ # on()
2275
+
2276
+ Registers an event listener.
2277
+
2278
+ Returns an unsubscribe function.
2279
+
2280
+ ## Signature
2281
+
2282
+ ```ts
2283
+ on<K extends keyof NotificationEvents>(
2284
+ event: K,
2285
+ listener:
2286
+ (
2287
+ payload:
2288
+ NotificationEvents[K]
2289
+ ) => void
2290
+ ): () => void
2291
+ ```
2292
+
2293
+ Example
2294
+
2295
+ ```tsx
2296
+ const unsubscribe = Notifications.on(
2297
+ "notificationReceived",
2298
+
2299
+ ({ notification }) => {
2300
+ console.log(notification);
2301
+ },
2302
+ );
2303
+ ```
2304
+
2305
+ ---
2306
+
2307
+ # off()
2308
+
2309
+ Removes an event listener.
2310
+
2311
+ ## Signature
2312
+
2313
+ ```ts
2314
+ off<K extends keyof NotificationEvents>(
2315
+ event: K,
2316
+ listener:
2317
+ (
2318
+ payload:
2319
+ NotificationEvents[K]
2320
+ ) => void
2321
+ ): void
2322
+ ```
2323
+
2324
+ ---
2325
+
2326
+ # NotificationConfig
2327
+
2328
+ ```ts
2329
+ interface NotificationConfig {
2330
+ debug?: boolean;
2331
+
2332
+ foreground?: {
2333
+ displayNotifications?: boolean;
2334
+ };
2335
+
2336
+ background?: {
2337
+ displayNotifications?: boolean;
2338
+ };
2339
+
2340
+ ios?: {
2341
+ requestPermissionOnLaunch?: boolean;
2342
+ };
2343
+
2344
+ channels?: NotificationChannel[];
2345
+ }
2346
+ ```
2347
+
2348
+ ---
2349
+
2350
+ # DisplayNotification
2351
+
2352
+ ```ts
2353
+ interface DisplayNotification {
2354
+ id?: string;
2355
+
2356
+ title: string;
2357
+
2358
+ body: string;
2359
+
2360
+ subtitle?: string;
2361
+
2362
+ data?: Record<string, string>;
2363
+
2364
+ actions?: NotificationAction[];
2365
+
2366
+ android?: AndroidNotificationOptions;
2367
+
2368
+ ios?: IOSNotificationOptions;
2369
+ }
2370
+ ```
2371
+
2372
+ ---
2373
+
2374
+ # ScheduledNotification
2375
+
2376
+ ```ts
2377
+ interface ScheduledNotification extends DisplayNotification {
2378
+ trigger: NotificationTrigger;
2379
+ }
2380
+ ```
2381
+
2382
+ ---
2383
+
2384
+ # NotificationTrigger
2385
+
2386
+ ```ts
2387
+ interface NotificationTrigger {
2388
+ type: "timestamp";
2389
+
2390
+ timestamp: number;
2391
+ }
2392
+ ```
2393
+
2394
+ ---
2395
+
2396
+ # NotificationAction
2397
+
2398
+ ```ts
2399
+ interface NotificationAction {
2400
+ id: string;
2401
+
2402
+ title: string;
2403
+
2404
+ launchActivity?: "default";
2405
+
2406
+ destructive?: boolean;
2407
+
2408
+ input?: boolean;
2409
+ }
2410
+ ```
2411
+
2412
+ ---
2413
+
2414
+ # NotificationChannel
2415
+
2416
+ ```ts
2417
+ interface NotificationChannel {
2418
+ id: string;
2419
+
2420
+ name: string;
2421
+
2422
+ description?: string;
2423
+
2424
+ importance?: "none" | "min" | "low" | "default" | "high" | "max";
2425
+ }
2426
+ ```
2427
+
2428
+ ---
2429
+
2430
+ # AndroidNotificationOptions
2431
+
2432
+ ```ts
2433
+ interface AndroidNotificationOptions {
2434
+ channelId?: string;
2435
+
2436
+ pressActionId?: string;
2437
+
2438
+ smallIcon?: string;
2439
+
2440
+ largeIcon?: string;
2441
+
2442
+ color?: string;
2443
+
2444
+ autoCancel?: boolean;
2445
+ }
2446
+ ```
2447
+
2448
+ ---
2449
+
2450
+ # IOSNotificationOptions
2451
+
2452
+ ```ts
2453
+ interface IOSNotificationOptions {
2454
+ badge?: number;
2455
+
2456
+ sound?: string;
2457
+
2458
+ categoryId?: string;
2459
+ }
2460
+ ```
2461
+
2462
+ ---
2463
+
2464
+ # NotificationPayload
2465
+
2466
+ ```ts
2467
+ interface NotificationPayload {
2468
+ id?: string;
2469
+
2470
+ title?: string;
2471
+
2472
+ body?: string;
2473
+
2474
+ subtitle?: string;
2475
+
2476
+ data?: Record<string, string>;
2477
+
2478
+ imageUrl?: string;
2479
+
2480
+ sentTime?: number;
2481
+
2482
+ from?: string;
2483
+ }
2484
+ ```
2485
+
2486
+ ---
2487
+
2488
+ # PermissionStatus
2489
+
2490
+ ```ts
2491
+ type PermissionStatus = "granted" | "denied" | "blocked" | "provisional";
2492
+ ```
2493
+
2494
+ ---
2495
+
2496
+ # Error Handling
2497
+
2498
+ The SDK may throw the following errors:
2499
+
2500
+ | Error | Description |
2501
+ | --------------------------- | --------------------------------------- |
2502
+ | SDKNotInitializedError | SDK method called before initialization |
2503
+ | FirebaseInitializationError | Firebase initialization failed |
2504
+ | NotifeeInitializationError | Notifee initialization failed |
2505
+ | PermissionDeniedError | Notification permission denied |
2506
+ | InvalidNotificationError | Invalid notification payload |
2507
+
2508
+ Example
2509
+
2510
+ ```tsx
2511
+ try {
2512
+ await Notifications.initialize({
2513
+ debug: true,
2514
+ });
2515
+ } catch (error) {
2516
+ console.error(error);
2517
+ }
2518
+ ```
2519
+
2520
+ ---
2521
+
2522
+ # Validation
2523
+
2524
+ The SDK validates:
2525
+
2526
+ - Notification channels
2527
+ - Display notifications
2528
+ - Scheduled notifications
2529
+ - Notification actions
2530
+
2531
+ Invalid payloads throw descriptive errors before reaching the native layer.
2532
+
2533
+ ---
2534
+
2535
+ # Thread Safety
2536
+
2537
+ The SDK is implemented as a singleton.
2538
+
2539
+ - Multiple calls to `initialize()` are ignored after the first successful initialization.
2540
+ - Event listeners are managed through an internal event bus.
2541
+ - Native services are initialized only once.
2542
+
2543
+ ---
2544
+
2545
+ # Best Practices
2546
+
2547
+ - Initialize the SDK once at app startup.
2548
+ - Keep notification payloads lightweight.
2549
+ - Store and update FCM tokens on your backend.
2550
+ - Always unsubscribe event listeners when they are no longer needed.
2551
+ - Use notification `data` for navigation rather than parsing titles or bodies.
2552
+ - Register the background handler before the app renders.
2553
+ - Disable `debug` in production.
2554
+
2555
+ ---
2556
+
2557
+ # What's Next?
2558
+
2559
+ The final section covers:
2560
+
2561
+ - Troubleshooting
2562
+ - Frequently Asked Questions (FAQ)
2563
+ - Upgrade Guide
2564
+ - Production Checklist
2565
+ - Common Firebase Errors
2566
+ - Common Expo Errors
2567
+ - Common React Native Errors
2568
+ - Security Recommendations
2569
+ - Performance Recommendations
2570
+ - License
2571
+
2572
+ ➡️ Continue to **Part 6 – Troubleshooting & Production Guide**
2573
+
2574
+ # Troubleshooting & Production Guide
2575
+
2576
+ This section contains the most common issues encountered while integrating the Notification SDK and their solutions.
2577
+
2578
+ ---
2579
+
2580
+ # Troubleshooting
2581
+
2582
+ ## SDKNotInitializedError
2583
+
2584
+ ### Error
2585
+
2586
+ ```text
2587
+ Notification SDK must be initialized before calling this method.
2588
+ ```
2589
+
2590
+ ### Cause
2591
+
2592
+ A Notification SDK method was called before `initialize()`.
2593
+
2594
+ ### Solution
2595
+
2596
+ Initialize the SDK before using any other API.
2597
+
2598
+ ```tsx
2599
+ await Notifications.initialize({
2600
+ debug: true,
2601
+ });
2602
+
2603
+ const token = await Notifications.getToken();
2604
+ ```
2605
+
2606
+ ---
2607
+
2608
+ ## RNFBAppModule not found
2609
+
2610
+ ### Error
2611
+
2612
+ ```text
2613
+ Native module RNFBAppModule not found.
2614
+ ```
2615
+
2616
+ ### Cause
2617
+
2618
+ React Native Firebase is not properly linked.
2619
+
2620
+ ### Solution (React Native CLI)
2621
+
2622
+ ```bash
2623
+ npm install @react-native-firebase/app
2624
+ npm install @react-native-firebase/messaging
2625
+
2626
+ cd ios
2627
+ pod install
2628
+ ```
2629
+
2630
+ ### Solution (Expo)
2631
+
2632
+ ```bash
2633
+ npx expo prebuild --clean
2634
+ npx expo run:android
2635
+ ```
2636
+
2637
+ ---
2638
+
2639
+ ## app.notifee:core:+ could not be found
2640
+
2641
+ ### Error
2642
+
2643
+ ```text
2644
+ Could not find app.notifee:core:+
2645
+ ```
2646
+
2647
+ ### Cause
2648
+
2649
+ The Notifee local Maven repository was not added to the Android project.
2650
+
2651
+ ### Solution
2652
+
2653
+ If using Expo Development Builds:
2654
+
2655
+ - Ensure the SDK plugin is configured.
2656
+
2657
+ ```json
2658
+ {
2659
+ "expo": {
2660
+ "plugins": [
2661
+ "@react-native-firebase/app",
2662
+ "@react-native-firebase/messaging",
2663
+ "react-native-notification-sdk/plugins"
2664
+ ]
2665
+ }
2666
+ }
2667
+ ```
2668
+
2669
+ Then regenerate native projects.
2670
+
2671
+ ```bash
2672
+ npx expo prebuild --clean
2673
+ ```
2674
+
2675
+ ---
2676
+
2677
+ ## No matching client found for package name
2678
+
2679
+ ### Error
2680
+
2681
+ ```text
2682
+ No matching client found for package name
2683
+ ```
2684
+
2685
+ ### Cause
2686
+
2687
+ The package name in `google-services.json` does not match the application's package name.
2688
+
2689
+ ### Solution
2690
+
2691
+ Register the correct Android package in Firebase.
2692
+
2693
+ Download a new:
2694
+
2695
+ ```text
2696
+ google-services.json
2697
+ ```
2698
+
2699
+ Replace:
2700
+
2701
+ ```text
2702
+ android/app/google-services.json
2703
+ ```
2704
+
2705
+ ---
2706
+
2707
+ ## GoogleService-Info.plist not found
2708
+
2709
+ ### Cause
2710
+
2711
+ The iOS Firebase configuration file is missing.
2712
+
2713
+ ### Solution
2714
+
2715
+ Download the file from Firebase.
2716
+
2717
+ Reference it in Expo.
2718
+
2719
+ ```json
2720
+ {
2721
+ "expo": {
2722
+ "ios": {
2723
+ "googleServicesFile": "./GoogleService-Info.plist"
2724
+ }
2725
+ }
2726
+ }
2727
+ ```
2728
+
2729
+ ---
2730
+
2731
+ ## Notifications not received on Android
2732
+
2733
+ Check the following:
2734
+
2735
+ - Google Play Services installed
2736
+ - Internet connection
2737
+ - Notification permission granted (Android 13+)
2738
+ - Valid Firebase token
2739
+ - Correct Firebase project
2740
+
2741
+ ---
2742
+
2743
+ ## Notifications not received on iOS
2744
+
2745
+ Verify:
2746
+
2747
+ - APNs Authentication Key uploaded
2748
+ - Push Notifications capability enabled
2749
+ - Background Modes enabled
2750
+ - Remote Notifications enabled
2751
+ - Correct Bundle Identifier
2752
+ - Physical device (simulator cannot receive push notifications)
2753
+
2754
+ ---
2755
+
2756
+ ## Foreground notifications not displayed
2757
+
2758
+ By default, Firebase does not display notifications while the application is open.
2759
+
2760
+ Enable automatic display.
2761
+
2762
+ ```tsx
2763
+ await Notifications.initialize({
2764
+ foreground: {
2765
+ displayNotifications: true,
2766
+ },
2767
+ });
2768
+ ```
2769
+
2770
+ ---
2771
+
2772
+ ## Background handler not called
2773
+
2774
+ Ensure:
2775
+
2776
+ ```tsx
2777
+ Notifications.registerBackgroundHandler(...)
2778
+ ```
2779
+
2780
+ is registered **before** rendering the application.
2781
+
2782
+ Only one background handler should exist.
2783
+
2784
+ ---
2785
+
2786
+ ## Scheduled notifications not appearing
2787
+
2788
+ Verify:
2789
+
2790
+ - Notification permission granted
2791
+ - Device date and time correct
2792
+ - Trigger timestamp is in the future
2793
+
2794
+ ---
2795
+
2796
+ # Frequently Asked Questions
2797
+
2798
+ ## Does this SDK support Expo Go?
2799
+
2800
+ No.
2801
+
2802
+ Firebase Messaging and Notifee require native modules that are unavailable in Expo Go.
2803
+
2804
+ Use an Expo Development Build.
2805
+
2806
+ ---
2807
+
2808
+ ## Does this SDK support React Native CLI?
2809
+
2810
+ Yes.
2811
+
2812
+ React Native CLI is fully supported.
2813
+
2814
+ ---
2815
+
2816
+ ## Does this SDK support Expo?
2817
+
2818
+ Yes.
2819
+
2820
+ Supported through Expo Development Builds.
2821
+
2822
+ ---
2823
+
2824
+ ## Do I need Notifee?
2825
+
2826
+ Yes.
2827
+
2828
+ Notifee is responsible for:
2829
+
2830
+ - Local notifications
2831
+ - Scheduled notifications
2832
+ - Notification actions
2833
+ - Foreground notification display
2834
+
2835
+ ---
2836
+
2837
+ ## Do I need Firebase?
2838
+
2839
+ Yes.
2840
+
2841
+ Firebase Cloud Messaging is required for remote push notifications.
2842
+
2843
+ ---
2844
+
2845
+ ## Can I disable automatic notification display?
2846
+
2847
+ Yes.
2848
+
2849
+ Foreground
2850
+
2851
+ ```tsx
2852
+ foreground: {
2853
+ displayNotifications: false;
2854
+ }
2855
+ ```
2856
+
2857
+ Background
2858
+
2859
+ ```tsx
2860
+ background: {
2861
+ displayNotifications: false;
2862
+ }
2863
+ ```
2864
+
2865
+ ---
2866
+
2867
+ ## Can I display my own UI?
2868
+
2869
+ Yes.
2870
+
2871
+ Listen for:
2872
+
2873
+ ```tsx
2874
+ Notifications.on(
2875
+ "notificationReceived",
2876
+ ...
2877
+ )
2878
+ ```
2879
+
2880
+ and display your own interface.
2881
+
2882
+ ---
2883
+
2884
+ ## Is initialization safe to call multiple times?
2885
+
2886
+ Yes.
2887
+
2888
+ The SDK ignores repeated calls after successful initialization.
2889
+
2890
+ ---
2891
+
2892
+ ## Does the SDK refresh tokens automatically?
2893
+
2894
+ Yes.
2895
+
2896
+ Listen for:
2897
+
2898
+ ```tsx
2899
+ Notifications.on("tokenRefresh");
2900
+ ```
2901
+
2902
+ and update your backend.
2903
+
2904
+ ---
2905
+
2906
+ ## Can I schedule notifications?
2907
+
2908
+ Yes.
2909
+
2910
+ ```tsx
2911
+ await Notifications.scheduleNotification(...)
2912
+ ```
2913
+
2914
+ ---
2915
+
2916
+ ## Can I cancel scheduled notifications?
2917
+
2918
+ Yes.
2919
+
2920
+ ```tsx
2921
+ await Notifications.cancelScheduledNotification(id);
2922
+ ```
2923
+
2924
+ or
2925
+
2926
+ ```tsx
2927
+ await Notifications.cancelAllScheduledNotifications();
2928
+ ```
2929
+
2930
+ ---
2931
+
2932
+ ## Can I deep link into my application?
2933
+
2934
+ Yes.
2935
+
2936
+ Use notification `data` inside:
2937
+
2938
+ ```tsx
2939
+ notificationOpened;
2940
+ ```
2941
+
2942
+ to navigate to a specific screen.
2943
+
2944
+ ---
2945
+
2946
+ # Security Recommendations
2947
+
2948
+ - Never expose Firebase Server Keys in the client application.
2949
+ - Store FCM tokens securely on your backend.
2950
+ - Validate notification payloads on the server.
2951
+ - Use HTTPS for all notification-related APIs.
2952
+ - Remove FCM tokens when users log out.
2953
+
2954
+ ---
2955
+
2956
+ # Performance Recommendations
2957
+
2958
+ - Initialize the SDK only once.
2959
+ - Keep background handlers lightweight.
2960
+ - Avoid large notification payloads.
2961
+ - Use notification channels to organize notifications.
2962
+ - Batch backend token updates when possible.
2963
+
2964
+ ---
2965
+
2966
+ # Upgrade Guide
2967
+
2968
+ After upgrading the SDK:
2969
+
2970
+ ### React Native CLI
2971
+
2972
+ ```bash
2973
+ npm install
2974
+
2975
+ cd ios
2976
+ pod install
2977
+ ```
2978
+
2979
+ ### Expo
2980
+
2981
+ ```bash
2982
+ npm install
2983
+
2984
+ npx expo prebuild --clean
2985
+
2986
+ npx expo run:android
2987
+
2988
+ npx expo run:ios
2989
+ ```
2990
+
2991
+ ---
2992
+
2993
+ # Production Checklist
2994
+
2995
+ Before releasing your application:
2996
+
2997
+ ## Firebase
2998
+
2999
+ - ✅ Firebase project created
3000
+ - ✅ Android application registered
3001
+ - ✅ iOS application registered
3002
+ - ✅ SHA-1 uploaded (Android)
3003
+ - ✅ SHA-256 uploaded (Android)
3004
+ - ✅ APNs Authentication Key uploaded (iOS)
3005
+
3006
+ ## Android
3007
+
3008
+ - ✅ `google-services.json` added
3009
+ - ✅ Notification permission requested (Android 13+)
3010
+ - ✅ Notification channels configured
3011
+ - ✅ Small notification icon added
3012
+
3013
+ ## iOS
3014
+
3015
+ - ✅ `GoogleService-Info.plist` added
3016
+ - ✅ Push Notifications capability enabled
3017
+ - ✅ Background Modes enabled
3018
+ - ✅ Remote Notifications enabled
3019
+
3020
+ ## SDK
3021
+
3022
+ - ✅ SDK initialized
3023
+ - ✅ Background handler registered
3024
+ - ✅ Foreground notifications configured
3025
+ - ✅ Notification actions tested
3026
+ - ✅ Scheduled notifications tested
3027
+ - ✅ Token stored on backend
3028
+ - ✅ Token refresh handling implemented
3029
+
3030
+ ## Testing
3031
+
3032
+ - ✅ Android physical device tested
3033
+ - ✅ iOS physical device tested
3034
+ - ✅ Foreground notifications tested
3035
+ - ✅ Background notifications tested
3036
+ - ✅ Terminated app notifications tested
3037
+ - ✅ Notification open events tested
3038
+ - ✅ Notification action buttons tested
3039
+
3040
+ ---
3041
+
3042
+ # Automatic Features
3043
+
3044
+ The SDK automatically:
3045
+
3046
+ - Initializes Firebase
3047
+ - Initializes Notifee
3048
+ - Creates Android notification channels
3049
+ - Registers Firebase listeners
3050
+ - Registers notification listeners
3051
+ - Maps Firebase payloads to a unified notification payload
3052
+ - Emits notification lifecycle events
3053
+ - Generates and refreshes FCM tokens
3054
+ - Displays foreground notifications (optional)
3055
+ - Displays background data notifications (optional)
3056
+
3057
+ ---
3058
+
3059
+ # License
3060
+
3061
+ MIT License
3062
+
3063
+ ---
3064
+
3065
+ # Support
3066
+
3067
+ If you encounter issues:
3068
+
3069
+ 1. Verify your Firebase configuration.
3070
+ 2. Verify Android package name and iOS bundle identifier.
3071
+ 3. Ensure native projects are rebuilt after configuration changes.
3072
+ 4. Review the troubleshooting section above before opening an issue.
3073
+
3074
+ ---
3075
+
3076
+ # Thank You
3077
+
3078
+ Thank you for choosing **React Native Notification SDK**.
3079
+
3080
+ We hope this SDK helps you build reliable, scalable, and production-ready notification experiences with minimal setup while retaining the flexibility required for advanced notification workflows.
3081
+
3082
+ Happy coding! 🚀