> For the complete documentation index, see [llms.txt](https://docs.tryterra.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tryterra.co/faq/help-topics/no-data/connections-expiring-disconnecting/silent-mobile-disconnect-reinit.md).

# How do I handle silent mobile disconnects?

Silent disconnects mainly affect mobile-based integrations like Apple Health and Health Connect.

**On app launch, call `getUserId()`.** If it returns `null` when you expect a connection (for example on a new device or after an update), call `initConnection()` to re-establish it rather than disconnecting first. Duplicate `initConnection` calls are safe, so you can re-establish without forcing a disconnect/reconnect cycle.

The permission popup will not reappear because the original grant is remembered, unless you request expanded permissions or the app was deleted and reinstalled.

On reinstall:

* If the device ID is unchanged, you keep the same user.
* If the device ID changes, iOS treats it as a new device and a new user ID is created.

Enforce one provider connection per `reference_id` to avoid orphaned or duplicate user IDs.

For web-based integrations you normally receive a [deauth event](https://docs.tryterra.co/health-and-fitness-api/user-authentication/handling-authentication-events) when access is revoked; in rare silent cases data requests return an `AuthorizationExpired` error. If `getUserId` returns `null` on the same device that was previously connected, capture a reproducible case for investigation.

A `404` from a data endpoint after webhooks means the user has deauthenticated and the connection is gone: handle it as "no longer connected", stop retrying, and return `2xx`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tryterra.co/faq/help-topics/no-data/connections-expiring-disconnecting/silent-mobile-disconnect-reinit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
