react-native-notify-kit 9.7.0 → 10.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 (111) hide show
  1. package/README.md +140 -6
  2. package/RNNotifeeCore.podspec +2 -0
  3. package/android/src/androidTest/java/app/notifee/core/RebootRecoveryTest.java +94 -2
  4. package/android/src/main/AndroidManifest.xml +8 -7
  5. package/android/src/main/java/app/notifee/core/NotificationManager.java +2 -0
  6. package/android/src/main/java/app/notifee/core/model/NotificationAndroidModel.java +8 -3
  7. package/android/src/main/java/app/notifee/core/utility/ResourceUtils.java +28 -0
  8. package/android/src/test/java/app/notifee/core/model/NotificationAndroidModelSmallIconFallbackTest.java +74 -0
  9. package/android/src/test/java/app/notifee/core/utility/ResourceUtilsFallbackIconTest.java +116 -0
  10. package/cli/bin/react-native-notify-kit +2 -0
  11. package/cli/dist/cli.bundle.js +20834 -0
  12. package/cli/dist/cli.d.ts +2 -0
  13. package/cli/dist/cli.js +87 -0
  14. package/cli/dist/cli.js.map +1 -0
  15. package/cli/dist/commands/initNse.d.ts +12 -0
  16. package/cli/dist/commands/initNse.js +212 -0
  17. package/cli/dist/commands/initNse.js.map +1 -0
  18. package/cli/dist/lib/detectProject.d.ts +15 -0
  19. package/cli/dist/lib/detectProject.js +156 -0
  20. package/cli/dist/lib/detectProject.js.map +1 -0
  21. package/cli/dist/lib/logger.d.ts +4 -0
  22. package/cli/dist/lib/logger.js +24 -0
  23. package/cli/dist/lib/logger.js.map +1 -0
  24. package/cli/dist/lib/patchPodfile.d.ts +12 -0
  25. package/cli/dist/lib/patchPodfile.js +143 -0
  26. package/cli/dist/lib/patchPodfile.js.map +1 -0
  27. package/cli/dist/lib/patchXcodeProject.d.ts +25 -0
  28. package/cli/dist/lib/patchXcodeProject.js +239 -0
  29. package/cli/dist/lib/patchXcodeProject.js.map +1 -0
  30. package/cli/dist/lib/writeTemplates.d.ts +11 -0
  31. package/cli/dist/lib/writeTemplates.js +82 -0
  32. package/cli/dist/lib/writeTemplates.js.map +1 -0
  33. package/cli/dist/templates/Info.plist.tmpl +29 -0
  34. package/cli/dist/templates/NotificationService.swift.tmpl +32 -0
  35. package/cli/dist/templates/NotifyKitNSE.entitlements.tmpl +6 -0
  36. package/cli/dist/templates/templates/Info.plist.tmpl +29 -0
  37. package/cli/dist/templates/templates/NotificationService.swift.tmpl +73 -0
  38. package/cli/dist/templates/templates/NotifyKitNSE.entitlements.tmpl +6 -0
  39. package/dist/NotifeeApiModule.d.ts +17 -0
  40. package/dist/NotifeeApiModule.js +66 -1
  41. package/dist/NotifeeApiModule.js.map +1 -1
  42. package/dist/fcm/index.d.ts +4 -0
  43. package/dist/fcm/index.js +3 -0
  44. package/dist/fcm/index.js.map +1 -0
  45. package/dist/fcm/parseFcmPayload.d.ts +16 -0
  46. package/dist/fcm/parseFcmPayload.js +37 -0
  47. package/dist/fcm/parseFcmPayload.js.map +1 -0
  48. package/dist/fcm/reconstructNotification.d.ts +8 -0
  49. package/dist/fcm/reconstructNotification.js +167 -0
  50. package/dist/fcm/reconstructNotification.js.map +1 -0
  51. package/dist/fcm/types.d.ts +51 -0
  52. package/dist/fcm/types.js +6 -0
  53. package/dist/fcm/types.js.map +1 -0
  54. package/dist/index.d.ts +2 -0
  55. package/dist/index.js +1 -0
  56. package/dist/index.js.map +1 -1
  57. package/dist/types/Module.d.ts +21 -0
  58. package/dist/validators/validateTrigger.js +16 -0
  59. package/dist/validators/validateTrigger.js.map +1 -1
  60. package/dist/version.d.ts +1 -1
  61. package/dist/version.js +1 -1
  62. package/dist/version.js.map +1 -1
  63. package/package.json +38 -3
  64. package/server/README.md +129 -0
  65. package/server/dist/android.d.ts +8 -0
  66. package/server/dist/android.d.ts.map +1 -0
  67. package/server/dist/android.js +20 -0
  68. package/server/dist/android.js.map +1 -0
  69. package/server/dist/buildPayload.d.ts +3 -0
  70. package/server/dist/buildPayload.d.ts.map +1 -0
  71. package/server/dist/buildPayload.js +82 -0
  72. package/server/dist/buildPayload.js.map +1 -0
  73. package/server/dist/index.d.ts +6 -0
  74. package/server/dist/index.d.ts.map +1 -0
  75. package/server/dist/index.js +12 -0
  76. package/server/dist/index.js.map +1 -0
  77. package/server/dist/ios.d.ts +11 -0
  78. package/server/dist/ios.d.ts.map +1 -0
  79. package/server/dist/ios.js +61 -0
  80. package/server/dist/ios.js.map +1 -0
  81. package/server/dist/serialize.d.ts +11 -0
  82. package/server/dist/serialize.d.ts.map +1 -0
  83. package/server/dist/serialize.js +32 -0
  84. package/server/dist/serialize.js.map +1 -0
  85. package/server/dist/types.d.ts +2 -0
  86. package/server/dist/types.d.ts.map +1 -0
  87. package/server/dist/types.js +3 -0
  88. package/server/dist/types.js.map +1 -0
  89. package/server/dist/validation.d.ts +3 -0
  90. package/server/dist/validation.d.ts.map +1 -0
  91. package/server/dist/validation.js +101 -0
  92. package/server/dist/validation.js.map +1 -0
  93. package/server/package.json +5 -0
  94. package/server/src/android.ts +27 -0
  95. package/server/src/buildPayload.ts +91 -0
  96. package/server/src/index.ts +12 -0
  97. package/server/src/ios.ts +88 -0
  98. package/server/src/serialize.ts +39 -0
  99. package/server/src/types.ts +24 -0
  100. package/server/src/validation.ts +134 -0
  101. package/server/tsconfig.json +25 -0
  102. package/src/NotifeeApiModule.ts +80 -1
  103. package/src/fcm/index.ts +4 -0
  104. package/src/fcm/parseFcmPayload.ts +56 -0
  105. package/src/fcm/reconstructNotification.ts +201 -0
  106. package/src/fcm/types.ts +57 -0
  107. package/src/index.ts +2 -0
  108. package/src/internal/fcmContract.d.ts +150 -0
  109. package/src/types/Module.ts +23 -0
  110. package/src/validators/validateTrigger.ts +24 -0
  111. package/src/version.ts +1 -1
@@ -0,0 +1,116 @@
1
+ package app.notifee.core.utility;
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ import static org.junit.Assert.assertEquals;
20
+ import static org.junit.Assert.assertNotEquals;
21
+ import static org.mockito.Mockito.mock;
22
+ import static org.mockito.Mockito.when;
23
+
24
+ import android.content.Context;
25
+ import android.content.pm.ApplicationInfo;
26
+ import org.junit.Test;
27
+ import org.junit.runner.RunWith;
28
+ import org.robolectric.RobolectricTestRunner;
29
+
30
+ /**
31
+ * Unit coverage for {@link ResourceUtils#getFallbackSmallIconId(Context)} — the three-layer
32
+ * fallback that keeps a notification valid when the user-supplied {@code smallIcon} string cannot
33
+ * be resolved. Guards the invariant that the method never returns 0 and never throws, which is what
34
+ * {@link app.notifee.core.NotificationManager} relies on to avoid the {@code
35
+ * IllegalArgumentException: Invalid notification (no valid small icon)} crash that motivated the
36
+ * fix (upstream invertase/notifee#733).
37
+ */
38
+ @RunWith(RobolectricTestRunner.class)
39
+ public class ResourceUtilsFallbackIconTest {
40
+
41
+ @Test
42
+ public void returnsApplicationInfoIcon_whenIconNonZero() {
43
+ ApplicationInfo info = new ApplicationInfo();
44
+ info.icon = 0x7f080001;
45
+ info.logo = 0x7f080002;
46
+ Context context = mock(Context.class);
47
+ when(context.getApplicationInfo()).thenReturn(info);
48
+
49
+ assertEquals(0x7f080001, ResourceUtils.getFallbackSmallIconId(context));
50
+ }
51
+
52
+ @Test
53
+ public void returnsApplicationInfoLogo_whenIconZeroAndLogoNonZero() {
54
+ ApplicationInfo info = new ApplicationInfo();
55
+ info.icon = 0;
56
+ info.logo = 0x7f080002;
57
+ Context context = mock(Context.class);
58
+ when(context.getApplicationInfo()).thenReturn(info);
59
+
60
+ assertEquals(0x7f080002, ResourceUtils.getFallbackSmallIconId(context));
61
+ }
62
+
63
+ @Test
64
+ public void returnsSystemDefault_whenIconAndLogoZero() {
65
+ ApplicationInfo info = new ApplicationInfo();
66
+ info.icon = 0;
67
+ info.logo = 0;
68
+ Context context = mock(Context.class);
69
+ when(context.getApplicationInfo()).thenReturn(info);
70
+
71
+ assertEquals(android.R.drawable.ic_dialog_info, ResourceUtils.getFallbackSmallIconId(context));
72
+ }
73
+
74
+ @Test
75
+ public void returnsSystemDefault_whenGetApplicationInfoThrows() {
76
+ Context context = mock(Context.class);
77
+ when(context.getApplicationInfo()).thenThrow(new RuntimeException("boom"));
78
+
79
+ assertEquals(android.R.drawable.ic_dialog_info, ResourceUtils.getFallbackSmallIconId(context));
80
+ }
81
+
82
+ @Test
83
+ public void returnsSystemDefault_whenContextIsNull() {
84
+ assertEquals(android.R.drawable.ic_dialog_info, ResourceUtils.getFallbackSmallIconId(null));
85
+ }
86
+
87
+ @Test
88
+ public void neverReturnsZero_acrossAllPaths() {
89
+ // Path 1: icon present
90
+ ApplicationInfo infoIcon = new ApplicationInfo();
91
+ infoIcon.icon = 0x7f080001;
92
+ Context ctxIcon = mock(Context.class);
93
+ when(ctxIcon.getApplicationInfo()).thenReturn(infoIcon);
94
+ assertNotEquals(0, ResourceUtils.getFallbackSmallIconId(ctxIcon));
95
+
96
+ // Path 2: logo fallback
97
+ ApplicationInfo infoLogo = new ApplicationInfo();
98
+ infoLogo.logo = 0x7f080002;
99
+ Context ctxLogo = mock(Context.class);
100
+ when(ctxLogo.getApplicationInfo()).thenReturn(infoLogo);
101
+ assertNotEquals(0, ResourceUtils.getFallbackSmallIconId(ctxLogo));
102
+
103
+ // Path 3: system default (empty ApplicationInfo, icon and logo both zero)
104
+ Context ctxEmpty = mock(Context.class);
105
+ when(ctxEmpty.getApplicationInfo()).thenReturn(new ApplicationInfo());
106
+ assertNotEquals(0, ResourceUtils.getFallbackSmallIconId(ctxEmpty));
107
+
108
+ // Path 4: exception branch
109
+ Context ctxThrows = mock(Context.class);
110
+ when(ctxThrows.getApplicationInfo()).thenThrow(new RuntimeException());
111
+ assertNotEquals(0, ResourceUtils.getFallbackSmallIconId(ctxThrows));
112
+
113
+ // Path 5: null context
114
+ assertNotEquals(0, ResourceUtils.getFallbackSmallIconId(null));
115
+ }
116
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../dist/cli.js');