@dubsdotapp/expo 0.2.60 → 0.2.62
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.js +16 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +3 -0
- package/src/hooks/usePushNotifications.ts +20 -18
package/dist/index.js
CHANGED
|
@@ -95,6 +95,7 @@ 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";
|
|
98
99
|
var DEFAULT_RPC_URL = "https://api.mainnet-beta.solana.com";
|
|
99
100
|
var NETWORK_CONFIG = {
|
|
100
101
|
"mainnet-beta": {
|
|
@@ -2381,14 +2382,6 @@ function usePushNotifications() {
|
|
|
2381
2382
|
return null;
|
|
2382
2383
|
}
|
|
2383
2384
|
}, []);
|
|
2384
|
-
(0, import_react16.useEffect)(() => {
|
|
2385
|
-
const Notifications = getNotificationsModule();
|
|
2386
|
-
if (!Notifications) return;
|
|
2387
|
-
Notifications.getPermissionsAsync().then(({ status }) => {
|
|
2388
|
-
if (status === "granted") setHasPermission(true);
|
|
2389
|
-
}).catch(() => {
|
|
2390
|
-
});
|
|
2391
|
-
}, [getNotificationsModule]);
|
|
2392
2385
|
const getDeviceName = (0, import_react16.useCallback)(() => {
|
|
2393
2386
|
try {
|
|
2394
2387
|
const Device = require("expo-device");
|
|
@@ -2438,7 +2431,9 @@ function usePushNotifications() {
|
|
|
2438
2431
|
return false;
|
|
2439
2432
|
}
|
|
2440
2433
|
setHasPermission(true);
|
|
2441
|
-
const tokenResult = await Notifications.getExpoPushTokenAsync(
|
|
2434
|
+
const tokenResult = await Notifications.getExpoPushTokenAsync({
|
|
2435
|
+
projectId: DUBS_EXPO_PROJECT_ID
|
|
2436
|
+
});
|
|
2442
2437
|
const token = tokenResult.data;
|
|
2443
2438
|
setExpoPushToken(token);
|
|
2444
2439
|
await registerTokenWithServer(token);
|
|
@@ -2470,16 +2465,25 @@ function usePushNotifications() {
|
|
|
2470
2465
|
if (!Notifications) return;
|
|
2471
2466
|
const { status } = await Notifications.getPermissionsAsync();
|
|
2472
2467
|
if (status !== "granted") return;
|
|
2473
|
-
|
|
2474
|
-
|
|
2468
|
+
const tokenResult = await Notifications.getExpoPushTokenAsync({
|
|
2469
|
+
projectId: DUBS_EXPO_PROJECT_ID
|
|
2470
|
+
});
|
|
2475
2471
|
const token = tokenResult.data;
|
|
2476
|
-
setExpoPushToken(token);
|
|
2477
2472
|
await registerTokenWithServer(token);
|
|
2473
|
+
setExpoPushToken(token);
|
|
2474
|
+
setHasPermission(true);
|
|
2478
2475
|
setupAndroidChannels(Notifications);
|
|
2479
2476
|
} catch (err) {
|
|
2477
|
+
setHasPermission(false);
|
|
2480
2478
|
console.log("[usePushNotifications] Restore skipped:", err instanceof Error ? err.message : err);
|
|
2481
2479
|
}
|
|
2482
2480
|
}, [getNotificationsModule, registerTokenWithServer, setupAndroidChannels]);
|
|
2481
|
+
const didMount = (0, import_react16.useRef)(false);
|
|
2482
|
+
(0, import_react16.useEffect)(() => {
|
|
2483
|
+
if (didMount.current) return;
|
|
2484
|
+
didMount.current = true;
|
|
2485
|
+
restoreIfGranted();
|
|
2486
|
+
}, []);
|
|
2483
2487
|
return {
|
|
2484
2488
|
hasPermission,
|
|
2485
2489
|
expoPushToken,
|