@dubsdotapp/expo 0.2.66 → 0.2.67
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/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +12 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +0 -3
- package/src/hooks/usePushNotifications.ts +18 -17
package/dist/index.d.mts
CHANGED
|
@@ -902,7 +902,11 @@ interface PushNotificationStatus {
|
|
|
902
902
|
enabled: boolean;
|
|
903
903
|
/** Whether notification permission has been granted */
|
|
904
904
|
hasPermission: boolean;
|
|
905
|
-
/** The
|
|
905
|
+
/** The push token (native FCM/APNs), if registered */
|
|
906
|
+
pushToken: string | null;
|
|
907
|
+
/**
|
|
908
|
+
* @deprecated Use pushToken instead. Kept for backwards compatibility.
|
|
909
|
+
*/
|
|
906
910
|
expoPushToken: string | null;
|
|
907
911
|
/** Whether a registration operation is in progress */
|
|
908
912
|
loading: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -902,7 +902,11 @@ interface PushNotificationStatus {
|
|
|
902
902
|
enabled: boolean;
|
|
903
903
|
/** Whether notification permission has been granted */
|
|
904
904
|
hasPermission: boolean;
|
|
905
|
-
/** The
|
|
905
|
+
/** The push token (native FCM/APNs), if registered */
|
|
906
|
+
pushToken: string | null;
|
|
907
|
+
/**
|
|
908
|
+
* @deprecated Use pushToken instead. Kept for backwards compatibility.
|
|
909
|
+
*/
|
|
906
910
|
expoPushToken: string | null;
|
|
907
911
|
/** Whether a registration operation is in progress */
|
|
908
912
|
loading: boolean;
|
package/dist/index.js
CHANGED
|
@@ -95,7 +95,6 @@ if (typeof self === "undefined" && typeof globalThis !== "undefined") {
|
|
|
95
95
|
|
|
96
96
|
// src/constants.ts
|
|
97
97
|
var DEFAULT_BASE_URL = "https://dubs-server-prod-9c91d3f01199.herokuapp.com/api/developer/v1";
|
|
98
|
-
var DUBS_EXPO_PROJECT_ID = "aaca4fc9-64be-46b2-9be2-4175cb0f59a2";
|
|
99
98
|
var DEFAULT_RPC_URL = "https://api.mainnet-beta.solana.com";
|
|
100
99
|
var NETWORK_CONFIG = {
|
|
101
100
|
"mainnet-beta": {
|
|
@@ -2371,7 +2370,7 @@ function usePushNotifications() {
|
|
|
2371
2370
|
const { client, appName, pushEnabled } = useDubs();
|
|
2372
2371
|
const channelId = (0, import_react16.useMemo)(() => appName.toLowerCase().replace(/[^a-z0-9-]/g, ""), [appName]);
|
|
2373
2372
|
const [hasPermission, setHasPermission] = (0, import_react16.useState)(false);
|
|
2374
|
-
const [
|
|
2373
|
+
const [pushToken, setPushToken] = (0, import_react16.useState)(null);
|
|
2375
2374
|
const [loading, setLoading] = (0, import_react16.useState)(false);
|
|
2376
2375
|
const [error, setError] = (0, import_react16.useState)(null);
|
|
2377
2376
|
const registering = (0, import_react16.useRef)(false);
|
|
@@ -2432,11 +2431,9 @@ function usePushNotifications() {
|
|
|
2432
2431
|
return false;
|
|
2433
2432
|
}
|
|
2434
2433
|
setHasPermission(true);
|
|
2435
|
-
const tokenResult = await Notifications.
|
|
2436
|
-
projectId: DUBS_EXPO_PROJECT_ID
|
|
2437
|
-
});
|
|
2434
|
+
const tokenResult = await Notifications.getDevicePushTokenAsync();
|
|
2438
2435
|
const token = tokenResult.data;
|
|
2439
|
-
|
|
2436
|
+
setPushToken(token);
|
|
2440
2437
|
await registerTokenWithServer(token);
|
|
2441
2438
|
setupAndroidChannels(Notifications);
|
|
2442
2439
|
setLoading(false);
|
|
@@ -2452,14 +2449,14 @@ function usePushNotifications() {
|
|
|
2452
2449
|
}
|
|
2453
2450
|
}, [getNotificationsModule, registerTokenWithServer, setupAndroidChannels]);
|
|
2454
2451
|
const unregister = (0, import_react16.useCallback)(async () => {
|
|
2455
|
-
if (!
|
|
2452
|
+
if (!pushToken) return;
|
|
2456
2453
|
try {
|
|
2457
|
-
await client.unregisterPushToken(
|
|
2458
|
-
|
|
2454
|
+
await client.unregisterPushToken(pushToken);
|
|
2455
|
+
setPushToken(null);
|
|
2459
2456
|
} catch (err) {
|
|
2460
2457
|
console.error("[usePushNotifications] Unregister error:", err);
|
|
2461
2458
|
}
|
|
2462
|
-
}, [client,
|
|
2459
|
+
}, [client, pushToken]);
|
|
2463
2460
|
const restoreIfGranted = (0, import_react16.useCallback)(async () => {
|
|
2464
2461
|
if (!pushEnabled) return;
|
|
2465
2462
|
try {
|
|
@@ -2467,12 +2464,10 @@ function usePushNotifications() {
|
|
|
2467
2464
|
if (!Notifications) return;
|
|
2468
2465
|
const { status } = await Notifications.getPermissionsAsync();
|
|
2469
2466
|
if (status !== "granted") return;
|
|
2470
|
-
const tokenResult = await Notifications.
|
|
2471
|
-
projectId: DUBS_EXPO_PROJECT_ID
|
|
2472
|
-
});
|
|
2467
|
+
const tokenResult = await Notifications.getDevicePushTokenAsync();
|
|
2473
2468
|
const token = tokenResult.data;
|
|
2474
2469
|
await registerTokenWithServer(token);
|
|
2475
|
-
|
|
2470
|
+
setPushToken(token);
|
|
2476
2471
|
setHasPermission(true);
|
|
2477
2472
|
setupAndroidChannels(Notifications);
|
|
2478
2473
|
} catch (err) {
|
|
@@ -2489,7 +2484,9 @@ function usePushNotifications() {
|
|
|
2489
2484
|
return {
|
|
2490
2485
|
enabled: pushEnabled,
|
|
2491
2486
|
hasPermission,
|
|
2492
|
-
|
|
2487
|
+
pushToken,
|
|
2488
|
+
expoPushToken: pushToken,
|
|
2489
|
+
// backwards compat
|
|
2493
2490
|
loading,
|
|
2494
2491
|
error,
|
|
2495
2492
|
register,
|