aboutsummaryrefslogtreecommitdiffstats
path: root/android/app/build.gradle
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-11-06 23:01:15 -0700
committerAdam Soltys <[email protected]>2026-11-06 23:01:15 -0700
commit8969744783e2851b287e937f71033ce4b6bb4dc3 (patch)
tree682652e80d9119da9106a2e5ce2d11eeadb08d6f /android/app/build.gradle
parent1fe10057f301b09bbad0cfccdfecac9826733048 (diff)
downloadcoinosv3-8969744783e2851b287e937f71033ce4b6bb4dc3.tar.gz
coinosv3-8969744783e2851b287e937f71033ce4b6bb4dc3.zip
A third Android build, fcm (io.coinos.beta, "Coinos Beta"): the wallet in its own WebView, as the webview build, with Firebase Cloud Messaging for push on phones with Google Play Services — no distributor app to install. A user on the TWA APK found launching slow next to Minibits (2026-11-05); measured on a Pixel 9, a WebView paints ~0.7 s sooner than a cold Chrome. This build installs beside the TWA for a side-by-side trial before deciding whether it replaces it. Fcm asks for the token and stores "fcm:<token>" as the push endpoint, which reaches the page down the UnifiedPush road (?up= on the next launch, or written straight into the page's localStorage once it has loaded, since the token arrives after the first load starts); nwcpush (coinosv3-server 0c50417) sends an fcm: endpoint through Firebase. FcmService hands a message's "body" to the same handler UnifiedPush messages use (PushReceiver.onPush: wake the wallet off-screen, notify unless it answered a silent request). Firebase is set up in code (CoinosApp → Fcm.init) from values build.gradle reads out of app/google-services.json (gitignored) — without it the build still builds and falls back to UnifiedPush. The webview and fdroid builds get a stub Fcm (src/nofcm) and carry no Google code; the notification permission is asked when Firebase or a distributor can deliver; CoinosHost.env reports app "fcm"
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6Ts5Tktega8VbLg31q
Diffstat (limited to 'android/app/build.gradle')
-rw-r--r--android/app/build.gradle47
1 files changed, 46 insertions, 1 deletions
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 0119e93..046358d 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -22,6 +22,24 @@ tasks.register('copyWeb', Copy) {
into layout.buildDirectory.dir('www')
}
+// Firebase settings for the fcm build, read from app/google-services.json
+// (downloaded from the Firebase console; gitignored). Without it the fcm
+// build still builds, and pushes through UnifiedPush like the webview one.
+def firebase = [appId: '', apiKey: '', projectId: '', senderId: '']
+def gsFile = file('google-services.json')
+if (gsFile.exists()) {
+ def gs = new groovy.json.JsonSlurper().parse(gsFile)
+ def client = gs.client.find { it.client_info?.android_client_info?.package_name == 'io.coinos.beta' }
+ if (client) {
+ firebase = [
+ appId: client.client_info.mobilesdk_app_id,
+ apiKey: client.api_key[0].current_key,
+ projectId: gs.project_info.project_id,
+ senderId: gs.project_info.project_number,
+ ]
+ }
+}
+
android {
namespace 'io.coinos.app'
compileSdk 35
@@ -66,6 +84,21 @@ android {
resValue 'string', 'app_name', 'Coinos (UnifiedPush)'
buildConfigField 'boolean', 'BUNDLED', 'false'
}
+ // fcm — the webview shell plus Firebase Cloud Messaging: push without a
+ // distributor app on phones with Google Play Services (see
+ // src/fcm/java/io/coinos/app/Fcm.java). Its own app id, so it
+ // installs beside the TWA for a side-by-side trial.
+ fcm {
+ dimension 'shell'
+ applicationId 'io.coinos.beta'
+ versionNameSuffix '-beta'
+ resValue 'string', 'app_name', 'Coinos Beta'
+ buildConfigField 'boolean', 'BUNDLED', 'false'
+ buildConfigField 'String', 'FCM_APP_ID', "\"${firebase.appId}\""
+ buildConfigField 'String', 'FCM_API_KEY', "\"${firebase.apiKey}\""
+ buildConfigField 'String', 'FCM_PROJECT_ID', "\"${firebase.projectId}\""
+ buildConfigField 'String', 'FCM_SENDER_ID', "\"${firebase.senderId}\""
+ }
fdroid {
dimension 'shell'
applicationId 'io.coinos.fdroid'
@@ -74,9 +107,19 @@ android {
}
}
sourceSets {
+ // the webview shell has no Firebase: its Fcm is a stub
+ webview {
+ java.srcDirs += 'src/nofcm/java'
+ }
+ // the webview shell with Firebase (the manifest is webview's plus FCM)
+ fcm {
+ java.srcDirs = ['src/webview/java', 'src/fcm/java']
+ res.srcDirs = ['src/webview/res']
+ manifest.srcFile 'src/fcm/AndroidManifest.xml'
+ }
// the same shell as webview, plus the bundled web app
fdroid {
- java.srcDirs = ['src/webview/java']
+ java.srcDirs = ['src/webview/java', 'src/nofcm/java']
res.srcDirs = ['src/webview/res']
manifest.srcFile 'src/webview/AndroidManifest.xml'
assets.srcDirs += layout.buildDirectory.dir('www').get().asFile
@@ -102,6 +145,8 @@ android {
dependencies {
// only the TWA shell needs Chrome's helper; the WebView build carries none
twaImplementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.5.0'
+ // only the fcm build carries Google's push client
+ fcmImplementation 'com.google.firebase:firebase-messaging:24.1.0'
}
preBuild.dependsOn copyWeb