From 90bc4d3d54b91cb9845cda4edc53ed148ae00251 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 13 Oct 2026 06:51:13 +0000 Subject: Android 1.14 (code 15): UnifiedPush only where web push can't reach the app. isolabellart asked why Coinos opens a prompt inside ntfy: every launch of the TWA asked whatever UnifiedPush distributor was installed for an endpoint (and asked for notification permission for it), Play Services or not. UnifiedPush is there for phones without Google Play Services (GrapheneOS and the like); with Play Services, web push reaches Chrome — and so the TWA — through Google already, and asking ntfy too only put up its prompt (and would bring every notification twice). The TWA now asks a distributor only when Play Services isn't installed and enabled (Push.playServices; its package named in the manifest's queries for Android 11+), or when it already holds an endpoint — whoever has one has been through the prompt and may be counting on it. The WebView builds (webview, fdroid) are unchanged: web push never reaches a WebView, so UnifiedPush is their only way in either way. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KPw21NEpWeTGu6swVASmBt --- android/app/src/main/java/io/coinos/app/Push.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'android/app/src/main/java') diff --git a/android/app/src/main/java/io/coinos/app/Push.java b/android/app/src/main/java/io/coinos/app/Push.java index 925693a..932fc11 100644 --- a/android/app/src/main/java/io/coinos/app/Push.java +++ b/android/app/src/main/java/io/coinos/app/Push.java @@ -120,6 +120,19 @@ public final class Push { p.edit().putInt(KEY_TRY, p.getInt(KEY_TRY, 0) + 1).putLong(KEY_TRY_AT, 0).remove(KEY_DIST).apply(); } + /** + * Google Play Services, installed and switched on — what web push on + * Android runs through. (Its package is named in the manifest's queries: + * Android 11+ hides it otherwise.) + */ + static boolean playServices(Context c) { + try { + return c.getPackageManager().getApplicationInfo("com.google.android.gms", 0).enabled; + } catch (Exception e) { + return false; + } + } + static String endpoint(Context c) { return prefs(c).getString(KEY_ENDPOINT, null); } -- cgit v1.2.3