Skip to content

Commit a8ee9b2

Browse files
committed
fix(android): omit FCM token when SSE mode is enabled
When use_sse is checked, register the device without an FCM token so the server falls back to SSE notifications via the worker's /notify endpoint instead of sending FCM push messages that the app ignores in SSE mode.
1 parent f8a6cb0 commit a8ee9b2

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

android/app/src/main/java/com/doodkin/screenmcp/MainActivity.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,8 @@ class MainActivity : AppCompatActivity() {
427427
tvRegistrationStatus.text = "Registering..."
428428
tvRegistrationStatus.setBackgroundColor(0xFFFFF9C4.toInt())
429429

430+
val useSse = isUseSse()
431+
430432
FirebaseMessaging.getInstance().token.addOnSuccessListener { fcmToken ->
431433
user.getIdToken(false).addOnSuccessListener { result ->
432434
val idToken = result.token ?: return@addOnSuccessListener
@@ -435,7 +437,10 @@ class MainActivity : AppCompatActivity() {
435437
Thread {
436438
try {
437439
val body = JSONObject().apply {
438-
put("fcmToken", fcmToken)
440+
// When SSE mode is enabled, omit FCM token so server uses SSE for notifications
441+
if (!useSse) {
442+
put("fcmToken", fcmToken)
443+
}
439444
put("deviceName", android.os.Build.MODEL)
440445
put("deviceModel", "${android.os.Build.MANUFACTURER} ${android.os.Build.MODEL}")
441446
put("platform", "android")
@@ -451,7 +456,7 @@ class MainActivity : AppCompatActivity() {
451456
val response = httpClient.newCall(request).execute()
452457
runOnUiThread {
453458
if (response.isSuccessful) {
454-
log("Phone registered successfully")
459+
log("Phone registered successfully" + if (useSse) " (SSE mode)" else "")
455460
// Also set the API URL for FcmService
456461
FcmService.apiBaseUrl = apiUrl
457462
// Verify registration status from server

0 commit comments

Comments
 (0)