diff --git a/src/app/push/adapters/android.ts b/src/app/push/adapters/android.ts index 365ec363..3a4a08cd 100644 --- a/src/app/push/adapters/android.ts +++ b/src/app/push/adapters/android.ts @@ -5,7 +5,7 @@ import {maybe, now} from "@welshman/lib" import type {Filter} from "@welshman/util" import type {Session} from "@welshman/app" import {app, session} from "@app/core" -import {pushState} from "@app/push/adapters/common" +import {pushState, requiresFallback} from "@app/push/adapters/common" import type {IPushAdapter} from "@app/push/adapters/common" import {syncRelaySubscriptions} from "@app/push/adapters/common" @@ -92,6 +92,6 @@ export class AndroidFallbackNotifications implements IPushAdapter { await AndroidPushFallback.syncState({state: {}}) - pushState.set({}) + pushState.set({useFallback: requiresFallback}) } } diff --git a/src/app/push/adapters/common.ts b/src/app/push/adapters/common.ts index 3fd1f426..1d618941 100644 --- a/src/app/push/adapters/common.ts +++ b/src/app/push/adapters/common.ts @@ -1,5 +1,6 @@ import {writable} from "svelte/store" import type {Subscriber, Unsubscriber} from "svelte/store" +import {Capacitor} from "@capacitor/core" import {assoc, call, ms, now, on, parseJson, poll, spec, throttle, uniq} from "@welshman/lib" import {LOCAL_RELAY_URL} from "@welshman/net" import type {RepositoryUpdate} from "@welshman/net" @@ -33,7 +34,11 @@ export type PushState = { subscription?: PushSubscription } -export const pushState = withGetter(writable({})) +// The F-Droid build ships without the push plugin, so those installs can only ever poll +export const requiresFallback = + Capacitor.getPlatform() === "android" && !Capacitor.isPluginAvailable("PushNotifications") + +export const pushState = withGetter(writable({useFallback: requiresFallback})) export interface IPushAdapter { request: (prompt?: boolean) => Promise diff --git a/src/app/push/index.ts b/src/app/push/index.ts index 4830ad21..af695d67 100644 --- a/src/app/push/index.ts +++ b/src/app/push/index.ts @@ -18,10 +18,7 @@ export class Push { if (Capacitor.getPlatform() === "electron") { Push._adapter = new ElectronNotifications() - } else if ( - Capacitor.getPlatform() === "android" && - (useFallback || !Capacitor.isPluginAvailable("PushNotifications")) - ) { + } else if (Capacitor.getPlatform() === "android" && useFallback) { Push._adapter = new AndroidFallbackNotifications() } else if (Capacitor.isPluginAvailable("PushNotifications")) { Push._adapter = new CapacitorNotifications()