diff options
Diffstat (limited to 'android/app/src/main')
| -rw-r--r-- | android/app/src/main/AndroidManifest.xml | 3 | ||||
| -rw-r--r-- | android/app/src/main/java/io/coinos/app/Push.java | 13 |
2 files changed, 16 insertions, 0 deletions
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 0444b76..2f0f950 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -14,6 +14,9 @@ <intent> <action android:name="org.unifiedpush.android.distributor.REGISTER" /> </intent> + <!-- whether Google Play Services is here (Push.playServices): with it, the + TWA's web push works and UnifiedPush isn't asked --> + <package android:name="com.google.android.gms" /> </queries> <application android:label="@string/app_name" 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); } |
