Last Run End State API
useEffect(() => {
getLastRunEndState().then(resp => {
console.log('LastRunEndState', resp);
});
}, []);
This API enables customers to automatically/programmatically understand if the previous app instance ended in a crash. Depending on your use case, having the ability to query an API to understand if the previous app instance ended in a crash will enable you to adjust the behavior or UI of your app after a crash has occurred.
What do we mean by previous app instance?
A cold launch, basically. If the app gets backgrounded/resumed so a new session starts, the value returned will not change. So:
- App crashes
- App is relaunched
getLastRunEndState
returns "crashed"- App is sent to background
- App is resumed, starting a new session
getLastRunEndState
still returns "crashed"- App exits cleanly
- App is relaunched
getLastRunEndState
returns "clean exit"
Important Notes
Important
- The API can only be called after the SDK has been started. If a call is made prior to starting the Embrace SDK you will get a response of
INVALID
- It will return that a crash occurred if the app crashed any time since the app last came to the foreground. This includes if the app crashed while running in the background.
Possible Values
/// Used to represent the end state of the last run of the application.
export type SessionStatus = 'INVALID' | 'CRASH' | 'CLEAN_EXIT';