@dubsdotapp/expo 0.2.65 → 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/app.plugin.js +53 -38
- 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.mjs
CHANGED
|
@@ -21,7 +21,6 @@ if (typeof self === "undefined" && typeof globalThis !== "undefined") {
|
|
|
21
21
|
|
|
22
22
|
// src/constants.ts
|
|
23
23
|
var DEFAULT_BASE_URL = "https://dubs-server-prod-9c91d3f01199.herokuapp.com/api/developer/v1";
|
|
24
|
-
var DUBS_EXPO_PROJECT_ID = "aaca4fc9-64be-46b2-9be2-4175cb0f59a2";
|
|
25
24
|
var DEFAULT_RPC_URL = "https://api.mainnet-beta.solana.com";
|
|
26
25
|
var NETWORK_CONFIG = {
|
|
27
26
|
"mainnet-beta": {
|
|
@@ -2317,7 +2316,7 @@ function usePushNotifications() {
|
|
|
2317
2316
|
const { client, appName, pushEnabled } = useDubs();
|
|
2318
2317
|
const channelId = useMemo(() => appName.toLowerCase().replace(/[^a-z0-9-]/g, ""), [appName]);
|
|
2319
2318
|
const [hasPermission, setHasPermission] = useState14(false);
|
|
2320
|
-
const [
|
|
2319
|
+
const [pushToken, setPushToken] = useState14(null);
|
|
2321
2320
|
const [loading, setLoading] = useState14(false);
|
|
2322
2321
|
const [error, setError] = useState14(null);
|
|
2323
2322
|
const registering = useRef3(false);
|
|
@@ -2378,11 +2377,9 @@ function usePushNotifications() {
|
|
|
2378
2377
|
return false;
|
|
2379
2378
|
}
|
|
2380
2379
|
setHasPermission(true);
|
|
2381
|
-
const tokenResult = await Notifications.
|
|
2382
|
-
projectId: DUBS_EXPO_PROJECT_ID
|
|
2383
|
-
});
|
|
2380
|
+
const tokenResult = await Notifications.getDevicePushTokenAsync();
|
|
2384
2381
|
const token = tokenResult.data;
|
|
2385
|
-
|
|
2382
|
+
setPushToken(token);
|
|
2386
2383
|
await registerTokenWithServer(token);
|
|
2387
2384
|
setupAndroidChannels(Notifications);
|
|
2388
2385
|
setLoading(false);
|
|
@@ -2398,14 +2395,14 @@ function usePushNotifications() {
|
|
|
2398
2395
|
}
|
|
2399
2396
|
}, [getNotificationsModule, registerTokenWithServer, setupAndroidChannels]);
|
|
2400
2397
|
const unregister = useCallback13(async () => {
|
|
2401
|
-
if (!
|
|
2398
|
+
if (!pushToken) return;
|
|
2402
2399
|
try {
|
|
2403
|
-
await client.unregisterPushToken(
|
|
2404
|
-
|
|
2400
|
+
await client.unregisterPushToken(pushToken);
|
|
2401
|
+
setPushToken(null);
|
|
2405
2402
|
} catch (err) {
|
|
2406
2403
|
console.error("[usePushNotifications] Unregister error:", err);
|
|
2407
2404
|
}
|
|
2408
|
-
}, [client,
|
|
2405
|
+
}, [client, pushToken]);
|
|
2409
2406
|
const restoreIfGranted = useCallback13(async () => {
|
|
2410
2407
|
if (!pushEnabled) return;
|
|
2411
2408
|
try {
|
|
@@ -2413,12 +2410,10 @@ function usePushNotifications() {
|
|
|
2413
2410
|
if (!Notifications) return;
|
|
2414
2411
|
const { status } = await Notifications.getPermissionsAsync();
|
|
2415
2412
|
if (status !== "granted") return;
|
|
2416
|
-
const tokenResult = await Notifications.
|
|
2417
|
-
projectId: DUBS_EXPO_PROJECT_ID
|
|
2418
|
-
});
|
|
2413
|
+
const tokenResult = await Notifications.getDevicePushTokenAsync();
|
|
2419
2414
|
const token = tokenResult.data;
|
|
2420
2415
|
await registerTokenWithServer(token);
|
|
2421
|
-
|
|
2416
|
+
setPushToken(token);
|
|
2422
2417
|
setHasPermission(true);
|
|
2423
2418
|
setupAndroidChannels(Notifications);
|
|
2424
2419
|
} catch (err) {
|
|
@@ -2435,7 +2430,9 @@ function usePushNotifications() {
|
|
|
2435
2430
|
return {
|
|
2436
2431
|
enabled: pushEnabled,
|
|
2437
2432
|
hasPermission,
|
|
2438
|
-
|
|
2433
|
+
pushToken,
|
|
2434
|
+
expoPushToken: pushToken,
|
|
2435
|
+
// backwards compat
|
|
2439
2436
|
loading,
|
|
2440
2437
|
error,
|
|
2441
2438
|
register,
|