diff --git a/src/app/features/settings/notifications/SystemNotification.tsx b/src/app/features/settings/notifications/SystemNotification.tsx
index eb21a4f..f2aeeea 100644
--- a/src/app/features/settings/notifications/SystemNotification.tsx
+++ b/src/app/features/settings/notifications/SystemNotification.tsx
@@ -171,6 +171,7 @@ type PushStatus = {
distributor: string;
endpoint: string;
distributors: string[];
+ lastFailure: string;
};
/** Android-only section showing UnifiedPush registration status and controls. */
@@ -194,6 +195,7 @@ function AndroidPushNotifications() {
distributor: s.distributor || '',
endpoint: s.endpoint || '',
distributors,
+ lastFailure: s.lastFailure || '',
}
: undefined
);
@@ -211,7 +213,7 @@ function AndroidPushNotifications() {
await refresh();
if (!result.success) {
setLastError(
- 'Could not register a push distributor. Install ntfy (with UnifiedPush enabled), then try Reset again.'
+ 'Selected distributor but did not get a push endpoint. In ntfy: enable UnifiedPush, allow unrestricted battery, then try Reset again.'
);
}
}, [refresh])
@@ -244,6 +246,13 @@ function AndroidPushNotifications() {
);
}
+ if (status.lastFailure) {
+ return (
+
+ {`Registration failed (${status.lastFailure}). Tap Reset and pick ntfy again.`}
+
+ );
+ }
if (status.distributors.length === 0) {
return (
diff --git a/src/app/utils/backgroundSync.ts b/src/app/utils/backgroundSync.ts
index 280f71e..afd18c8 100644
--- a/src/app/utils/backgroundSync.ts
+++ b/src/app/utils/backgroundSync.ts
@@ -15,6 +15,7 @@ type UnifiedPushStatus = {
registered: boolean;
distributor: string;
distributors: string[] | string;
+ lastFailure?: string;
};
type UnifiedPushEndpointEvent = {
@@ -545,15 +546,20 @@ export const requestResetPushRegistration = async (): Promise<{ success: boolean
if (!result?.success) return { success: false };
// Endpoint arrives asynchronously from the distributor after register().
- for (let i = 0; i < 20; i += 1) {
+ for (let i = 0; i < 40; i += 1) {
await new Promise((resolve) => setTimeout(resolve, 250));
const status = await getBackgroundSyncStatus();
if (status?.registered && status.endpoint) {
return { success: true };
}
+ if (status?.lastFailure) {
+ console.warn('[BackgroundSync] Registration failed while waiting:', status.lastFailure);
+ return { success: false };
+ }
}
- return { success: true };
+ console.warn('[BackgroundSync] Distributor selected but no endpoint received in time');
+ return { success: false };
} catch (err) {
console.error('[BackgroundSync] requestDistributorSetup failed:', err);
return { success: false };