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
This commit is contained in:
@@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user