@dashx/react-native 1.3.1 → 1.3.2
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.
- package/.DS_Store +0 -0
- package/CHANGELOG.md +8 -0
- package/__tests__/index.test.js +37 -3
- package/android/.DS_Store +0 -0
- package/android/.gradle/.DS_Store +0 -0
- package/android/.kotlin/.DS_Store +0 -0
- package/android/build/.DS_Store +0 -0
- package/android/src/.DS_Store +0 -0
- package/index.d.ts +9 -1
- package/index.js +16 -2
- package/package.json +1 -1
package/.DS_Store
CHANGED
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@dashx/react-native` are documented in this file. Format loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), versions follow [SemVer](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [1.3.2] — 2026-04-22
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **`DashX.onPushNotificationReceived(callback)`** — new name for registering a foreground push listener. Same signature, same subscription shape; matches the `@dashx/browser` API so cross-platform apps using a Metro `.web.ts` wrapper can share the callsite.
|
|
9
|
+
|
|
10
|
+
### Deprecated
|
|
11
|
+
- **`DashX.onMessageReceived(callback)`** is now a deprecated alias of `onPushNotificationReceived` and logs a one-time `console.warn` on first call. The name leaked up from Android's Firebase `FirebaseMessagingService.onMessageReceived` override and was ambiguous in the DashX domain ("message" overloaded with `trackMessage` and in-app notifications). Scheduled for removal in the next major version.
|
|
12
|
+
|
|
5
13
|
## [1.3.1] — 2026-04-21
|
|
6
14
|
|
|
7
15
|
### Added
|
package/__tests__/index.test.js
CHANGED
|
@@ -310,20 +310,54 @@ describe('setLogLevel', () => {
|
|
|
310
310
|
});
|
|
311
311
|
});
|
|
312
312
|
|
|
313
|
-
// ---
|
|
313
|
+
// --- onPushNotificationReceived ---
|
|
314
314
|
|
|
315
|
-
describe('
|
|
315
|
+
describe('onPushNotificationReceived', () => {
|
|
316
316
|
it('throws if callback is not a function', () => {
|
|
317
|
-
expect(() => DashX.
|
|
317
|
+
expect(() => DashX.onPushNotificationReceived('not a function')).toThrow(
|
|
318
318
|
'callback must be a function'
|
|
319
319
|
);
|
|
320
320
|
});
|
|
321
321
|
|
|
322
322
|
it('registers a listener for messageReceived events', () => {
|
|
323
|
+
const callback = jest.fn();
|
|
324
|
+
const subscription = DashX.onPushNotificationReceived(callback);
|
|
325
|
+
expect(mockAddListener).toHaveBeenCalledWith('messageReceived', callback);
|
|
326
|
+
expect(subscription).toBeDefined();
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// --- onMessageReceived (deprecated alias) ---
|
|
331
|
+
|
|
332
|
+
describe('onMessageReceived (deprecated)', () => {
|
|
333
|
+
let warnSpy;
|
|
334
|
+
|
|
335
|
+
beforeEach(() => {
|
|
336
|
+
warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
afterEach(() => {
|
|
340
|
+
warnSpy.mockRestore();
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('registers a listener and emits a deprecation warning on first call', () => {
|
|
323
344
|
const callback = jest.fn();
|
|
324
345
|
const subscription = DashX.onMessageReceived(callback);
|
|
325
346
|
expect(mockAddListener).toHaveBeenCalledWith('messageReceived', callback);
|
|
326
347
|
expect(subscription).toBeDefined();
|
|
348
|
+
expect(warnSpy).toHaveBeenCalledWith(
|
|
349
|
+
expect.stringContaining('onMessageReceived is deprecated')
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('warns only once across repeated calls', () => {
|
|
354
|
+
warnSpy.mockClear();
|
|
355
|
+
DashX.onMessageReceived(jest.fn());
|
|
356
|
+
DashX.onMessageReceived(jest.fn());
|
|
357
|
+
DashX.onMessageReceived(jest.fn());
|
|
358
|
+
// The first call across the whole test run already consumed the one-shot
|
|
359
|
+
// warning (from the previous test). No new warnings should fire.
|
|
360
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
327
361
|
});
|
|
328
362
|
});
|
|
329
363
|
|
package/android/.DS_Store
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/src/.DS_Store
CHANGED
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -165,9 +165,17 @@ export interface DashXInstance {
|
|
|
165
165
|
setLogLevel(level: LogLevel): void;
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
|
-
* Register a listener for incoming push
|
|
168
|
+
* Register a listener for incoming push notifications.
|
|
169
169
|
* Returns a subscription that can be removed via `.remove()`.
|
|
170
170
|
*/
|
|
171
|
+
onPushNotificationReceived(
|
|
172
|
+
callback: (message: NotificationMessage) => void
|
|
173
|
+
): EmitterSubscription;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @deprecated Use `onPushNotificationReceived` instead.
|
|
177
|
+
* Will be removed in the next major version.
|
|
178
|
+
*/
|
|
171
179
|
onMessageReceived(
|
|
172
180
|
callback: (message: NotificationMessage) => void
|
|
173
181
|
): EmitterSubscription;
|
package/index.js
CHANGED
|
@@ -29,6 +29,8 @@ function getNativeDashX() {
|
|
|
29
29
|
return _nativeDashX;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
let _onMessageReceivedDeprecationWarned = false;
|
|
33
|
+
|
|
32
34
|
let _eventEmitter = null;
|
|
33
35
|
function getEventEmitter() {
|
|
34
36
|
if (!_eventEmitter) {
|
|
@@ -142,13 +144,25 @@ const DashX = {
|
|
|
142
144
|
return getNativeDashX().setLogLevel(level);
|
|
143
145
|
},
|
|
144
146
|
|
|
145
|
-
|
|
147
|
+
onPushNotificationReceived(callback) {
|
|
146
148
|
if (typeof callback !== 'function') {
|
|
147
|
-
throw new Error(
|
|
149
|
+
throw new Error(
|
|
150
|
+
'DashX.onPushNotificationReceived: callback must be a function'
|
|
151
|
+
);
|
|
148
152
|
}
|
|
149
153
|
return getEventEmitter().addListener('messageReceived', callback);
|
|
150
154
|
},
|
|
151
155
|
|
|
156
|
+
onMessageReceived(callback) {
|
|
157
|
+
if (!_onMessageReceivedDeprecationWarned) {
|
|
158
|
+
console.warn(
|
|
159
|
+
'DashX.onMessageReceived is deprecated and will be removed in the next major version. Use DashX.onPushNotificationReceived instead.'
|
|
160
|
+
);
|
|
161
|
+
_onMessageReceivedDeprecationWarned = true;
|
|
162
|
+
}
|
|
163
|
+
return DashX.onPushNotificationReceived(callback);
|
|
164
|
+
},
|
|
165
|
+
|
|
152
166
|
uploadAsset(filePath, resource, attribute) {
|
|
153
167
|
if (!filePath || typeof filePath !== 'string') {
|
|
154
168
|
throw new Error('DashX.uploadAsset: filePath must be a string');
|