Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix[mobile]: refresh apns token if needed (#1898)
Peter Chinmanc423dc4ff1de
diff --git a/js/app/packages/tauri/src/PushNotification.tsx b/js/app/packages/tauri/src/PushNotification.tsxindex aa692ec839..185ba27149 100644--- a/js/app/packages/tauri/src/PushNotification.tsx+++ b/js/app/packages/tauri/src/PushNotification.tsx@@ -1,4 +1,5 @@import { isOk } from '@core/util/maybeResult';+import { whenSettled } from '@core/util/whenSettled';import {checkPermissions,type NotificationEvent,@@ -92,6 +93,33 @@ function usePushNotifications(setRegistrationResult(undefined);}+ // On launch, once permission status resolves, check if the APNS token has rotated.+ // iOS returns the same token if valid, or a new one if it has rotated.+ whenSettled(+ systemPermission,+ (perm) => {+ if (perm.status !== 'granted') return;+ const storedToken = registrationResult()?.token;+ if (!storedToken) return;++ registerForRemoteNotifications()+ .then((freshResult) => {+ if (freshResult.token && freshResult.token !== storedToken) {+ // Best-effort unregister the old token+ notificationServiceClient.unregisterDevice({+ deviceType,+ token: storedToken,+ });+ setRegistrationResult(freshResult);+ // tokenToSend() emits the new value, triggering the createResource fetcher+ // to register the new token with the backend.+ }+ })+ .catch(console.error);+ },+ console.error+ );+createEffect(() => {if (!registrationResult()?.success || !onPushNotification) return;watchNotifications(onPushNotification).then(console.info);