← Zurück zu Mobile-App-Entwickler
Entdecke, wie der Skill hilft
1. Handle every lifecycle transition (
Robuster mobiler Lebenszyklus
Erhält wichtigen Zustand bei Hintergrundbetrieb, Prozessende, Netzwechsel und erneuter Authentifizierung.
mobile-lifecycle-resilience
Teammitglieder mit diesem Skill
Wann ist der Skill hilfreich?
Nutze dies bei Arbeitsverlust oder doppelten Anfragen nach Rückkehr zur App.
Wobei hilft er dir?
- Definiert Wiederherstellung aus aktiven, inaktiven, Hintergrund- und beendeten Zuständen.
- Behandelt unterbrochene Übertragungen und wechselnde Netzverbindungen.
- Koordiniert eine Tokenauffrischung und bereinigt Listener sowie Ressourcen.
Das könntest du fragen
Setze Upload nach Netzwechsel und Prozessneustart ohne zweites serverseitiges Objekt fort. Wechsle von WLAN zu Mobilfunk, beende die App und öffne sie erneut. Setze ab bestätigtem Fortschritt fort und prüfe ein fertiges entferntes Objekt.
Ausführliche Dokumentation
Hier findest du die ursprüngliche Anleitung, Beispiele und Prüfschritte des Skills in ihrer Originalsprache.
Weniger anzeigen
Mobile Lifecycle & Resilience
Mobile apps run in an interruptible environment: phone calls, app switching, OS memory pressure, process death and radio handoffs (Wi-Fi to cellular) happen mid-operation. Design every flow to survive interruption without losing user work or leaking resources.
1. Handle every lifecycle transition (active / inactive / background / process death)
- On
inactive/background(AppStatein React Native,AppLifecycleListenerin Flutter,ScenePhase/LifecycleObserverin native):- Immediately pause camera previews, audio/video playback, high-frequency timers, sensor/GPS polling and continuous animations.
- Flush or checkpoint unsaved form drafts and in-progress state to local storage synchronously or immediately—the OS may kill the backgrounded process without further warning.
- On
active(foreground resume):- Re-validate session/token expiry, refresh stale time-sensitive queries, and reconcile the status of any in-flight mutation or payment that was interrupted.
- Re-check runtime permissions (camera, location, notifications) that the user may have toggled in OS Settings while away.
- OS process death & state restoration: never rely solely on in-memory singletons surviving backgrounding; restore screen routes by ID and reload data or persisted drafts on cold/warm restart.
2. Flaky networks, radio switches and interrupted transfers
- Connectivity != reachability:
NetInfo/connectivity_plusreporting Wi-Fi does not mean the API is reachable (captive portals, blackholed cellular handoffs). Enforce explicit connect/read timeouts (10-30s) and distinguish network/timeout errors from4xxbusiness rejections. - Never destroy user input on failure: if a form save, comment or upload fails due to a timeout or connection drop, keep the user's draft intact on screen and provide a clear Retry action.
- Background & chunked transfers: iOS and Android throttle background sockets within seconds; for large media uploads/downloads, show progress, support cancellation/resume, and use OS background transfer APIs (
URLSessionbackground config, AndroidWorkManager,expo-file-systembackground tasks) when work must survive app switching.
3. Single-flight token refresh and resource cleanup
- Guard
401 Unauthorizedtoken refresh with a single-flight mutex/promise so 5 concurrent requests resuming after foregrounding await one refresh call instead of racing and triggering false logouts. - Remove every
AppState,NetInfo, keyboard, notification, stream and timer listener inuseEffectcleanup /dispose()/onCleared().
Before you finish
- Backgrounding pauses sensors/media/timers and checkpoints unsaved drafts before potential OS process death.
- Foregrounding refreshes stale data, reconciles pending work and re-verifies OS permissions.
- Network timeouts/drops preserve user input and offer safe retry without infinite loops.
- Concurrent 401 token refreshes share a single-flight lock; all listeners and timers are cleaned up.
Enthaltene Dateien 2
LICENSE.txtSKILL.md
