@webority/mobile-core 0.0.28 → 0.0.29

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.
@@ -114,7 +114,7 @@ const toStringData = data => {
114
114
  }
115
115
  return out;
116
116
  };
117
- const responseData = response => {
117
+ const contentData = response => {
118
118
  const content = response.notification.request.content;
119
119
  if (content.data) {
120
120
  return toStringData(content.data);
@@ -128,6 +128,31 @@ const responseData = response => {
128
128
  }
129
129
  return {};
130
130
  };
131
+
132
+ /**
133
+ * expo-notifications fills iOS `content.data` only from a `body` object, but our
134
+ * servers send raw APNs with the app's keys at the top level beside `aps`.
135
+ */
136
+ const triggerData = response => {
137
+ const trigger = response.notification.request.trigger;
138
+ const extra = {
139
+ ...(trigger?.remoteMessage?.data ?? {})
140
+ };
141
+ for (const [key, value] of Object.entries(trigger?.payload ?? {})) {
142
+ // A `body` object is what expo already turned into content.data.
143
+ if (key === 'aps' || key === 'body' && typeof value === 'object') {
144
+ continue;
145
+ }
146
+ extra[key] = value;
147
+ }
148
+ return toStringData(extra);
149
+ };
150
+
151
+ /** The push's own data merged over the raw remote payload's keys, so content.data wins a conflict. */
152
+ const responseData = response => ({
153
+ ...triggerData(response),
154
+ ...contentData(response)
155
+ });
131
156
  const toPushAction = response => ({
132
157
  actionId: response.actionIdentifier,
133
158
  ...(response.userText ? {
@@ -109,7 +109,7 @@ const toStringData = data => {
109
109
  }
110
110
  return out;
111
111
  };
112
- const responseData = response => {
112
+ const contentData = response => {
113
113
  const content = response.notification.request.content;
114
114
  if (content.data) {
115
115
  return toStringData(content.data);
@@ -123,6 +123,31 @@ const responseData = response => {
123
123
  }
124
124
  return {};
125
125
  };
126
+
127
+ /**
128
+ * expo-notifications fills iOS `content.data` only from a `body` object, but our
129
+ * servers send raw APNs with the app's keys at the top level beside `aps`.
130
+ */
131
+ const triggerData = response => {
132
+ const trigger = response.notification.request.trigger;
133
+ const extra = {
134
+ ...(trigger?.remoteMessage?.data ?? {})
135
+ };
136
+ for (const [key, value] of Object.entries(trigger?.payload ?? {})) {
137
+ // A `body` object is what expo already turned into content.data.
138
+ if (key === 'aps' || key === 'body' && typeof value === 'object') {
139
+ continue;
140
+ }
141
+ extra[key] = value;
142
+ }
143
+ return toStringData(extra);
144
+ };
145
+
146
+ /** The push's own data merged over the raw remote payload's keys, so content.data wins a conflict. */
147
+ const responseData = response => ({
148
+ ...triggerData(response),
149
+ ...contentData(response)
150
+ });
126
151
  export const toPushAction = response => ({
127
152
  actionId: response.actionIdentifier,
128
153
  ...(response.userText ? {
@@ -86,6 +86,14 @@ interface NotificationResponseLike {
86
86
  data?: Record<string, unknown> | null;
87
87
  dataString?: string;
88
88
  };
89
+ /** A remote push carries its raw payload: APNs `userInfo` on iOS, the FCM message on Android. */
90
+ trigger?: {
91
+ type?: string;
92
+ payload?: Record<string, unknown> | null;
93
+ remoteMessage?: {
94
+ data?: Record<string, unknown> | null;
95
+ } | null;
96
+ } | null;
89
97
  };
90
98
  };
91
99
  }
@@ -86,6 +86,14 @@ interface NotificationResponseLike {
86
86
  data?: Record<string, unknown> | null;
87
87
  dataString?: string;
88
88
  };
89
+ /** A remote push carries its raw payload: APNs `userInfo` on iOS, the FCM message on Android. */
90
+ trigger?: {
91
+ type?: string;
92
+ payload?: Record<string, unknown> | null;
93
+ remoteMessage?: {
94
+ data?: Record<string, unknown> | null;
95
+ } | null;
96
+ } | null;
89
97
  };
90
98
  };
91
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-core",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "Platform layer for Webority React Native apps: HTTP clients, auth/token storage, config, logging, formatters, validators, network status, permissions, storage and version checks. No UI.",
5
5
  "keywords": [
6
6
  "react-native",