@dubsdotapp/expo 0.2.63 → 0.2.65
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 +12 -0
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +20 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
- package/src/hooks/usePushNotifications.ts +6 -1
- package/src/provider.tsx +14 -4
- package/src/ui/AuthGate.tsx +4 -4
- package/src/ui/UserProfileSheet.tsx +29 -27
package/app.plugin.js
CHANGED
|
@@ -61,6 +61,18 @@ function withDubsNotifications(config) {
|
|
|
61
61
|
'google-services.json',
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
+
// If the developer already has their own google-services.json, leave it alone.
|
|
65
|
+
// Their existing Firebase project will handle FCM just fine.
|
|
66
|
+
if (fs.existsSync(filePath)) {
|
|
67
|
+
return cfg;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Also check the project root (some devs place it there for app.json googleServicesFile)
|
|
71
|
+
const rootGoogleServices = path.join(projectRoot, 'google-services.json');
|
|
72
|
+
if (fs.existsSync(rootGoogleServices)) {
|
|
73
|
+
return cfg;
|
|
74
|
+
}
|
|
75
|
+
|
|
64
76
|
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
65
77
|
fs.writeFileSync(filePath, JSON.stringify(googleServices, null, 2));
|
|
66
78
|
|
package/dist/index.d.mts
CHANGED
|
@@ -601,6 +601,7 @@ interface DubsContextValue {
|
|
|
601
601
|
network: DubsNetwork;
|
|
602
602
|
disconnect: () => Promise<void>;
|
|
603
603
|
uiConfig: UiConfig;
|
|
604
|
+
pushEnabled: boolean;
|
|
604
605
|
}
|
|
605
606
|
interface DubsProviderProps {
|
|
606
607
|
apiKey: string;
|
|
@@ -629,8 +630,10 @@ interface DubsProviderProps {
|
|
|
629
630
|
redirectUri?: string;
|
|
630
631
|
/** App URL shown in Phantom's connect screen. */
|
|
631
632
|
appUrl?: string;
|
|
633
|
+
/** Enable Dubs push notifications. Default: true. Set false if your app manages its own Firebase/push. */
|
|
634
|
+
pushEnabled?: boolean;
|
|
632
635
|
}
|
|
633
|
-
declare function DubsProvider({ apiKey, children, appName, network, wallet: externalWallet, tokenStorage, baseUrl: baseUrlOverride, rpcUrl: rpcUrlOverride, renderConnectScreen, renderLoading, renderError, renderRegistration, managed, redirectUri, appUrl, }: DubsProviderProps): react_jsx_runtime.JSX.Element | null;
|
|
636
|
+
declare function DubsProvider({ apiKey, children, appName, network, wallet: externalWallet, tokenStorage, baseUrl: baseUrlOverride, rpcUrl: rpcUrlOverride, renderConnectScreen, renderLoading, renderError, renderRegistration, managed, redirectUri, appUrl, pushEnabled, }: DubsProviderProps): react_jsx_runtime.JSX.Element | null;
|
|
634
637
|
declare function useDubs(): DubsContextValue;
|
|
635
638
|
declare function useAppConfig(): UiConfig;
|
|
636
639
|
|
|
@@ -895,6 +898,8 @@ declare function useUFCFightCard(): QueryResult<UFCEvent[]>;
|
|
|
895
898
|
declare function useUFCFighterDetail(athleteId: string | null): QueryResult<UFCFighterDetail>;
|
|
896
899
|
|
|
897
900
|
interface PushNotificationStatus {
|
|
901
|
+
/** Whether push notifications are enabled in the SDK configuration */
|
|
902
|
+
enabled: boolean;
|
|
898
903
|
/** Whether notification permission has been granted */
|
|
899
904
|
hasPermission: boolean;
|
|
900
905
|
/** The Expo push token, if registered */
|
package/dist/index.d.ts
CHANGED
|
@@ -601,6 +601,7 @@ interface DubsContextValue {
|
|
|
601
601
|
network: DubsNetwork;
|
|
602
602
|
disconnect: () => Promise<void>;
|
|
603
603
|
uiConfig: UiConfig;
|
|
604
|
+
pushEnabled: boolean;
|
|
604
605
|
}
|
|
605
606
|
interface DubsProviderProps {
|
|
606
607
|
apiKey: string;
|
|
@@ -629,8 +630,10 @@ interface DubsProviderProps {
|
|
|
629
630
|
redirectUri?: string;
|
|
630
631
|
/** App URL shown in Phantom's connect screen. */
|
|
631
632
|
appUrl?: string;
|
|
633
|
+
/** Enable Dubs push notifications. Default: true. Set false if your app manages its own Firebase/push. */
|
|
634
|
+
pushEnabled?: boolean;
|
|
632
635
|
}
|
|
633
|
-
declare function DubsProvider({ apiKey, children, appName, network, wallet: externalWallet, tokenStorage, baseUrl: baseUrlOverride, rpcUrl: rpcUrlOverride, renderConnectScreen, renderLoading, renderError, renderRegistration, managed, redirectUri, appUrl, }: DubsProviderProps): react_jsx_runtime.JSX.Element | null;
|
|
636
|
+
declare function DubsProvider({ apiKey, children, appName, network, wallet: externalWallet, tokenStorage, baseUrl: baseUrlOverride, rpcUrl: rpcUrlOverride, renderConnectScreen, renderLoading, renderError, renderRegistration, managed, redirectUri, appUrl, pushEnabled, }: DubsProviderProps): react_jsx_runtime.JSX.Element | null;
|
|
634
637
|
declare function useDubs(): DubsContextValue;
|
|
635
638
|
declare function useAppConfig(): UiConfig;
|
|
636
639
|
|
|
@@ -895,6 +898,8 @@ declare function useUFCFightCard(): QueryResult<UFCEvent[]>;
|
|
|
895
898
|
declare function useUFCFighterDetail(athleteId: string | null): QueryResult<UFCFighterDetail>;
|
|
896
899
|
|
|
897
900
|
interface PushNotificationStatus {
|
|
901
|
+
/** Whether push notifications are enabled in the SDK configuration */
|
|
902
|
+
enabled: boolean;
|
|
898
903
|
/** Whether notification permission has been granted */
|
|
899
904
|
hasPermission: boolean;
|
|
900
905
|
/** The Expo push token, if registered */
|
package/dist/index.js
CHANGED
|
@@ -2368,7 +2368,7 @@ function useUFCFighterDetail(athleteId) {
|
|
|
2368
2368
|
var import_react16 = require("react");
|
|
2369
2369
|
var import_react_native6 = require("react-native");
|
|
2370
2370
|
function usePushNotifications() {
|
|
2371
|
-
const { client, appName } = useDubs();
|
|
2371
|
+
const { client, appName, pushEnabled } = useDubs();
|
|
2372
2372
|
const channelId = (0, import_react16.useMemo)(() => appName.toLowerCase().replace(/[^a-z0-9-]/g, ""), [appName]);
|
|
2373
2373
|
const [hasPermission, setHasPermission] = (0, import_react16.useState)(false);
|
|
2374
2374
|
const [expoPushToken, setExpoPushToken] = (0, import_react16.useState)(null);
|
|
@@ -2409,6 +2409,7 @@ function usePushNotifications() {
|
|
|
2409
2409
|
});
|
|
2410
2410
|
}, [client, getDeviceName]);
|
|
2411
2411
|
const register = (0, import_react16.useCallback)(async () => {
|
|
2412
|
+
if (!pushEnabled) return false;
|
|
2412
2413
|
if (registering.current) return false;
|
|
2413
2414
|
registering.current = true;
|
|
2414
2415
|
setLoading(true);
|
|
@@ -2460,6 +2461,7 @@ function usePushNotifications() {
|
|
|
2460
2461
|
}
|
|
2461
2462
|
}, [client, expoPushToken]);
|
|
2462
2463
|
const restoreIfGranted = (0, import_react16.useCallback)(async () => {
|
|
2464
|
+
if (!pushEnabled) return;
|
|
2463
2465
|
try {
|
|
2464
2466
|
const Notifications = getNotificationsModule();
|
|
2465
2467
|
if (!Notifications) return;
|
|
@@ -2485,6 +2487,7 @@ function usePushNotifications() {
|
|
|
2485
2487
|
restoreIfGranted();
|
|
2486
2488
|
}, []);
|
|
2487
2489
|
return {
|
|
2490
|
+
enabled: pushEnabled,
|
|
2488
2491
|
hasPermission,
|
|
2489
2492
|
expoPushToken,
|
|
2490
2493
|
loading,
|
|
@@ -2521,7 +2524,7 @@ function AuthGate({
|
|
|
2521
2524
|
appName = "Dubs",
|
|
2522
2525
|
accentColor
|
|
2523
2526
|
}) {
|
|
2524
|
-
const { client } = useDubs();
|
|
2527
|
+
const { client, pushEnabled } = useDubs();
|
|
2525
2528
|
const auth = useAuth();
|
|
2526
2529
|
const [phase, setPhase] = (0, import_react17.useState)("init");
|
|
2527
2530
|
const [registrationPhase, setRegistrationPhase] = (0, import_react17.useState)(false);
|
|
@@ -2558,10 +2561,10 @@ function AuthGate({
|
|
|
2558
2561
|
if (auth.status === "needsRegistration") setRegistrationPhase(true);
|
|
2559
2562
|
}, [auth.status]);
|
|
2560
2563
|
(0, import_react17.useEffect)(() => {
|
|
2561
|
-
if (auth.status === "authenticated" && registrationPhase && !isRestoredSession) {
|
|
2564
|
+
if (pushEnabled && auth.status === "authenticated" && registrationPhase && !isRestoredSession) {
|
|
2562
2565
|
setShowPushSetup(true);
|
|
2563
2566
|
}
|
|
2564
|
-
}, [auth.status, registrationPhase, isRestoredSession]);
|
|
2567
|
+
}, [pushEnabled, auth.status, registrationPhase, isRestoredSession]);
|
|
2565
2568
|
(0, import_react17.useEffect)(() => {
|
|
2566
2569
|
if (auth.token) onSaveToken(auth.token);
|
|
2567
2570
|
}, [auth.token]);
|
|
@@ -2592,7 +2595,7 @@ function AuthGate({
|
|
|
2592
2595
|
);
|
|
2593
2596
|
}
|
|
2594
2597
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(AuthContext.Provider, { value: auth, children: [
|
|
2595
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PushTokenRestorer, {}),
|
|
2598
|
+
pushEnabled && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PushTokenRestorer, {}),
|
|
2596
2599
|
children
|
|
2597
2600
|
] });
|
|
2598
2601
|
}
|
|
@@ -3127,7 +3130,8 @@ function DubsProvider({
|
|
|
3127
3130
|
renderRegistration,
|
|
3128
3131
|
managed = true,
|
|
3129
3132
|
redirectUri,
|
|
3130
|
-
appUrl
|
|
3133
|
+
appUrl,
|
|
3134
|
+
pushEnabled = true
|
|
3131
3135
|
}) {
|
|
3132
3136
|
const config = NETWORK_CONFIG[network];
|
|
3133
3137
|
const baseUrl = baseUrlOverride || config.baseUrl;
|
|
@@ -3167,6 +3171,7 @@ function DubsProvider({
|
|
|
3167
3171
|
renderRegistration,
|
|
3168
3172
|
accentColor: uiConfig.accentColor,
|
|
3169
3173
|
uiConfig,
|
|
3174
|
+
pushEnabled,
|
|
3170
3175
|
children
|
|
3171
3176
|
}
|
|
3172
3177
|
) });
|
|
@@ -3197,6 +3202,7 @@ function DubsProvider({
|
|
|
3197
3202
|
renderRegistration,
|
|
3198
3203
|
accentColor: uiConfig.accentColor,
|
|
3199
3204
|
uiConfig,
|
|
3205
|
+
pushEnabled,
|
|
3200
3206
|
children
|
|
3201
3207
|
}
|
|
3202
3208
|
)
|
|
@@ -3215,6 +3221,7 @@ function ManagedInner({
|
|
|
3215
3221
|
renderRegistration,
|
|
3216
3222
|
accentColor,
|
|
3217
3223
|
uiConfig,
|
|
3224
|
+
pushEnabled,
|
|
3218
3225
|
children
|
|
3219
3226
|
}) {
|
|
3220
3227
|
const managedDisconnect = useDisconnect();
|
|
@@ -3223,8 +3230,8 @@ function ManagedInner({
|
|
|
3223
3230
|
await managedDisconnect?.();
|
|
3224
3231
|
}, [client, managedDisconnect]);
|
|
3225
3232
|
const value = (0, import_react18.useMemo)(
|
|
3226
|
-
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig }),
|
|
3227
|
-
[client, wallet, connection, appName, network, disconnect, uiConfig]
|
|
3233
|
+
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled }),
|
|
3234
|
+
[client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled]
|
|
3228
3235
|
);
|
|
3229
3236
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DubsContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3230
3237
|
AuthGate,
|
|
@@ -3256,6 +3263,7 @@ function ExternalWalletProvider({
|
|
|
3256
3263
|
renderRegistration,
|
|
3257
3264
|
accentColor,
|
|
3258
3265
|
uiConfig,
|
|
3266
|
+
pushEnabled,
|
|
3259
3267
|
children
|
|
3260
3268
|
}) {
|
|
3261
3269
|
const disconnect = (0, import_react18.useCallback)(async () => {
|
|
@@ -3265,8 +3273,8 @@ function ExternalWalletProvider({
|
|
|
3265
3273
|
await wallet.disconnect?.();
|
|
3266
3274
|
}, [client, storage, wallet]);
|
|
3267
3275
|
const value = (0, import_react18.useMemo)(
|
|
3268
|
-
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig }),
|
|
3269
|
-
[client, wallet, connection, appName, network, disconnect, uiConfig]
|
|
3276
|
+
() => ({ client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled }),
|
|
3277
|
+
[client, wallet, connection, appName, network, disconnect, uiConfig, pushEnabled]
|
|
3270
3278
|
);
|
|
3271
3279
|
if (!managed) {
|
|
3272
3280
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(DubsContext.Provider, { value, children });
|
|
@@ -3700,7 +3708,7 @@ function UserProfileSheet({
|
|
|
3700
3708
|
)
|
|
3701
3709
|
] }),
|
|
3702
3710
|
error ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.View, { style: [styles4.errorBox, { backgroundColor: t.errorBg, borderColor: t.errorBorder }], children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { style: [styles4.errorText, { color: t.errorText }], children: error }) }) : null,
|
|
3703
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native10.View, { style: [styles4.notifRow, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
3711
|
+
push.enabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native10.View, { style: [styles4.notifRow, { backgroundColor: t.surface, borderColor: t.border }], children: [
|
|
3704
3712
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native10.View, { style: styles4.notifLeft, children: [
|
|
3705
3713
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { style: [styles4.notifLabel, { color: t.text }], children: "Push Notifications" }),
|
|
3706
3714
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
@@ -3725,7 +3733,7 @@ function UserProfileSheet({
|
|
|
3725
3733
|
}
|
|
3726
3734
|
)
|
|
3727
3735
|
] }),
|
|
3728
|
-
push.error ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.View, { style: [styles4.errorBox, { backgroundColor: t.errorBg, borderColor: t.errorBorder }], children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { style: [styles4.errorText, { color: t.errorText }], children: push.error.message }) }) : null,
|
|
3736
|
+
push.enabled && push.error ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.View, { style: [styles4.errorBox, { backgroundColor: t.errorBg, borderColor: t.errorBorder }], children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native10.Text, { style: [styles4.errorText, { color: t.errorText }], children: push.error.message }) }) : null,
|
|
3729
3737
|
onDisconnect ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3730
3738
|
import_react_native10.TouchableOpacity,
|
|
3731
3739
|
{
|