Ntfy listener: only run when the paired gateway pushes via ntfy — the foreground service (and its permanent 'Listening for messages' notification) is now started/stopped based on the gateway's push backend from hello.ack server_caps (persisted as pushBackend); FCM gateways no longer keep a persistent listener alive, and switching gateways toggles the service on the next connect

This commit is contained in:
ARIA committed 2026-08-21 17:21:47 +02:00
1 parent 75d491fd30
commit acd5fb4ad0
8 files changed
+105 -40

No files matched your search

@@ -15,7 +15,7 @@ import iris.IrisApp
import iris.platform.AndroidEnv
import iris.platform.AndroidSecureStore
import iris.platform.AppBridge
import iris.platform.NtfyListenerService
import iris.platform.syncNtfyListener
class MainActivity : ComponentActivity() {
private val deepLinkChatId = mutableStateOf<String?>(null)
@@ -31,7 +31,9 @@ class MainActivity : ComponentActivity() {
val store = AndroidSecureStore(applicationContext)
handleDeepLink(intent)
requestNotificationPermission()
startNtfyListener(store)
// M5: the ntfy listener (and its permanent notification) only runs
// when the paired gateway pushes via ntfy; unknown ("") = not yet.
syncNtfyListener(store.pushBackend)
setContent {
val chatId by deepLinkChatId
val threadId by deepLinkThreadId
@@ -58,10 +60,12 @@ class MainActivity : ComponentActivity() {
* extras or an iris://chat/<id>?thread=<tid> URI). */
private fun handleDeepLink(intent: Intent?) {
val data = intent?.data
val chatId = intent?.getStringExtra("chat_id")
?: data?.pathSegments?.firstOrNull()
val threadId = intent?.getStringExtra("thread_id")
?: data?.getQueryParameter("thread")
val chatId =
intent?.getStringExtra("chat_id")
?: data?.pathSegments?.firstOrNull()
val threadId =
intent?.getStringExtra("thread_id")
?: data?.getQueryParameter("thread")
if (!chatId.isNullOrBlank()) {
deepLinkChatId.value = chatId
deepLinkThreadId.value = threadId
@@ -77,9 +81,4 @@ class MainActivity : ComponentActivity() {
}
}
}
private fun startNtfyListener(store: AndroidSecureStore) {
if (store.ntfyTopic.isBlank()) return
ContextCompat.startForegroundService(this, Intent(this, NtfyListenerService::class.java))
}
}
}