@dubsdotapp/expo 0.2.60 → 0.2.61
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 +9 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/usePushNotifications.ts +13 -16
package/dist/index.js
CHANGED
|
@@ -2381,14 +2381,6 @@ function usePushNotifications() {
|
|
|
2381
2381
|
return null;
|
|
2382
2382
|
}
|
|
2383
2383
|
}, []);
|
|
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
2384
|
const getDeviceName = (0, import_react16.useCallback)(() => {
|
|
2393
2385
|
try {
|
|
2394
2386
|
const Device = require("expo-device");
|
|
@@ -2470,16 +2462,23 @@ function usePushNotifications() {
|
|
|
2470
2462
|
if (!Notifications) return;
|
|
2471
2463
|
const { status } = await Notifications.getPermissionsAsync();
|
|
2472
2464
|
if (status !== "granted") return;
|
|
2473
|
-
setHasPermission(true);
|
|
2474
2465
|
const tokenResult = await Notifications.getExpoPushTokenAsync();
|
|
2475
2466
|
const token = tokenResult.data;
|
|
2476
|
-
setExpoPushToken(token);
|
|
2477
2467
|
await registerTokenWithServer(token);
|
|
2468
|
+
setExpoPushToken(token);
|
|
2469
|
+
setHasPermission(true);
|
|
2478
2470
|
setupAndroidChannels(Notifications);
|
|
2479
2471
|
} catch (err) {
|
|
2472
|
+
setHasPermission(false);
|
|
2480
2473
|
console.log("[usePushNotifications] Restore skipped:", err instanceof Error ? err.message : err);
|
|
2481
2474
|
}
|
|
2482
2475
|
}, [getNotificationsModule, registerTokenWithServer, setupAndroidChannels]);
|
|
2476
|
+
const didMount = (0, import_react16.useRef)(false);
|
|
2477
|
+
(0, import_react16.useEffect)(() => {
|
|
2478
|
+
if (didMount.current) return;
|
|
2479
|
+
didMount.current = true;
|
|
2480
|
+
restoreIfGranted();
|
|
2481
|
+
}, []);
|
|
2483
2482
|
return {
|
|
2484
2483
|
hasPermission,
|
|
2485
2484
|
expoPushToken,
|