@@ -96,6 +96,7 @@ const registeredActivityPushTokens = new Map<string, number>();
9696let widgetSnapshotReads = 0 ;
9797let androidDeviceReplayedAt : number | null = null ;
9898let lastNativePushToken : string | null = null ;
99+ let registeredWithPushToken = false ;
99100let nativePushTokenRotations = 0 ;
100101let pushTokenSubscription : { remove : ( ) => void } | null = null ;
101102let appStateSubscription : { remove : ( ) => void } | null = null ;
@@ -118,6 +119,12 @@ export function getAgentAwarenessRegistrationStatus(): AgentAwarenessRegistratio
118119 return registrationStatus ;
119120}
120121
122+ // Live Activities use their own push tokens, so device registration alone does not mean
123+ // the relay can deliver notifications.
124+ export function agentAwarenessNotificationsReady ( ) : boolean {
125+ return registrationStatus === "registered" && registeredWithPushToken ;
126+ }
127+
121128export function subscribeAgentAwarenessRegistrationStatus ( listener : ( ) => void ) : ( ) => void {
122129 registrationStatusListeners . add ( listener ) ;
123130 return ( ) => {
@@ -368,13 +375,6 @@ function registrationSignature(body: RelayDeviceRegistrationRequest): string {
368375 ] . join ( "|" ) ;
369376}
370377
371- // Notifications are not set up until the relay holds a token for them.
372- function acceptedRegistrationStatus (
373- body : RelayDeviceRegistrationRequest ,
374- ) : AgentAwarenessRegistrationStatus {
375- return body . preferences . notificationsEnabled && ! body . pushToken ? "failed" : "registered" ;
376- }
377-
378378const registerDeviceWithRelay = Effect . fn ( "remoteRegistration.registerDeviceWithRelay" ) ( function * (
379379 body : RelayDeviceRegistrationRequest ,
380380 expectedGeneration : number ,
@@ -423,7 +423,8 @@ const registerDeviceWithRelay = Effect.fn("remoteRegistration.registerDeviceWith
423423 persisted . signature === signature &&
424424 ! needsAndroidReplay
425425 ) {
426- setRegistrationStatus ( acceptedRegistrationStatus ( payload ) ) ;
426+ registeredWithPushToken = Boolean ( payload . pushToken ) ;
427+ setRegistrationStatus ( "registered" ) ;
427428 return ;
428429 }
429430
@@ -439,7 +440,8 @@ const registerDeviceWithRelay = Effect.fn("remoteRegistration.registerDeviceWith
439440 return ;
440441 }
441442 if ( body . platform === "android" ) androidDeviceReplayedAt = yield * Clock . currentTimeMillis ;
442- setRegistrationStatus ( acceptedRegistrationStatus ( payload ) ) ;
443+ registeredWithPushToken = Boolean ( payload . pushToken ) ;
444+ setRegistrationStatus ( "registered" ) ;
443445 yield * Effect . promise ( ( ) =>
444446 saveAgentAwarenessRegistrationRecord ( {
445447 identity,
@@ -873,6 +875,7 @@ export function __resetAgentAwarenessRemoteRegistrationForTest(): void {
873875 activeDeviceRegistration = null ;
874876 pendingDeviceRegistration = null ;
875877 registrationStatus = "unknown" ;
878+ registeredWithPushToken = false ;
876879 androidDeviceReplayedAt = null ;
877880 lastNativePushToken = null ;
878881 nativePushTokenRotations = 0 ;
0 commit comments