react-native-notify-kit 10.4.9 → 10.6.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 (62) hide show
  1. package/README.md +60 -2
  2. package/android/src/main/java/app/notifee/core/Notifee.java +9 -0
  3. package/android/src/main/java/app/notifee/core/ReceiverService.java +41 -4
  4. package/android/src/main/java/app/notifee/core/model/NotificationAndroidStyleModel.java +63 -34
  5. package/android/src/main/java/app/notifee/core/utility/FullScreenIntentUtils.java +53 -0
  6. package/android/src/main/java/app/notifee/core/utility/ResourceUtils.java +15 -1
  7. package/android/src/test/java/app/notifee/core/ReceiverServicePendingIntentIdentityTest.java +303 -0
  8. package/android/src/test/java/app/notifee/core/model/NotificationAndroidStyleModelPersonFailureTest.java +337 -0
  9. package/android/src/test/java/app/notifee/core/model/TimestampTriggerModelTest.java +27 -70
  10. package/android/src/test/java/app/notifee/core/utility/FullScreenIntentUtilsTest.java +83 -0
  11. package/android/src/test/java/app/notifee/core/utility/ResourceUtilsBitmapOwnershipTest.java +145 -0
  12. package/dist/NotifeeApiModule.js +4 -0
  13. package/dist/NotifeeApiModule.js.map +1 -1
  14. package/dist/types/Notification.d.ts +2 -1
  15. package/dist/types/Notification.js.map +1 -1
  16. package/dist/types/NotificationAndroid.d.ts +17 -5
  17. package/dist/types/NotificationAndroid.js.map +1 -1
  18. package/dist/validators/validateAndroidNotification.js +4 -0
  19. package/dist/validators/validateAndroidNotification.js.map +1 -1
  20. package/dist/version.d.ts +1 -1
  21. package/dist/version.js +1 -1
  22. package/ios/NotifeeCore/NotifeeCoreExtensionHelper.m +285 -91
  23. package/ios/NotifeeCore/NotifeeCoreUtil.m +159 -13
  24. package/jest-mock.js +1 -0
  25. package/package.json +2 -2
  26. package/server/README.md +6 -4
  27. package/server/dist/android.d.ts +8 -0
  28. package/server/dist/android.d.ts.map +1 -0
  29. package/server/dist/android.js +20 -0
  30. package/server/dist/android.js.map +1 -0
  31. package/server/dist/buildPayload.d.ts +3 -0
  32. package/server/dist/buildPayload.d.ts.map +1 -0
  33. package/server/dist/buildPayload.js +82 -0
  34. package/server/dist/buildPayload.js.map +1 -0
  35. package/server/dist/index.d.ts +6 -0
  36. package/server/dist/index.d.ts.map +1 -0
  37. package/server/dist/index.js +12 -0
  38. package/server/dist/index.js.map +1 -0
  39. package/server/dist/ios.d.ts +11 -0
  40. package/server/dist/ios.d.ts.map +1 -0
  41. package/server/dist/ios.js +61 -0
  42. package/server/dist/ios.js.map +1 -0
  43. package/server/dist/serialize.d.ts +11 -0
  44. package/server/dist/serialize.d.ts.map +1 -0
  45. package/server/dist/serialize.js +32 -0
  46. package/server/dist/serialize.js.map +1 -0
  47. package/server/dist/types.d.ts +2 -0
  48. package/server/dist/types.d.ts.map +1 -0
  49. package/server/dist/types.js +3 -0
  50. package/server/dist/types.js.map +1 -0
  51. package/server/dist/validation.d.ts +3 -0
  52. package/server/dist/validation.d.ts.map +1 -0
  53. package/server/dist/validation.js +115 -0
  54. package/server/dist/validation.js.map +1 -0
  55. package/server/src/android.ts +4 -4
  56. package/server/src/validation.ts +20 -0
  57. package/src/NotifeeApiModule.ts +4 -0
  58. package/src/internal/fcmContract.d.ts +10 -8
  59. package/src/types/Notification.ts +2 -1
  60. package/src/types/NotificationAndroid.ts +18 -5
  61. package/src/validators/validateAndroidNotification.ts +7 -0
  62. package/src/version.ts +1 -1
@@ -19,6 +19,7 @@
19
19
  #include <CoreGraphics/CGGeometry.h>
20
20
  #import <Intents/INIntentIdentifiers.h>
21
21
  #import <UIKit/UIKit.h>
22
+ #import <dispatch/dispatch.h>
22
23
  #include <limits.h>
23
24
  #include <math.h>
24
25
  #import "NotifeeCore+NSURLSession.h"
@@ -55,9 +56,30 @@ static NSInteger const kNotifeeRollingTargetPerTrigger = 32;
55
56
  defaultMissingCreatedAt:(BOOL)defaultMissingCreatedAt;
56
57
  + (nullable id)rollingJSONObjectFromObject:(nullable id)object;
57
58
  + (NSNumber *)rollingCurrentTimestampMs;
59
+ + (INSendMessageIntent *)generateSenderIntentForCommunicationNotification:
60
+ (NSDictionary *)communicationInfo
61
+ deadline:(dispatch_time_t)deadline;
62
+ + (dispatch_time_t)communicationAvatarCurrentTime;
63
+
64
+ @end
65
+
66
+ @interface NotifeeCoreCommunicationAvatarDownloadResult : NSObject
67
+
68
+ @property(nonatomic, strong, nullable) NSURL *URL;
69
+ @property(nonatomic, assign) dispatch_time_t completionTime;
70
+ @property(nonatomic, assign, getter=isCompleted) BOOL completed;
71
+ @property(nonatomic, assign, getter=isUsable) BOOL usable;
58
72
 
59
73
  @end
60
74
 
75
+ @implementation NotifeeCoreCommunicationAvatarDownloadResult
76
+ @end
77
+
78
+ static BOOL NotifeeCoreIsRemoteURLString(id value) {
79
+ return [value isKindOfClass:NSString.class] &&
80
+ ([value hasPrefix:@"http://"] || [value hasPrefix:@"https://"]);
81
+ }
82
+
61
83
  @implementation NotifeeCoreUtil
62
84
 
63
85
  + (NSNumber *)numberForUNNotificationSetting:(UNNotificationSetting)setting {
@@ -223,20 +245,26 @@ static NSInteger const kNotifeeRollingTargetPerTrigger = 32;
223
245
  * @return NSURL
224
246
  */
225
247
  + (NSURL *)getURLFromString:(NSString *)urlString {
226
- NSURL *url;
248
+ if (![urlString isKindOfClass:NSString.class] || [urlString length] == 0) {
249
+ return nil;
250
+ }
251
+
252
+ NSURL *parsedURL = [NSURL URLWithString:urlString];
253
+
254
+ if ([parsedURL isFileURL]) {
255
+ return parsedURL;
256
+ }
227
257
 
228
- if ([urlString hasPrefix:@"http://"] || [urlString hasPrefix:@"https://"]) {
258
+ if (NotifeeCoreIsRemoteURLString(urlString)) {
229
259
  // handle remote url by attempting to download attachement synchronously
230
- url = [self downloadMediaSynchronously:urlString];
260
+ return [self downloadMediaSynchronously:urlString];
231
261
  } else if ([urlString hasPrefix:@"/"]) {
232
262
  // handle absolute file path
233
- url = [NSURL fileURLWithPath:urlString];
234
- } else {
235
- // try to resolve local resource
236
- url = [[NSBundle mainBundle] URLForResource:urlString withExtension:nil];
263
+ return [NSURL fileURLWithPath:urlString];
237
264
  }
238
265
 
239
- return url;
266
+ // try to resolve local resource
267
+ return [[NSBundle mainBundle] URLForResource:urlString withExtension:nil];
240
268
  }
241
269
 
242
270
  /*
@@ -1251,16 +1279,135 @@ static NSInteger const kNotifeeRollingTargetPerTrigger = 32;
1251
1279
 
1252
1280
  + (INSendMessageIntent *)generateSenderIntentForCommunicationNotification:
1253
1281
  (NSDictionary *)communicationInfo {
1282
+ return [self generateSenderIntentForCommunicationNotification:communicationInfo
1283
+ deadline:DISPATCH_TIME_FOREVER];
1284
+ }
1285
+
1286
+ + (dispatch_time_t)communicationAvatarCurrentTime {
1287
+ return dispatch_time(DISPATCH_TIME_NOW, 0);
1288
+ }
1289
+
1290
+ + (INSendMessageIntent *)
1291
+ generateSenderIntentForCommunicationNotification:(NSDictionary *)communicationInfo
1292
+ deadline:(dispatch_time_t)deadline {
1254
1293
  if (@available(iOS 15.0, *)) {
1255
1294
  NSDictionary *sender = communicationInfo[@"sender"];
1256
1295
  INPersonHandle *senderPersonHandle =
1257
1296
  [[INPersonHandle alloc] initWithValue:sender[@"id"] type:INPersonHandleTypeUnknown];
1258
1297
 
1298
+ id senderAvatarValue = sender[@"avatar"];
1299
+ id groupAvatarValue = communicationInfo[@"groupAvatar"];
1300
+ BOOL sharesAvatar = [senderAvatarValue isKindOfClass:NSString.class] &&
1301
+ [groupAvatarValue isKindOfClass:NSString.class] &&
1302
+ [senderAvatarValue isEqualToString:groupAvatarValue];
1303
+
1304
+ NSURL *senderAvatarURL = nil;
1305
+ NSURL *groupAvatarURL = nil;
1306
+
1307
+ if (deadline == DISPATCH_TIME_FOREVER) {
1308
+ __block NSURL *downloadedGroupAvatarURL = nil;
1309
+ dispatch_group_t groupAvatarDownload = nil;
1310
+
1311
+ if (!sharesAvatar && NotifeeCoreIsRemoteURLString(groupAvatarValue)) {
1312
+ groupAvatarDownload = dispatch_group_create();
1313
+ dispatch_group_async(groupAvatarDownload, dispatch_get_global_queue(QOS_CLASS_UTILITY, 0),
1314
+ ^{
1315
+ downloadedGroupAvatarURL = [self getURLFromString:groupAvatarValue];
1316
+ });
1317
+ }
1318
+
1319
+ if (senderAvatarValue != nil) {
1320
+ senderAvatarURL = [self getURLFromString:senderAvatarValue];
1321
+ }
1322
+
1323
+ if (sharesAvatar) {
1324
+ groupAvatarURL = senderAvatarURL;
1325
+ } else if (groupAvatarDownload != nil) {
1326
+ if (dispatch_group_wait(groupAvatarDownload, deadline) == 0) {
1327
+ groupAvatarURL = downloadedGroupAvatarURL;
1328
+ }
1329
+ } else if (groupAvatarValue != nil) {
1330
+ groupAvatarURL = [self getURLFromString:groupAvatarValue];
1331
+ }
1332
+ } else {
1333
+ BOOL senderAvatarIsRemote = NotifeeCoreIsRemoteURLString(senderAvatarValue);
1334
+ BOOL groupAvatarIsRemote = NotifeeCoreIsRemoteURLString(groupAvatarValue);
1335
+ BOOL remoteDownloadsMayStart = [self communicationAvatarCurrentTime] < deadline;
1336
+ NotifeeCoreCommunicationAvatarDownloadResult *senderAvatarResult = nil;
1337
+ NotifeeCoreCommunicationAvatarDownloadResult *groupAvatarResult = nil;
1338
+ dispatch_group_t senderAvatarDownload = nil;
1339
+ dispatch_group_t groupAvatarDownload = nil;
1340
+
1341
+ dispatch_group_t (^startRemoteDownload)(NSString *,
1342
+ NotifeeCoreCommunicationAvatarDownloadResult *) =
1343
+ ^dispatch_group_t(NSString *avatarValue,
1344
+ NotifeeCoreCommunicationAvatarDownloadResult *result) {
1345
+ dispatch_group_t download = dispatch_group_create();
1346
+ dispatch_group_async(download, dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^{
1347
+ dispatch_time_t downloadStartTime = [self communicationAvatarCurrentTime];
1348
+ if (downloadStartTime >= deadline) {
1349
+ @synchronized(result) {
1350
+ result.completionTime = downloadStartTime;
1351
+ result.completed = YES;
1352
+ result.usable = NO;
1353
+ }
1354
+ return;
1355
+ }
1356
+
1357
+ NSURL *downloadedURL = [self getURLFromString:avatarValue];
1358
+ dispatch_time_t completionTime = [self communicationAvatarCurrentTime];
1359
+ @synchronized(result) {
1360
+ result.URL = downloadedURL;
1361
+ result.completionTime = completionTime;
1362
+ result.completed = YES;
1363
+ result.usable = completionTime < deadline;
1364
+ }
1365
+ });
1366
+ return download;
1367
+ };
1368
+
1369
+ NSURL * (^waitForRemoteDownload)(dispatch_group_t,
1370
+ NotifeeCoreCommunicationAvatarDownloadResult *) =
1371
+ ^NSURL *(dispatch_group_t download,
1372
+ NotifeeCoreCommunicationAvatarDownloadResult *result) {
1373
+ dispatch_group_wait(download, deadline);
1374
+ @synchronized(result) {
1375
+ if (result.isCompleted && result.isUsable) {
1376
+ return result.URL;
1377
+ }
1378
+ return nil;
1379
+ }
1380
+ };
1381
+
1382
+ if (remoteDownloadsMayStart && senderAvatarIsRemote) {
1383
+ senderAvatarResult = [NotifeeCoreCommunicationAvatarDownloadResult new];
1384
+ senderAvatarDownload = startRemoteDownload(senderAvatarValue, senderAvatarResult);
1385
+ }
1386
+
1387
+ if (remoteDownloadsMayStart && !sharesAvatar && groupAvatarIsRemote) {
1388
+ groupAvatarResult = [NotifeeCoreCommunicationAvatarDownloadResult new];
1389
+ groupAvatarDownload = startRemoteDownload(groupAvatarValue, groupAvatarResult);
1390
+ }
1391
+
1392
+ if (senderAvatarDownload != nil) {
1393
+ senderAvatarURL = waitForRemoteDownload(senderAvatarDownload, senderAvatarResult);
1394
+ } else if (!senderAvatarIsRemote && senderAvatarValue != nil) {
1395
+ senderAvatarURL = [self getURLFromString:senderAvatarValue];
1396
+ }
1397
+
1398
+ if (sharesAvatar) {
1399
+ groupAvatarURL = senderAvatarURL;
1400
+ } else if (groupAvatarDownload != nil) {
1401
+ groupAvatarURL = waitForRemoteDownload(groupAvatarDownload, groupAvatarResult);
1402
+ } else if (!groupAvatarIsRemote && groupAvatarValue != nil) {
1403
+ groupAvatarURL = [self getURLFromString:groupAvatarValue];
1404
+ }
1405
+ }
1406
+
1259
1407
  // Parse sender's avatar
1260
1408
  INImage *avatar = nil;
1261
- if (sender[@"avatar"] != nil) {
1262
- NSURL *url = [self getURLFromString:sender[@"avatar"]];
1263
- avatar = [INImage imageWithURL:url];
1409
+ if (senderAvatarURL != nil) {
1410
+ avatar = [INImage imageWithURL:senderAvatarURL];
1264
1411
  }
1265
1412
 
1266
1413
  INPerson *senderPerson = [[INPerson alloc] initWithPersonHandle:senderPersonHandle
@@ -1305,8 +1452,7 @@ static NSInteger const kNotifeeRollingTargetPerTrigger = 32;
1305
1452
  sender:senderPerson
1306
1453
  attachments:nil];
1307
1454
 
1308
- if (communicationInfo[@"groupAvatar"] != nil) {
1309
- NSURL *groupAvatarURL = [[NSURL alloc] initWithString:communicationInfo[@"groupAvatar"]];
1455
+ if (groupAvatarURL != nil) {
1310
1456
  INImage *groupAvatarImage = [INImage imageWithURL:groupAvatarURL];
1311
1457
 
1312
1458
  [intent setImage:groupAvatarImage forParameterNamed:@"speakableGroupName"];
package/jest-mock.js CHANGED
@@ -83,6 +83,7 @@ export const testNotificationSettings = {
83
83
  authorizationStatus: Notification.AuthorizationStatus.AUTHORIZED,
84
84
  android: {
85
85
  alarm: NotificationAndroid.AndroidNotificationSetting.ENABLED,
86
+ fullScreenIntent: NotificationAndroid.AndroidNotificationSetting.ENABLED,
86
87
  },
87
88
  ios: {
88
89
  alert: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-notify-kit",
3
- "version": "10.4.9",
3
+ "version": "10.6.0",
4
4
  "author": "Marco Crupi",
5
5
  "description": "Maintained Notifee-compatible React Native notifications library for Android, iOS, FCM Mode, rich notifications, foreground services, and Expo CNG development builds.",
6
6
  "main": "dist/index.js",
@@ -32,7 +32,7 @@
32
32
  "build:watch": "tsc --watch",
33
33
  "test:server": "jest --config jest.config.server.js",
34
34
  "prepare": "yarn run build",
35
- "prepack": "cd ../.. && bash build_ios_core.sh && bash scripts/verify-ios-core-generation.sh && bash scripts/prepack-cli.sh",
35
+ "prepack": "yarn run build:server && cd ../.. && bash build_ios_core.sh && bash scripts/verify-ios-core-generation.sh && bash scripts/prepack-cli.sh",
36
36
  "postpack": "rm -rf cli",
37
37
  "prepublishOnly": "cd ../.. && yarn run build:core",
38
38
  "format:android": "google-java-format --replace -i $(find . -type f -name \"*.java\" ! -path \"*/node_modules/*\" ! -path \"*/generated/*\")",
package/server/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # react-native-notify-kit/server
2
2
 
3
- Server-side FCM HTTP v1 payload builder for [`react-native-notify-kit`](../README.md). Runs in Node.js 22+ (backends, Firebase Cloud Functions). **Zero runtime dependencies.**
3
+ Server-side Firebase Admin-compatible FCM message builder for [`react-native-notify-kit`](../README.md). Runs in Node.js 22+ (backends, Firebase Cloud Functions). **Zero runtime dependencies.**
4
4
 
5
5
  Use it to construct payloads that the client-side `handleFcmMessage` handler can consume — Android receives data-only messages routed through `setBackgroundMessageHandler`, iOS receives alert-style APNs payloads that a Notification Service Extension reads from the `notifee_options` key.
6
6
 
@@ -42,21 +42,23 @@ const message = buildNotifyKitPayload({
42
42
  await admin.messaging().send(message);
43
43
  ```
44
44
 
45
+ `options.ttl` is expressed in seconds. Pass the message directly to Firebase Admin without an adapter or a manual unit conversion.
46
+
45
47
  ## API
46
48
 
47
49
  ### `buildNotifyKitPayload(input: NotifyKitPayloadInput): NotifyKitPayloadOutput`
48
50
 
49
- Main entry point. Validates the input, serializes the `notifee_options` blob, and returns a complete FCM HTTP v1 `Message` object with an `android` half (data-only) and an `apns` half (alert + `mutable-content: 1`). Routing field (`token` / `topic` / `condition`) is passed through from the input; exactly one must be provided.
51
+ Main entry point. Validates the input, serializes the `notifee_options` blob, and returns a Firebase Admin-compatible message with an `android` half (data-only) and an `apns` half (alert + `mutable-content: 1`). Firebase Admin serializes the message to the FCM HTTP v1 request format. Routing field (`token` / `topic` / `condition`) is passed through from the input; exactly one must be provided.
50
52
 
51
53
  The returned object also carries a **non-enumerable** `sizeBytes` field — accessible for your own diagnostics, invisible to `JSON.stringify` so it never leaks to FCM.
52
54
 
53
55
  ### `buildAndroidPayload(input, context): NotifyKitAndroidOutput`
54
56
 
55
- Builds the Android half only: `{ priority, collapse_key?, ttl? }`. Use when composing a custom `Message` (rare).
57
+ Builds the Android half only: `{ priority: 'high' | 'normal', collapseKey?: string, ttl?: number }`. The public `options.ttl` input is expressed in seconds; the Firebase Admin-compatible `android.ttl` output is expressed in milliseconds. Use when composing a custom message (rare).
56
58
 
57
59
  ### `buildIosApnsPayload(input, context): NotifyKitApnsOutput`
58
60
 
59
- Builds the iOS APNs half only: `{ headers, payload }` with the `aps` object, `notifee_options` blob, and optional `notifee_data`. Use when composing a custom `Message`.
61
+ Builds the iOS APNs half only: `{ headers, payload }` with the `aps` object, `notifee_options` blob, and optional `notifee_data`. When TTL is set, `apns-expiration` is an absolute UNIX epoch timestamp in seconds. Use when composing a custom message.
60
62
 
61
63
  ### `serializeNotifeeOptions(input): string`
62
64
 
@@ -0,0 +1,8 @@
1
+ import type { NotifyKitAndroidOutput, NotifyKitPayloadInput } from './types';
2
+ type BuildAndroidContext = {
3
+ collapseKey?: string;
4
+ ttlSeconds?: number;
5
+ };
6
+ export declare function buildAndroidPayload(input: NotifyKitPayloadInput, context: BuildAndroidContext): NotifyKitAndroidOutput;
7
+ export {};
8
+ //# sourceMappingURL=android.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"android.d.ts","sourceRoot":"","sources":["../src/android.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAoB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE/F,KAAK,mBAAmB,GAAG;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAMF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,qBAAqB,EAC5B,OAAO,EAAE,mBAAmB,GAC3B,sBAAsB,CAYxB"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildAndroidPayload = buildAndroidPayload;
4
+ function toAndroidPriority(priority) {
5
+ return priority === 'normal' ? 'normal' : 'high';
6
+ }
7
+ function buildAndroidPayload(input, context) {
8
+ const options = input.options ?? {};
9
+ const output = {
10
+ priority: toAndroidPriority(options.androidPriority),
11
+ };
12
+ if (context.collapseKey !== undefined) {
13
+ output.collapseKey = context.collapseKey;
14
+ }
15
+ if (context.ttlSeconds !== undefined) {
16
+ output.ttl = context.ttlSeconds * 1000;
17
+ }
18
+ return output;
19
+ }
20
+ //# sourceMappingURL=android.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"android.js","sourceRoot":"","sources":["../src/android.ts"],"names":[],"mappings":";;AAWA,kDAeC;AAnBD,SAAS,iBAAiB,CAAC,QAA6C;IACtE,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;AACnD,CAAC;AAED,SAAgB,mBAAmB,CACjC,KAA4B,EAC5B,OAA4B;IAE5B,MAAM,OAAO,GAAqB,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;IACtD,MAAM,MAAM,GAA2B;QACrC,QAAQ,EAAE,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAAC;KACrD,CAAC;IACF,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAC3C,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IACzC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { NotifyKitPayloadInput, NotifyKitPayloadOutput } from './types';
2
+ export declare function buildNotifyKitPayload(input: NotifyKitPayloadInput): NotifyKitPayloadOutput;
3
+ //# sourceMappingURL=buildPayload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildPayload.d.ts","sourceRoot":"","sources":["../src/buildPayload.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAM7E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,qBAAqB,GAAG,sBAAsB,CAiF1F"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildNotifyKitPayload = buildNotifyKitPayload;
4
+ const android_1 = require("./android");
5
+ const ios_1 = require("./ios");
6
+ const serialize_1 = require("./serialize");
7
+ const validation_1 = require("./validation");
8
+ const SIZE_WARN_THRESHOLD_BYTES = 3500;
9
+ const PREFIX = '[react-native-notify-kit/server]';
10
+ function buildNotifyKitPayload(input) {
11
+ (0, validation_1.validateInput)(input);
12
+ const { notification } = input;
13
+ const options = input.options ?? {};
14
+ const collapseKey = options.collapseKey ?? notification.id ?? undefined;
15
+ let expiration;
16
+ if (options.ttl !== undefined) {
17
+ expiration = String(Math.floor(Date.now() / 1000) + options.ttl);
18
+ }
19
+ const notifeeOptions = (0, serialize_1.serializeNotifeeOptions)({
20
+ title: notification.title,
21
+ body: notification.body,
22
+ ...(notification.android !== undefined ? { android: notification.android } : {}),
23
+ ...(notification.ios !== undefined ? { ios: notification.ios } : {}),
24
+ });
25
+ const notifeeData = (0, serialize_1.serializeData)(notification.data);
26
+ // Android path: top-level `data` carries `notification.data` keys verbatim
27
+ // plus `notifee_options`. `notifee_data` is intentionally NOT duplicated here —
28
+ // the client can read the original keys directly from `data`. iOS NSE still
29
+ // receives `notifee_data` inside `apns.payload` because APNs does not expose
30
+ // arbitrary top-level keys to the extension.
31
+ const data = {
32
+ ...(notification.data ?? {}),
33
+ notifee_options: notifeeOptions,
34
+ };
35
+ const android = (0, android_1.buildAndroidPayload)(input, {
36
+ ...(collapseKey !== undefined ? { collapseKey } : {}),
37
+ ...(options.ttl !== undefined ? { ttlSeconds: options.ttl } : {}),
38
+ });
39
+ const apns = (0, ios_1.buildIosApnsPayload)(input, {
40
+ notifeeOptions,
41
+ ...(notifeeData !== undefined ? { notifeeData } : {}),
42
+ ...(collapseKey !== undefined ? { collapseKey } : {}),
43
+ ...(expiration !== undefined ? { expiration } : {}),
44
+ });
45
+ // Build the FCM-bound payload first (without sizeBytes — that's metadata for
46
+ // the caller, not part of the wire format).
47
+ const fcmPayload = {
48
+ data,
49
+ android,
50
+ apns,
51
+ };
52
+ if (input.token !== undefined) {
53
+ fcmPayload.token = input.token;
54
+ }
55
+ else if (input.topic !== undefined) {
56
+ fcmPayload.topic = input.topic;
57
+ }
58
+ else if (input.condition !== undefined) {
59
+ fcmPayload.condition = input.condition;
60
+ }
61
+ // FCM's 4 KB limit is measured in UTF-8 bytes, not JS code units, so emoji
62
+ // and non-ASCII characters consume more than one byte each. Deviation from
63
+ // the spec's literal `JSON.stringify(output).length` to avoid underestimating
64
+ // payload size under such characters. sizeBytes measures the FCM-relevant
65
+ // fields only (excludes the sizeBytes field itself).
66
+ const sizeBytes = Buffer.byteLength(JSON.stringify(fcmPayload), 'utf8');
67
+ if (sizeBytes > SIZE_WARN_THRESHOLD_BYTES) {
68
+ console.warn(`${PREFIX} Payload size ${sizeBytes} bytes approaches FCM 4KB limit. Consider reducing notifee_options.`);
69
+ }
70
+ // Attach sizeBytes as non-enumerable so JSON.stringify and object spread
71
+ // never include it — consumers can safely pass the output directly to
72
+ // admin.messaging().send() without stripping metadata fields.
73
+ const output = { ...fcmPayload };
74
+ Object.defineProperty(output, 'sizeBytes', {
75
+ value: sizeBytes,
76
+ enumerable: false,
77
+ writable: false,
78
+ configurable: false,
79
+ });
80
+ return output;
81
+ }
82
+ //# sourceMappingURL=buildPayload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildPayload.js","sourceRoot":"","sources":["../src/buildPayload.ts"],"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C,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;IACrE,CAAC;IAED,2EAA2E;IAC3E,2EAA2E;IAC3E,8EAA8E;IAC9E,0EAA0E;IAC1E,qDAAqD;IACrD,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;IACxE,IAAI,SAAS,GAAG,yBAAyB,EAAE,CAAC;QAC1C,OAAO,CAAC,IAAI,CACV,GAAG,MAAM,iBAAiB,SAAS,qEAAqE,CACzG,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,sEAAsE;IACtE,8DAA8D;IAC9D,MAAM,MAAM,GAAG,EAAE,GAAG,UAAU,EAA4B,CAAC;IAC3D,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE;QACzC,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;QACf,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { buildNotifyKitPayload } from './buildPayload';
2
+ export { buildIosApnsPayload } from './ios';
3
+ export { buildAndroidPayload } from './android';
4
+ export { serializeNotifeeOptions } from './serialize';
5
+ export type { NotifyKitPayloadInput, NotifyKitPayloadOutput, NotifyKitNotification, NotifyKitOptions, NotifyKitAndroidConfig, NotifyKitIosConfig, } from './types';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeNotifeeOptions = exports.buildAndroidPayload = exports.buildIosApnsPayload = exports.buildNotifyKitPayload = void 0;
4
+ var buildPayload_1 = require("./buildPayload");
5
+ Object.defineProperty(exports, "buildNotifyKitPayload", { enumerable: true, get: function () { return buildPayload_1.buildNotifyKitPayload; } });
6
+ var ios_1 = require("./ios");
7
+ Object.defineProperty(exports, "buildIosApnsPayload", { enumerable: true, get: function () { return ios_1.buildIosApnsPayload; } });
8
+ var android_1 = require("./android");
9
+ Object.defineProperty(exports, "buildAndroidPayload", { enumerable: true, get: function () { return android_1.buildAndroidPayload; } });
10
+ var serialize_1 = require("./serialize");
11
+ Object.defineProperty(exports, "serializeNotifeeOptions", { enumerable: true, get: function () { return serialize_1.serializeNotifeeOptions; } });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+CAAuD;AAA9C,qHAAA,qBAAqB,OAAA;AAC9B,6BAA4C;AAAnC,0GAAA,mBAAmB,OAAA;AAC5B,qCAAgD;AAAvC,8GAAA,mBAAmB,OAAA;AAC5B,yCAAsD;AAA7C,oHAAA,uBAAuB,OAAA"}
@@ -0,0 +1,11 @@
1
+ import type { ApnsInterruptionLevel, NotifyKitApnsOutput, NotifyKitIosInterruptionLevel, NotifyKitPayloadInput } from './types';
2
+ export declare function toApnsInterruptionLevel(level: NotifyKitIosInterruptionLevel): ApnsInterruptionLevel;
3
+ type BuildIosContext = {
4
+ notifeeOptions: string;
5
+ notifeeData?: string;
6
+ collapseKey?: string;
7
+ expiration?: string;
8
+ };
9
+ export declare function buildIosApnsPayload(input: NotifyKitPayloadInput, context: BuildIosContext): NotifyKitApnsOutput;
10
+ export {};
11
+ //# sourceMappingURL=ios.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../src/ios.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EAGrB,mBAAmB,EACnB,6BAA6B,EAG7B,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAWjB,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,6BAA6B,GACnC,qBAAqB,CAQvB;AAED,KAAK,eAAe,GAAG;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,qBAAqB,EAC5B,OAAO,EAAE,eAAe,GACvB,mBAAmB,CA6CrB"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toApnsInterruptionLevel = toApnsInterruptionLevel;
4
+ exports.buildIosApnsPayload = buildIosApnsPayload;
5
+ const INTERRUPTION_LEVEL_MAP = {
6
+ passive: 'passive',
7
+ active: 'active',
8
+ timeSensitive: 'time-sensitive',
9
+ critical: 'critical',
10
+ };
11
+ const PREFIX = '[react-native-notify-kit/server]';
12
+ function toApnsInterruptionLevel(level) {
13
+ const mapped = INTERRUPTION_LEVEL_MAP[level];
14
+ if (mapped === undefined) {
15
+ throw new Error(`${PREFIX} Validation: invalid interruptionLevel '${String(level)}'. Expected one of: passive, active, timeSensitive, critical`);
16
+ }
17
+ return mapped;
18
+ }
19
+ function buildIosApnsPayload(input, context) {
20
+ const notification = input.notification;
21
+ const options = input.options ?? {};
22
+ const ios = notification.ios;
23
+ const headers = {
24
+ 'apns-push-type': 'alert',
25
+ 'apns-priority': '10',
26
+ };
27
+ if (context.collapseKey !== undefined) {
28
+ headers['apns-collapse-id'] = context.collapseKey;
29
+ }
30
+ if (context.expiration !== undefined) {
31
+ headers['apns-expiration'] = context.expiration;
32
+ }
33
+ const aps = {
34
+ alert: { title: notification.title, body: notification.body },
35
+ 'mutable-content': 1,
36
+ };
37
+ if (ios?.sound !== undefined) {
38
+ aps.sound = ios.sound;
39
+ }
40
+ if (ios?.categoryId !== undefined) {
41
+ aps.category = ios.categoryId;
42
+ }
43
+ if (ios?.threadId !== undefined) {
44
+ aps['thread-id'] = ios.threadId;
45
+ }
46
+ if (ios?.interruptionLevel !== undefined) {
47
+ aps['interruption-level'] = toApnsInterruptionLevel(ios.interruptionLevel);
48
+ }
49
+ if (options.iosBadgeCount !== undefined) {
50
+ aps.badge = options.iosBadgeCount;
51
+ }
52
+ const payload = {
53
+ aps,
54
+ notifee_options: context.notifeeOptions,
55
+ };
56
+ if (context.notifeeData !== undefined) {
57
+ payload.notifee_data = context.notifeeData;
58
+ }
59
+ return { headers, payload };
60
+ }
61
+ //# sourceMappingURL=ios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ios.js","sourceRoot":"","sources":["../src/ios.ts"],"names":[],"mappings":";;AAoBA,0DAUC;AASD,kDAgDC;AA5ED,MAAM,sBAAsB,GAAiE;IAC3F,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,aAAa,EAAE,gBAAgB;IAC/B,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAM,MAAM,GAAG,kCAAkC,CAAC;AAElD,SAAgB,uBAAuB,CACrC,KAAoC;IAEpC,MAAM,MAAM,GAAG,sBAAsB,CAAC,KAAsC,CAAC,CAAC;IAC9E,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,2CAA2C,MAAM,CAAC,KAAK,CAAC,8DAA8D,CAChI,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAS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;IACD,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;QACxC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC;IACpC,CAAC;IAED,MAAM,OAAO,GAAmC;QAC9C,GAAG;QACH,eAAe,EAAE,OAAO,CAAC,cAAc;KACxC,CAAC;IACF,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAC7C,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { NotifyKitAndroidConfig, NotifyKitIosConfig } from './types';
2
+ type SerializeInput = {
3
+ title: string;
4
+ body: string;
5
+ android?: NotifyKitAndroidConfig;
6
+ ios?: NotifyKitIosConfig;
7
+ };
8
+ export declare function serializeNotifeeOptions(input: SerializeInput): string;
9
+ export declare function serializeData(data?: Record<string, string>): string | undefined;
10
+ export {};
11
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../src/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAA4B,MAAM,SAAS,CAAC;AAEpG,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,GAAG,CAAC,EAAE,kBAAkB,CAAC;CAC1B,CAAC;AAIF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAgBrE;AAED,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CAS/E"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeNotifeeOptions = serializeNotifeeOptions;
4
+ exports.serializeData = serializeData;
5
+ const PREFIX = '[react-native-notify-kit/server]';
6
+ function serializeNotifeeOptions(input) {
7
+ const payload = { _v: 1, title: input.title, body: input.body };
8
+ if (input.android !== undefined) {
9
+ payload.android = input.android;
10
+ }
11
+ if (input.ios !== undefined) {
12
+ payload.ios = input.ios;
13
+ }
14
+ try {
15
+ return JSON.stringify(payload);
16
+ }
17
+ catch (e) {
18
+ const detail = e instanceof Error ? `: ${e.message}` : `: ${String(e)}`;
19
+ throw new Error(`${PREFIX} Serialization: notifee_options contains circular references or non-serializable values. Check for circular object references in android/ios config${detail}`);
20
+ }
21
+ }
22
+ function serializeData(data) {
23
+ if (!data) {
24
+ return undefined;
25
+ }
26
+ const keys = Object.keys(data);
27
+ if (keys.length === 0) {
28
+ return undefined;
29
+ }
30
+ return JSON.stringify(data);
31
+ }
32
+ //# sourceMappingURL=serialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.js","sourceRoot":"","sources":["../src/serialize.ts"],"names":[],"mappings":";;AAWA,0DAgBC;AAED,sCASC;AA7BD,MAAM,MAAM,GAAG,kCAAkC,CAAC;AAElD,SAAgB,uBAAuB,CAAC,KAAqB;IAC3D,MAAM,OAAO,GAA6B,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IAC1F,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAClC,CAAC;IACD,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;IAC1B,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,CAAU,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,sJAAsJ,MAAM,EAAE,CACxK,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAgB,aAAa,CAAC,IAA6B;IACzD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type { NotifyKitPressAction, NotifyKitAndroidAction, NotifyKitAndroidStyle, NotifyKitAndroidConfig, NotifyKitIosAttachment, NotifyKitIosInterruptionLevel, NotifyKitIosConfig, NotifyKitNotification, NotifyKitOptions, NotifyKitPayloadInput, ApnsInterruptionLevel, NotifyKitAndroidOutput, NotifyKitApnsAps, NotifyKitApnsHeaders, NotifyKitApnsPayload, NotifyKitApnsOutput, NotifyKitPayloadOutput, SerializedNotifeeOptions, } from '../../src/internal/fcmContract';
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,6BAA6B,EAC7B,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { NotifyKitPayloadInput } from './types';
2
+ export declare function validateInput(input: NotifyKitPayloadInput): void;
3
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAarD,wBAAgB,aAAa,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,CA4IhE"}