Compare commits
2 Commits
e460dbd34e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ea7642f0bb | |||
| 0fb3da20b9 |
@@ -171,6 +171,8 @@ type PushStatus = {
|
|||||||
distributor: string;
|
distributor: string;
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
distributors: string[];
|
distributors: string[];
|
||||||
|
lastFailure: string;
|
||||||
|
autoStartBlocked: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Android-only section showing UnifiedPush registration status and controls. */
|
/** Android-only section showing UnifiedPush registration status and controls. */
|
||||||
@@ -194,6 +196,8 @@ function AndroidPushNotifications() {
|
|||||||
distributor: s.distributor || '',
|
distributor: s.distributor || '',
|
||||||
endpoint: s.endpoint || '',
|
endpoint: s.endpoint || '',
|
||||||
distributors,
|
distributors,
|
||||||
|
lastFailure: s.lastFailure || '',
|
||||||
|
autoStartBlocked: Boolean(s.autoStartBlocked),
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
);
|
);
|
||||||
@@ -211,7 +215,7 @@ function AndroidPushNotifications() {
|
|||||||
await refresh();
|
await refresh();
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
setLastError(
|
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])
|
}, [refresh])
|
||||||
@@ -244,6 +248,20 @@ function AndroidPushNotifications() {
|
|||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (status.lastFailure === 'AUTO_START_BLOCKED' || status.autoStartBlocked) {
|
||||||
|
return (
|
||||||
|
<Text as="span" style={{ color: color.Critical.Main }} size="T200">
|
||||||
|
Phone is blocking auto-start for Paarrot. Open App Boot / Auto-start settings, allow Paarrot (and ntfy), then tap Reset.
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (status.lastFailure) {
|
||||||
|
return (
|
||||||
|
<Text as="span" style={{ color: color.Critical.Main }} size="T200">
|
||||||
|
{`Registration failed (${status.lastFailure}). Tap Reset and pick ntfy again.`}
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
}
|
||||||
if (status.distributors.length === 0) {
|
if (status.distributors.length === 0) {
|
||||||
return (
|
return (
|
||||||
<Text as="span" style={{ color: color.Critical.Main }} size="T200">
|
<Text as="span" style={{ color: color.Critical.Main }} size="T200">
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ type UnifiedPushStatus = {
|
|||||||
registered: boolean;
|
registered: boolean;
|
||||||
distributor: string;
|
distributor: string;
|
||||||
distributors: string[] | string;
|
distributors: string[] | string;
|
||||||
|
lastFailure?: string;
|
||||||
|
/** OEM App Boot / AUTO_START is blocking distributor broadcasts (e.g. TCL). */
|
||||||
|
autoStartBlocked?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type UnifiedPushEndpointEvent = {
|
type UnifiedPushEndpointEvent = {
|
||||||
@@ -545,15 +548,20 @@ export const requestResetPushRegistration = async (): Promise<{ success: boolean
|
|||||||
if (!result?.success) return { success: false };
|
if (!result?.success) return { success: false };
|
||||||
|
|
||||||
// Endpoint arrives asynchronously from the distributor after register().
|
// 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));
|
await new Promise((resolve) => setTimeout(resolve, 250));
|
||||||
const status = await getBackgroundSyncStatus();
|
const status = await getBackgroundSyncStatus();
|
||||||
if (status?.registered && status.endpoint) {
|
if (status?.registered && status.endpoint) {
|
||||||
return { success: true };
|
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) {
|
} catch (err) {
|
||||||
console.error('[BackgroundSync] requestDistributorSetup failed:', err);
|
console.error('[BackgroundSync] requestDistributorSetup failed:', err);
|
||||||
return { success: false };
|
return { success: false };
|
||||||
|
|||||||
Reference in New Issue
Block a user