Skip to content

Commit 5f17a3d

Browse files
committed
fix(mobile): allow dismissing retained Android activity
1 parent fec6aef commit 5f17a3d

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎apps/mobile/modules/t3-agent-notifications/android/src/main/java/expo/modules/t3agentnotifications/AgentNotifications.kt‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,8 @@ object AgentNotifications {
270270
.setDeleteIntent(dismissIntent)
271271
presentation.applyTo(builder, context)
272272
val action = presentation.action
273-
if (action != null) {
274-
if (openThread != null) builder.addAction(0, action, openThread)
275-
builder.addAction(0, "Dismiss", dismissIntent)
276-
}
273+
if (action != null && openThread != null) builder.addAction(0, action, openThread)
274+
if (ongoing) builder.addAction(0, "Dismiss", dismissIntent)
277275
manager(context).notify(ACTIVITY_TAG, ACTIVITY_ID, builder.build())
278276
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
279277
// Notification timeouts were added in API 26. One inexact alarm also

‎apps/mobile/modules/t3-agent-notifications/android/src/test/java/expo/modules/t3agentnotifications/AgentNotificationsTest.kt‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ class AgentNotificationsTest {
456456
},
457457
card.extras.getString(NotificationCompat.EXTRA_SHORT_CRITICAL_TEXT)
458458
)
459-
assertEquals(0, card.actions?.size ?: 0)
459+
assertEquals(if (Build.VERSION.SDK_INT >= 36) 1 else 0, card.actions?.size ?: 0)
460460
}
461461
}
462462
}
@@ -745,7 +745,13 @@ class AgentNotificationChannelsTest {
745745
completedCard.notification.extras.getString(NotificationCompat.EXTRA_SHORT_CRITICAL_TEXT)
746746
)
747747

748-
AgentNotifications.dismiss(context)
748+
if (promoted) {
749+
val dismiss = completedCard.notification.actions.single()
750+
assertEquals("Dismiss", dismiss.title.toString())
751+
AgentActivityDismissReceiver().onReceive(context, shadowOf(dismiss.actionIntent).savedIntent)
752+
} else {
753+
AgentNotifications.dismiss(context)
754+
}
749755
AgentNotifications.receive(context, finished)
750756
assertTrue(manager.activeNotifications.isEmpty())
751757

‎docs/user/mobile-notifications.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Sign in to T3 Connect, link your environments, and enable **Device Notifications
44

55
Enable **Ongoing Agent Activity** on Android or **Live Activity Updates** on iOS to follow work without opening the app. Finished results remain visible for up to 15 minutes. You can dismiss an Android activity card without disabling alerts; turn off ongoing activity in Settings to stop future cards.
66

7-
For activity without ordinary alerts on Android 8 or newer, leave **Ongoing agent activity** enabled and turn off **Agent alerts** in Android's notification settings for T3 Code. Push delivery stays registered, and the same activity card shows the finished result without a separate alert. On Android 16 and newer, the finished result remains a Live Update until dismissed or expired. Keep app-wide notification permission and **Live updates** enabled so Android can display it.
7+
For activity without ordinary alerts on Android 8 or newer, leave **Ongoing agent activity** enabled and turn off **Agent alerts** in Android's notification settings for T3 Code. Activity updates continue, and the same card shows the finished result without a separate alert. On Android 16 and newer, the finished result remains a Live Update until dismissed or expired. Keep app-wide notification permission and **Live updates** enabled so Android can display it.
88

99
Ordinary alerts stay quiet while the mobile app is in the foreground. Ongoing activity continues to update. Viewing a thread on another device does not silence your phone's alerts.
1010

0 commit comments

Comments
 (0)