@ammarahmed/notifee-react-native 7.3.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 (215) hide show
  1. package/.gitattributes +3 -0
  2. package/LICENSE +44 -0
  3. package/README.md +131 -0
  4. package/RNNotifee.podspec +39 -0
  5. package/RNNotifeeCore.podspec +33 -0
  6. package/android/build.gradle +116 -0
  7. package/android/gradle.properties +1 -0
  8. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar +0 -0
  9. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.md5 +1 -0
  10. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha1 +1 -0
  11. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha256 +1 -0
  12. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha512 +1 -0
  13. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom +9 -0
  14. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.md5 +1 -0
  15. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha1 +1 -0
  16. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha256 +1 -0
  17. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha512 +1 -0
  18. package/android/libs/app/notifee/core/maven-metadata.xml +13 -0
  19. package/android/libs/app/notifee/core/maven-metadata.xml.md5 +1 -0
  20. package/android/libs/app/notifee/core/maven-metadata.xml.sha1 +1 -0
  21. package/android/libs/app/notifee/core/maven-metadata.xml.sha256 +1 -0
  22. package/android/libs/app/notifee/core/maven-metadata.xml.sha512 +1 -0
  23. package/android/lint.xml +5 -0
  24. package/android/proguard-rules.pro +74 -0
  25. package/android/settings.gradle +1 -0
  26. package/android/src/main/AndroidManifest.xml +12 -0
  27. package/android/src/main/java/io/invertase/notifee/NotifeeApiModule.java +349 -0
  28. package/android/src/main/java/io/invertase/notifee/NotifeeEventSubscriber.java +118 -0
  29. package/android/src/main/java/io/invertase/notifee/NotifeeInitProvider.java +55 -0
  30. package/android/src/main/java/io/invertase/notifee/NotifeePackage.java +30 -0
  31. package/android/src/main/java/io/invertase/notifee/NotifeeReactUtils.java +244 -0
  32. package/app.plugin.js +1 -0
  33. package/dist/NotifeeApiModule.d.ts +53 -0
  34. package/dist/NotifeeApiModule.js +607 -0
  35. package/dist/NotifeeApiModule.js.map +1 -0
  36. package/dist/NotifeeJSEventEmitter.d.ts +3 -0
  37. package/dist/NotifeeJSEventEmitter.js +14 -0
  38. package/dist/NotifeeJSEventEmitter.js.map +1 -0
  39. package/dist/NotifeeNativeError.d.ts +15 -0
  40. package/dist/NotifeeNativeError.js +61 -0
  41. package/dist/NotifeeNativeError.js.map +1 -0
  42. package/dist/NotifeeNativeModule.d.ts +14 -0
  43. package/dist/NotifeeNativeModule.js +43 -0
  44. package/dist/NotifeeNativeModule.js.map +1 -0
  45. package/dist/NotifeeNativeModule.web.d.ts +12 -0
  46. package/dist/NotifeeNativeModule.web.js +19 -0
  47. package/dist/NotifeeNativeModule.web.js.map +1 -0
  48. package/dist/index.d.ts +8 -0
  49. package/dist/index.js +43 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/types/Library.d.ts +21 -0
  52. package/dist/types/Library.js +6 -0
  53. package/dist/types/Library.js.map +1 -0
  54. package/dist/types/Module.d.ts +572 -0
  55. package/dist/types/Module.js +6 -0
  56. package/dist/types/Module.js.map +1 -0
  57. package/dist/types/Notification.d.ts +450 -0
  58. package/dist/types/Notification.js +105 -0
  59. package/dist/types/Notification.js.map +1 -0
  60. package/dist/types/NotificationAndroid.d.ts +1276 -0
  61. package/dist/types/NotificationAndroid.js +380 -0
  62. package/dist/types/NotificationAndroid.js.map +1 -0
  63. package/dist/types/NotificationIOS.d.ts +537 -0
  64. package/dist/types/NotificationIOS.js +92 -0
  65. package/dist/types/NotificationIOS.js.map +1 -0
  66. package/dist/types/NotificationWeb.d.ts +5 -0
  67. package/dist/types/NotificationWeb.js +3 -0
  68. package/dist/types/NotificationWeb.js.map +1 -0
  69. package/dist/types/PowerManagerInfo.d.ts +36 -0
  70. package/dist/types/PowerManagerInfo.js +6 -0
  71. package/dist/types/PowerManagerInfo.js.map +1 -0
  72. package/dist/types/Trigger.d.ts +108 -0
  73. package/dist/types/Trigger.js +39 -0
  74. package/dist/types/Trigger.js.map +1 -0
  75. package/dist/utils/id.d.ts +1 -0
  76. package/dist/utils/id.js +16 -0
  77. package/dist/utils/id.js.map +1 -0
  78. package/dist/utils/index.d.ts +16 -0
  79. package/dist/utils/index.js +52 -0
  80. package/dist/utils/index.js.map +1 -0
  81. package/dist/utils/validate.d.ts +15 -0
  82. package/dist/utils/validate.js +93 -0
  83. package/dist/utils/validate.js.map +1 -0
  84. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.d.ts +2 -0
  85. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js +39 -0
  86. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js.map +1 -0
  87. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.d.ts +2 -0
  88. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js +27 -0
  89. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js.map +1 -0
  90. package/dist/validators/validate.d.ts +25 -0
  91. package/dist/validators/validate.js +75 -0
  92. package/dist/validators/validate.js.map +1 -0
  93. package/dist/validators/validateAndroidAction.d.ts +2 -0
  94. package/dist/validators/validateAndroidAction.js +52 -0
  95. package/dist/validators/validateAndroidAction.js.map +1 -0
  96. package/dist/validators/validateAndroidChannel.d.ts +2 -0
  97. package/dist/validators/validateAndroidChannel.js +155 -0
  98. package/dist/validators/validateAndroidChannel.js.map +1 -0
  99. package/dist/validators/validateAndroidChannelGroup.d.ts +2 -0
  100. package/dist/validators/validateAndroidChannelGroup.js +42 -0
  101. package/dist/validators/validateAndroidChannelGroup.js.map +1 -0
  102. package/dist/validators/validateAndroidFullScreenAction.d.ts +2 -0
  103. package/dist/validators/validateAndroidFullScreenAction.js +50 -0
  104. package/dist/validators/validateAndroidFullScreenAction.js.map +1 -0
  105. package/dist/validators/validateAndroidInput.d.ts +2 -0
  106. package/dist/validators/validateAndroidInput.js +54 -0
  107. package/dist/validators/validateAndroidInput.js.map +1 -0
  108. package/dist/validators/validateAndroidNotification.d.ts +2 -0
  109. package/dist/validators/validateAndroidNotification.js +529 -0
  110. package/dist/validators/validateAndroidNotification.js.map +1 -0
  111. package/dist/validators/validateAndroidPressAction.d.ts +2 -0
  112. package/dist/validators/validateAndroidPressAction.js +50 -0
  113. package/dist/validators/validateAndroidPressAction.js.map +1 -0
  114. package/dist/validators/validateAndroidStyle.d.ts +22 -0
  115. package/dist/validators/validateAndroidStyle.js +231 -0
  116. package/dist/validators/validateAndroidStyle.js.map +1 -0
  117. package/dist/validators/validateIOSAttachment.d.ts +6 -0
  118. package/dist/validators/validateIOSAttachment.js +102 -0
  119. package/dist/validators/validateIOSAttachment.js.map +1 -0
  120. package/dist/validators/validateIOSCategory.d.ts +2 -0
  121. package/dist/validators/validateIOSCategory.js +124 -0
  122. package/dist/validators/validateIOSCategory.js.map +1 -0
  123. package/dist/validators/validateIOSCategoryAction.d.ts +2 -0
  124. package/dist/validators/validateIOSCategoryAction.js +59 -0
  125. package/dist/validators/validateIOSCategoryAction.js.map +1 -0
  126. package/dist/validators/validateIOSInput.d.ts +2 -0
  127. package/dist/validators/validateIOSInput.js +32 -0
  128. package/dist/validators/validateIOSInput.js.map +1 -0
  129. package/dist/validators/validateIOSNotification.d.ts +2 -0
  130. package/dist/validators/validateIOSNotification.js +211 -0
  131. package/dist/validators/validateIOSNotification.js.map +1 -0
  132. package/dist/validators/validateIOSPermissions.d.ts +2 -0
  133. package/dist/validators/validateIOSPermissions.js +62 -0
  134. package/dist/validators/validateIOSPermissions.js.map +1 -0
  135. package/dist/validators/validateNotification.d.ts +11 -0
  136. package/dist/validators/validateNotification.js +129 -0
  137. package/dist/validators/validateNotification.js.map +1 -0
  138. package/dist/validators/validateTrigger.d.ts +2 -0
  139. package/dist/validators/validateTrigger.js +104 -0
  140. package/dist/validators/validateTrigger.js.map +1 -0
  141. package/dist/version.d.ts +1 -0
  142. package/dist/version.js.map +1 -0
  143. package/ios/NotifeeCore/Info.plist +22 -0
  144. package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.h +28 -0
  145. package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m +72 -0
  146. package/ios/NotifeeCore/NotifeeCore+NSURLSession.h +25 -0
  147. package/ios/NotifeeCore/NotifeeCore+NSURLSession.m +55 -0
  148. package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.h +37 -0
  149. package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m +242 -0
  150. package/ios/NotifeeCore/NotifeeCore.h +118 -0
  151. package/ios/NotifeeCore/NotifeeCore.m +784 -0
  152. package/ios/NotifeeCore/NotifeeCoreDelegateHolder.h +34 -0
  153. package/ios/NotifeeCore/NotifeeCoreDelegateHolder.m +70 -0
  154. package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.h +39 -0
  155. package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.m +68 -0
  156. package/ios/NotifeeCore/NotifeeCoreExtensionHelper.h +38 -0
  157. package/ios/NotifeeCore/NotifeeCoreExtensionHelper.m +224 -0
  158. package/ios/NotifeeCore/NotifeeCoreUtil.h +82 -0
  159. package/ios/NotifeeCore/NotifeeCoreUtil.m +793 -0
  160. package/ios/RNNotifee/NotifeeApiModule.h +25 -0
  161. package/ios/RNNotifee/NotifeeApiModule.m +371 -0
  162. package/ios/RNNotifee/NotifeeExtensionHelper.h +37 -0
  163. package/ios/RNNotifee/NotifeeExtensionHelper.m +37 -0
  164. package/ios/RNNotifee.xcodeproj/project.pbxproj +318 -0
  165. package/jest-mock.js +158 -0
  166. package/package.json +59 -0
  167. package/plugin/build/index.d.ts +3 -0
  168. package/plugin/build/index.js +12 -0
  169. package/plugin/build/index.js.map +1 -0
  170. package/plugin/build/withNotifeeProjectGradlePlugin.d.ts +5 -0
  171. package/plugin/build/withNotifeeProjectGradlePlugin.js +24 -0
  172. package/plugin/build/withNotifeeProjectGradlePlugin.js.map +1 -0
  173. package/plugin/src/index.ts +9 -0
  174. package/plugin/src/withNotifeeProjectGradlePlugin.ts +27 -0
  175. package/plugin/tsconfig.json +9 -0
  176. package/react-native.config.js +11 -0
  177. package/refresh-example.sh +71 -0
  178. package/src/NotifeeApiModule.ts +825 -0
  179. package/src/NotifeeJSEventEmitter.ts +11 -0
  180. package/src/NotifeeNativeError.ts +70 -0
  181. package/src/NotifeeNativeModule.ts +55 -0
  182. package/src/NotifeeNativeModule.web.ts +25 -0
  183. package/src/index.ts +33 -0
  184. package/src/types/Library.ts +28 -0
  185. package/src/types/Module.ts +625 -0
  186. package/src/types/Notification.ts +505 -0
  187. package/src/types/NotificationAndroid.ts +1443 -0
  188. package/src/types/NotificationIOS.ts +681 -0
  189. package/src/types/NotificationWeb.ts +5 -0
  190. package/src/types/PowerManagerInfo.ts +43 -0
  191. package/src/types/Trigger.ts +118 -0
  192. package/src/utils/id.ts +13 -0
  193. package/src/utils/index.ts +47 -0
  194. package/src/utils/validate.ts +92 -0
  195. package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfo.ts +45 -0
  196. package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.ts +33 -0
  197. package/src/validators/validate.ts +85 -0
  198. package/src/validators/validateAndroidAction.ts +54 -0
  199. package/src/validators/validateAndroidChannel.ts +188 -0
  200. package/src/validators/validateAndroidChannelGroup.ts +49 -0
  201. package/src/validators/validateAndroidFullScreenAction.ts +65 -0
  202. package/src/validators/validateAndroidInput.ts +67 -0
  203. package/src/validators/validateAndroidNotification.ts +704 -0
  204. package/src/validators/validateAndroidPressAction.ts +65 -0
  205. package/src/validators/validateAndroidStyle.ts +315 -0
  206. package/src/validators/validateIOSAttachment.ts +136 -0
  207. package/src/validators/validateIOSCategory.ts +150 -0
  208. package/src/validators/validateIOSCategoryAction.ts +65 -0
  209. package/src/validators/validateIOSInput.ts +38 -0
  210. package/src/validators/validateIOSNotification.ts +296 -0
  211. package/src/validators/validateIOSPermissions.ts +78 -0
  212. package/src/validators/validateNotification.ts +156 -0
  213. package/src/validators/validateTrigger.ts +134 -0
  214. package/src/version.ts +2 -0
  215. package/tsconfig.json +23 -0
@@ -0,0 +1,704 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
2
+ /*
3
+ * Copyright (c) 2016-present Invertase Limited
4
+ */
5
+ import { Image } from 'react-native';
6
+
7
+ import {
8
+ objectHasProperty,
9
+ isArray,
10
+ isArrayOfStrings,
11
+ isBoolean,
12
+ isNumber,
13
+ isObject,
14
+ isString,
15
+ isUndefined,
16
+ isIOS,
17
+ } from '../utils';
18
+
19
+ import { AndroidImportance } from '../types/NotificationAndroid';
20
+ import {
21
+ AndroidBadgeIconType,
22
+ AndroidCategory,
23
+ AndroidDefaults,
24
+ AndroidFlags,
25
+ AndroidGroupAlertBehavior,
26
+ AndroidProgress,
27
+ AndroidStyle,
28
+ AndroidVisibility,
29
+ NotificationAndroid,
30
+ } from '../types/NotificationAndroid';
31
+
32
+ import {
33
+ isValidColor,
34
+ isValidLightPattern,
35
+ isValidTimestamp,
36
+ isValidVibratePattern,
37
+ } from './validate';
38
+
39
+ import {
40
+ validateAndroidBigPictureStyle,
41
+ validateAndroidBigTextStyle,
42
+ validateAndroidInboxStyle,
43
+ validateAndroidMessagingStyle,
44
+ } from './validateAndroidStyle';
45
+ import validateAndroidPressAction from './validateAndroidPressAction';
46
+ import validateAndroidFullScreenAction from './validateAndroidFullScreenAction';
47
+ import validateAndroidAction from './validateAndroidAction';
48
+
49
+ export default function validateAndroidNotification(
50
+ android?: NotificationAndroid,
51
+ ): NotificationAndroid {
52
+ // Notification default values
53
+ const out: NotificationAndroid = {
54
+ autoCancel: true,
55
+ asForegroundService: false,
56
+ lightUpScreen: false,
57
+ badgeIconType: AndroidBadgeIconType.LARGE,
58
+ colorized: false,
59
+ chronometerDirection: 'up',
60
+ defaults: [AndroidDefaults.ALL],
61
+ groupAlertBehavior: AndroidGroupAlertBehavior.ALL,
62
+ groupSummary: false,
63
+ localOnly: false,
64
+ ongoing: false,
65
+ loopSound: false,
66
+ onlyAlertOnce: false,
67
+ importance: AndroidImportance.DEFAULT,
68
+ showTimestamp: false,
69
+ smallIcon: 'ic_launcher',
70
+ showChronometer: false,
71
+ visibility: AndroidVisibility.PRIVATE,
72
+ circularLargeIcon: false,
73
+ };
74
+
75
+ /* Skip validating if iOS in release */
76
+ if (isIOS && !__DEV__) return out;
77
+
78
+ if (isUndefined(android)) {
79
+ return out;
80
+ }
81
+
82
+ if (!isUndefined(android) && !isObject(android)) {
83
+ throw new Error("'notification.android' expected an object value.");
84
+ }
85
+
86
+ /**
87
+ * actions
88
+ */
89
+ if (objectHasProperty(android, 'actions') && android.actions !== undefined) {
90
+ if (!isArray(android.actions)) {
91
+ throw new Error("'notification.android.actions' expected an array of AndroidAction types.");
92
+ }
93
+
94
+ const actions = [];
95
+ try {
96
+ for (let i = 0; i < android.actions.length; i++) {
97
+ actions.push(validateAndroidAction(android.actions[i]));
98
+ }
99
+ } catch (e: any) {
100
+ throw new Error(`'notification.android.actions' invalid AndroidAction. ${e.message}.`);
101
+ }
102
+
103
+ if (actions.length) {
104
+ out.actions = actions;
105
+ }
106
+ }
107
+
108
+ /**
109
+ * asForegroundService
110
+ */
111
+ if (objectHasProperty(android, 'asForegroundService')) {
112
+ if (!isBoolean(android.asForegroundService)) {
113
+ throw new Error("'notification.android.asForegroundService' expected a boolean value.");
114
+ }
115
+
116
+ out.asForegroundService = android.asForegroundService;
117
+ }
118
+
119
+ /**
120
+ * lightUpScreen
121
+ */
122
+ if (objectHasProperty(android, 'lightUpScreen')) {
123
+ if (!isBoolean(android.lightUpScreen)) {
124
+ throw new Error("'notification.android.lightUpScreen' expected a boolean value.");
125
+ }
126
+
127
+ out.lightUpScreen = android.lightUpScreen;
128
+ }
129
+
130
+ /**
131
+ * autoCancel
132
+ */
133
+ if (objectHasProperty(android, 'autoCancel')) {
134
+ if (!isBoolean(android.autoCancel)) {
135
+ throw new Error("'notification.android.autoCancel' expected a boolean value.");
136
+ }
137
+
138
+ out.autoCancel = android.autoCancel;
139
+ }
140
+
141
+ /**
142
+ * badgeCount
143
+ */
144
+ if (objectHasProperty(android, 'badgeCount')) {
145
+ if (!isNumber(android.badgeCount)) {
146
+ throw new Error("'notification.android.badgeCount' expected a number value.");
147
+ }
148
+
149
+ out.badgeCount = android.badgeCount;
150
+ }
151
+
152
+ /**
153
+ * badgeIconType
154
+ */
155
+ if (objectHasProperty(android, 'badgeIconType') && !isUndefined(android.badgeIconType)) {
156
+ if (!Object.values(AndroidBadgeIconType).includes(android.badgeIconType)) {
157
+ throw new Error(
158
+ "'notification.android.badgeIconType' expected a valid AndroidBadgeIconType.",
159
+ );
160
+ }
161
+
162
+ out.badgeIconType = android.badgeIconType;
163
+ }
164
+
165
+ /**
166
+ * category
167
+ */
168
+ if (objectHasProperty(android, 'category') && !isUndefined(android.category)) {
169
+ if (!Object.values(AndroidCategory).includes(android.category)) {
170
+ throw new Error("'notification.android.category' expected a valid AndroidCategory.");
171
+ }
172
+
173
+ out.category = android.category;
174
+ }
175
+
176
+ /**
177
+ * channelId
178
+ */
179
+ if (!isString(android.channelId)) {
180
+ throw new Error("'notification.android.channelId' expected a string value.");
181
+ }
182
+
183
+ out.channelId = android.channelId;
184
+
185
+ /**
186
+ * color
187
+ */
188
+ if (objectHasProperty(android, 'color') && !isUndefined(android.color)) {
189
+ if (!isString(android.color)) {
190
+ throw new Error("'notification.android.color' expected a string value.");
191
+ }
192
+
193
+ if (!isValidColor(android.color)) {
194
+ throw new Error(
195
+ "'notification.android.color' invalid color. Expected an AndroidColor or hexadecimal string value.",
196
+ );
197
+ }
198
+
199
+ out.color = android.color;
200
+ }
201
+
202
+ /**
203
+ * colorized
204
+ */
205
+ if (objectHasProperty(android, 'colorized')) {
206
+ if (!isBoolean(android.colorized)) {
207
+ throw new Error("'notification.android.colorized' expected a boolean value.");
208
+ }
209
+
210
+ out.colorized = android.colorized;
211
+ }
212
+
213
+ /**
214
+ * chronometerDirection
215
+ */
216
+ if (objectHasProperty(android, 'chronometerDirection')) {
217
+ if (!isString(android.chronometerDirection)) {
218
+ throw new Error("'notification.android.chronometerDirection' expected a string value.");
219
+ }
220
+
221
+ if (android.chronometerDirection !== 'up' && android.chronometerDirection !== 'down') {
222
+ throw new Error(`'notification.android.chronometerDirection' must be one of "up" or "down".`);
223
+ }
224
+
225
+ out.chronometerDirection = android.chronometerDirection;
226
+ }
227
+
228
+ /**
229
+ * defaults
230
+ */
231
+ if (objectHasProperty(android, 'defaults') && !isUndefined(android.defaults)) {
232
+ if (!isArray(android.defaults)) {
233
+ throw new Error("'notification.android.defaults' expected an array.");
234
+ }
235
+
236
+ if (android.defaults.length === 0) {
237
+ throw new Error(
238
+ "'notification.android.defaults' expected an array containing AndroidDefaults.",
239
+ );
240
+ }
241
+
242
+ const defaults = Object.values(AndroidDefaults);
243
+
244
+ for (let i = 0; i < android.defaults.length; i++) {
245
+ if (!defaults.includes(android.defaults[i])) {
246
+ throw new Error(
247
+ "'notification.android.defaults' invalid array value, expected an AndroidDefaults value.",
248
+ );
249
+ }
250
+ }
251
+
252
+ out.defaults = android.defaults;
253
+ }
254
+
255
+ /**
256
+ * groupId
257
+ */
258
+ if (objectHasProperty(android, 'groupId')) {
259
+ if (!isString(android.groupId)) {
260
+ throw new Error("'notification.android.groupId' expected a string value.");
261
+ }
262
+
263
+ out.groupId = android.groupId;
264
+ }
265
+
266
+ /**
267
+ * groupAlertBehavior
268
+ */
269
+ if (
270
+ objectHasProperty(android, 'groupAlertBehavior') &&
271
+ !isUndefined(android.groupAlertBehavior)
272
+ ) {
273
+ if (!Object.values(AndroidGroupAlertBehavior).includes(android.groupAlertBehavior)) {
274
+ throw new Error(
275
+ "'notification.android.groupAlertBehavior' expected a valid AndroidGroupAlertBehavior.",
276
+ );
277
+ }
278
+
279
+ out.groupAlertBehavior = android.groupAlertBehavior;
280
+ }
281
+
282
+ /**
283
+ * groupSummary
284
+ */
285
+ if (objectHasProperty(android, 'groupSummary')) {
286
+ if (!isBoolean(android.groupSummary)) {
287
+ throw new Error("'notification.android.groupSummary' expected a boolean value.");
288
+ }
289
+
290
+ out.groupSummary = android.groupSummary;
291
+ }
292
+
293
+ if (objectHasProperty(android, 'inputHistory')) {
294
+ if (!isArrayOfStrings(android.inputHistory)) {
295
+ throw new Error("'notification.android.inputHistory' expected an array of string values.");
296
+ }
297
+
298
+ out.inputHistory = android.inputHistory;
299
+ }
300
+
301
+ /**
302
+ * largeIcon
303
+ */
304
+ if (objectHasProperty(android, 'largeIcon')) {
305
+ if (
306
+ (!isNumber(android.largeIcon) &&
307
+ !isString(android.largeIcon) &&
308
+ !isObject(android.largeIcon)) ||
309
+ (isString(android.largeIcon) && !android.largeIcon.length)
310
+ ) {
311
+ throw new Error(
312
+ "'notification.android.largeIcon' expected a React Native ImageResource value or a valid string URL.",
313
+ );
314
+ }
315
+
316
+ if (isNumber(android.largeIcon) || isObject(android.largeIcon)) {
317
+ const image = Image.resolveAssetSource(android.largeIcon);
318
+ out.largeIcon = image.uri;
319
+ } else {
320
+ out.largeIcon = android.largeIcon;
321
+ }
322
+
323
+ if (isBoolean(android.circularLargeIcon)) {
324
+ out.circularLargeIcon = android.circularLargeIcon;
325
+ }
326
+ }
327
+
328
+ /**
329
+ * lights
330
+ */
331
+ if (objectHasProperty(android, 'lights') && !isUndefined(android.lights)) {
332
+ if (!isArray(android.lights)) {
333
+ throw new Error(
334
+ "'notification.android.lights' expected an array value containing the color, on ms and off ms.",
335
+ );
336
+ }
337
+
338
+ const [valid, property] = isValidLightPattern(android.lights);
339
+
340
+ if (!valid) {
341
+ switch (property) {
342
+ case 'color':
343
+ throw new Error(
344
+ "'notification.android.lights' invalid color. Expected an AndroidColor or hexadecimal string value.",
345
+ );
346
+ case 'onMs':
347
+ throw new Error(
348
+ `'notification.android.lights' invalid "on" millisecond value, expected a number greater than 0.`,
349
+ );
350
+ case 'offMs':
351
+ throw new Error(
352
+ `'notification.android.lights' invalid "off" millisecond value, expected a number greater than 0.`,
353
+ );
354
+ }
355
+ }
356
+
357
+ out.lights = android.lights;
358
+ }
359
+
360
+ /**
361
+ * localOnly
362
+ */
363
+ if (objectHasProperty(android, 'localOnly')) {
364
+ if (!isBoolean(android.localOnly)) {
365
+ throw new Error("'notification.android.localOnly' expected a boolean value.");
366
+ }
367
+
368
+ out.localOnly = android.localOnly;
369
+ }
370
+
371
+ /**
372
+ * ongoing
373
+ */
374
+ if (objectHasProperty(android, 'ongoing')) {
375
+ if (!isBoolean(android.ongoing)) {
376
+ throw new Error("'notification.android.ongoing' expected a boolean value.");
377
+ }
378
+
379
+ out.ongoing = android.ongoing;
380
+ }
381
+
382
+ /**
383
+ * loopSound
384
+ */
385
+ if (objectHasProperty(android, 'loopSound')) {
386
+ if (!isBoolean(android.loopSound)) {
387
+ throw new Error("'notification.android.loopSound' expected a boolean value.");
388
+ }
389
+
390
+ out.loopSound = android.loopSound;
391
+ }
392
+
393
+ /**
394
+ * flags
395
+ */
396
+ if (objectHasProperty(android, 'flags') && !isUndefined(android.flags)) {
397
+ if (!isArray(android.flags)) {
398
+ throw new Error("'notification.android.flags' expected an array.");
399
+ }
400
+
401
+ if (android.flags.length === 0) {
402
+ throw new Error("'notification.android.flags' expected an array containing AndroidDefaults.");
403
+ }
404
+
405
+ const defaults = Object.values(AndroidFlags);
406
+
407
+ for (let i = 0; i < android.flags.length; i++) {
408
+ if (!defaults.includes(android.flags[i])) {
409
+ throw new Error(
410
+ "'notification.android.flags' invalid array value, expected an AndroidFlags value.",
411
+ );
412
+ }
413
+ }
414
+
415
+ out.flags = android.flags;
416
+ }
417
+
418
+ /**
419
+ * onlyAlertOnce
420
+ */
421
+ if (objectHasProperty(android, 'onlyAlertOnce')) {
422
+ if (!isBoolean(android.onlyAlertOnce)) {
423
+ throw new Error("'notification.android.onlyAlertOnce' expected a boolean value.");
424
+ }
425
+
426
+ out.onlyAlertOnce = android.onlyAlertOnce;
427
+ }
428
+
429
+ /**
430
+ * pressAction
431
+ */
432
+ if (objectHasProperty(android, 'pressAction') && !isUndefined(android.pressAction)) {
433
+ try {
434
+ out.pressAction = validateAndroidPressAction(android.pressAction);
435
+ } catch (e: any) {
436
+ throw new Error(`'notification.android.pressAction' ${e.message}`);
437
+ }
438
+ }
439
+
440
+ /**
441
+ * fullScreenAction
442
+ */
443
+ if (objectHasProperty(android, 'fullScreenAction') && !isUndefined(android.fullScreenAction)) {
444
+ try {
445
+ out.fullScreenAction = validateAndroidFullScreenAction(android.fullScreenAction);
446
+ } catch (e: any) {
447
+ throw new Error(`'notification.android.fullScreenAction' ${e.message}`);
448
+ }
449
+ }
450
+
451
+ /**
452
+ * importance
453
+ */
454
+ if (objectHasProperty(android, 'importance') && !isUndefined(android.importance)) {
455
+ if (!Object.values(AndroidImportance).includes(android.importance)) {
456
+ throw new Error("'notification.android.importance' expected a valid Importance.");
457
+ }
458
+
459
+ out.importance = android.importance;
460
+ }
461
+
462
+ /**
463
+ * progress
464
+ */
465
+ if (objectHasProperty(android, 'progress') && !isUndefined(android.progress)) {
466
+ if (!isObject(android.progress)) {
467
+ throw new Error("'notification.android.progress' expected an object value.");
468
+ }
469
+
470
+ const progress: AndroidProgress = {
471
+ indeterminate: false,
472
+ };
473
+
474
+ if (objectHasProperty(android.progress, 'indeterminate')) {
475
+ if (!isBoolean(android.progress.indeterminate)) {
476
+ throw new Error("'notification.android.progress.indeterminate' expected a boolean value.");
477
+ }
478
+
479
+ progress.indeterminate = android.progress.indeterminate;
480
+ }
481
+
482
+ if (!isUndefined(android.progress.max)) {
483
+ if (!isNumber(android.progress.max) || android.progress.max < 0) {
484
+ throw new Error("'notification.android.progress.max' expected a positive number value.");
485
+ }
486
+
487
+ if (isUndefined(android.progress.current)) {
488
+ throw new Error(
489
+ "'notification.android.progress.max' when providing a max value, you must also specify a current value.",
490
+ );
491
+ }
492
+
493
+ progress.max = android.progress.max;
494
+ }
495
+
496
+ if (!isUndefined(android.progress.current)) {
497
+ if (!isNumber(android.progress.current) || android.progress.current < 0) {
498
+ throw new Error(
499
+ "'notification.android.progress.current' expected a positive number value.",
500
+ );
501
+ }
502
+
503
+ if (isUndefined(android.progress.max)) {
504
+ throw new Error(
505
+ "'notification.android.progress.current' when providing a current value, you must also specify a `max` value.",
506
+ );
507
+ }
508
+
509
+ progress.current = android.progress.current;
510
+ }
511
+
512
+ // We have a max/current value
513
+ if (!isUndefined(progress.max) && !isUndefined(progress.current)) {
514
+ if (progress.current > progress.max) {
515
+ throw new Error(
516
+ "'notification.android.progress' the current value cannot be greater than the max value.",
517
+ );
518
+ }
519
+ }
520
+
521
+ out.progress = progress;
522
+ }
523
+
524
+ /**
525
+ * showTimestamp
526
+ */
527
+ if (objectHasProperty(android, 'showTimestamp')) {
528
+ if (!isBoolean(android.showTimestamp)) {
529
+ throw new Error("'notification.android.showTimestamp' expected a boolean value.");
530
+ }
531
+
532
+ out.showTimestamp = android.showTimestamp;
533
+ }
534
+
535
+ /**
536
+ * smallIcon
537
+ */
538
+ if (objectHasProperty(android, 'smallIcon') && !isUndefined(android.smallIcon)) {
539
+ if (!isString(android.smallIcon)) {
540
+ throw new Error("'notification.android.smallIcon' expected value to be a string.");
541
+ }
542
+
543
+ out.smallIcon = android.smallIcon;
544
+ }
545
+
546
+ /**
547
+ * smallIconLevel
548
+ */
549
+ if (objectHasProperty(android, 'smallIconLevel') && !isUndefined(android.smallIcon)) {
550
+ if (!isNumber(android.smallIconLevel)) {
551
+ throw new Error("'notification.android.smallIconLevel' expected value to be a number.");
552
+ }
553
+
554
+ out.smallIconLevel = android.smallIconLevel;
555
+ }
556
+
557
+ /**
558
+ * sortKey
559
+ */
560
+ if (objectHasProperty(android, 'sortKey')) {
561
+ if (!isString(android.sortKey)) {
562
+ throw new Error("'notification.android.sortKey' expected a string value.");
563
+ }
564
+
565
+ out.sortKey = android.sortKey;
566
+ }
567
+
568
+ /**
569
+ * style
570
+ */
571
+
572
+ if (objectHasProperty(android, 'style') && !isUndefined(android.style)) {
573
+ if (!isObject(android.style)) {
574
+ throw new Error("'notification.android.style' expected an object value.");
575
+ }
576
+
577
+ switch (android.style.type) {
578
+ case AndroidStyle.BIGPICTURE:
579
+ out.style = validateAndroidBigPictureStyle(android.style);
580
+ break;
581
+ case AndroidStyle.BIGTEXT:
582
+ out.style = validateAndroidBigTextStyle(android.style);
583
+ break;
584
+ case AndroidStyle.INBOX:
585
+ out.style = validateAndroidInboxStyle(android.style);
586
+ break;
587
+ case AndroidStyle.MESSAGING:
588
+ out.style = validateAndroidMessagingStyle(android.style);
589
+ break;
590
+ default:
591
+ throw new Error(
592
+ "'notification.android.style' style type must be one of AndroidStyle.BIGPICTURE, AndroidStyle.BIGTEXT, AndroidStyle.INBOX or AndroidStyle.MESSAGING.",
593
+ );
594
+ }
595
+ }
596
+
597
+ /**
598
+ * tag
599
+ */
600
+ if (objectHasProperty(android, 'tag') && android.tag !== undefined) {
601
+ if (!isString(android.tag)) {
602
+ throw new Error("'notification.android.tag' expected a string value.");
603
+ }
604
+
605
+ if (android.tag.includes('|')) {
606
+ throw new Error(`'notification.android.tag' tag cannot contain the "|" (pipe) character.`);
607
+ }
608
+
609
+ out.tag = android.tag;
610
+ }
611
+
612
+ /**
613
+ * ticker
614
+ */
615
+ if (objectHasProperty(android, 'ticker')) {
616
+ if (!isString(android.ticker)) {
617
+ throw new Error("'notification.android.ticker' expected a string value.");
618
+ }
619
+
620
+ out.ticker = android.ticker;
621
+ }
622
+
623
+ /**
624
+ * timeoutAfter
625
+ */
626
+ if (objectHasProperty(android, 'timeoutAfter') && android.timeoutAfter !== undefined) {
627
+ if (!isNumber(android.timeoutAfter)) {
628
+ throw new Error("'notification.android.timeoutAfter' expected a number value.");
629
+ }
630
+
631
+ if (!isValidTimestamp(android.timeoutAfter)) {
632
+ throw new Error("'notification.android.timeoutAfter' invalid millisecond timestamp.");
633
+ }
634
+
635
+ out.timeoutAfter = android.timeoutAfter;
636
+ }
637
+
638
+ /**
639
+ * showChronometer
640
+ */
641
+ if (objectHasProperty(android, 'showChronometer')) {
642
+ if (!isBoolean(android.showChronometer)) {
643
+ throw new Error("'notification.android.showChronometer' expected a boolean value.");
644
+ }
645
+
646
+ out.showChronometer = android.showChronometer;
647
+ }
648
+
649
+ /**
650
+ * vibrationPattern
651
+ */
652
+ if (objectHasProperty(android, 'vibrationPattern') && android.vibrationPattern !== undefined) {
653
+ if (!isArray(android.vibrationPattern) || !isValidVibratePattern(android.vibrationPattern)) {
654
+ throw new Error(
655
+ "'notification.android.vibrationPattern' expected an array containing an even number of positive values.",
656
+ );
657
+ }
658
+
659
+ out.vibrationPattern = android.vibrationPattern;
660
+ }
661
+
662
+ /**
663
+ * visibility
664
+ */
665
+ if (objectHasProperty(android, 'visibility') && android.visibility !== undefined) {
666
+ if (!Object.values(AndroidVisibility).includes(android.visibility)) {
667
+ throw new Error(
668
+ "'notification.android.visibility' expected a valid AndroidVisibility value.",
669
+ );
670
+ }
671
+
672
+ out.visibility = android.visibility;
673
+ }
674
+
675
+ /**
676
+ * timestamp
677
+ */
678
+ if (objectHasProperty(android, 'timestamp') && android.timestamp !== undefined) {
679
+ if (!isNumber(android.timestamp)) {
680
+ throw new Error("'notification.android.timestamp' expected a number value.");
681
+ }
682
+
683
+ if (!isValidTimestamp(android.timestamp)) {
684
+ throw new Error(
685
+ "'notification.android.timestamp' invalid millisecond timestamp, date must be a positive number",
686
+ );
687
+ }
688
+
689
+ out.timestamp = android.timestamp;
690
+ }
691
+
692
+ /**
693
+ * sound
694
+ */
695
+ if (objectHasProperty(android, 'sound') && android.sound !== undefined) {
696
+ if (!isString(android.sound)) {
697
+ throw new Error("'notification.sound' expected a valid sound string.");
698
+ }
699
+
700
+ out.sound = android.sound;
701
+ }
702
+
703
+ return out;
704
+ }