From 0a7577dc21aa5d84562ac0a24468998ce87cccaf Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 19:09:40 +0000 Subject: [PATCH] fix: show incoming call notification when app is in background When the app is alive but backgrounded, the relay subscription delivers the call event first, marking it as consumed. The push notification path then skips showing the notification because the event is already consumed. This left the phone ringing with no notification and no way to bring the app to the foreground. Now CallController shows the call notification directly when entering IncomingCall state, regardless of how the event was received. The notification's fullScreenIntent brings the app to the foreground. https://claude.ai/code/session_014espsysob7MrE8X8e75jFX --- .../amethyst/service/call/CallController.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt index 8ffcef6e6..679b1cdcc 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/call/CallController.kt @@ -24,7 +24,10 @@ import android.content.Context import android.content.Intent import com.vitorpamplona.amethyst.commons.call.CallManager import com.vitorpamplona.amethyst.commons.call.CallState +import com.vitorpamplona.amethyst.model.LocalCache import com.vitorpamplona.amethyst.service.notifications.NotificationUtils +import com.vitorpamplona.quartz.nip01Core.core.hexToByteArray +import com.vitorpamplona.quartz.nip19Bech32.toNpub import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent import com.vitorpamplona.quartz.nipACWebRtcCalls.WebRtcCallFactory import com.vitorpamplona.quartz.nipACWebRtcCalls.events.CallIceCandidateEvent @@ -105,6 +108,7 @@ class CallController( when (state) { is CallState.IncomingCall -> { audioManager.startRinging() + showIncomingCallNotification(state.callerPubKey) } is CallState.Offering -> { @@ -448,4 +452,17 @@ class CallController( } catch (_: Exception) { } } + + private fun showIncomingCallNotification(callerPubKey: String) { + val callerUser = LocalCache.getUserIfExists(callerPubKey) + val callerName = callerUser?.toBestDisplayName() ?: callerPubKey.take(8) + "..." + val uri = "nostr:${callerPubKey.hexToByteArray().toNpub()}" + + NotificationUtils.sendCallNotification( + callerName = callerName, + callerBitmap = null, + uri = uri, + applicationContext = context, + ) + } }