diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index d66d00bb8e..50c7712ecf 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -33,6 +33,7 @@ // Daiki Ihara // Abe Dolinger // Dominique Richard +// Mohamed Shaban // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -6875,22 +6876,27 @@ export interface AlertStatic { export type AlertType = 'default' | 'plain-text' | 'secure-text' | 'login-password'; /** - * AppStateIOS can tell you if the app is in the foreground or background, + * AppState can tell you if the app is in the foreground or background, * and notify you when the state changes. * - * AppStateIOS is frequently used to determine the intent and proper behavior + * AppState is frequently used to determine the intent and proper behavior * when handling push notifications. * - * iOS App States + * App State Events + * change - This even is received when the app state has changed. + * focus [Android] - Received when the app gains focus (the user is interacting with the app). + * blur [Android] - Received when the user is not actively interacting with the app. + * + * App States * active - The app is running in the foreground * background - The app is running in the background. The user is either in another app or on the home screen - * inactive - This is a transition state that currently never happens for typical React Native apps. + * inactive [iOS] - This is a transition state that currently never happens for typical React Native apps. * * For more information, see Apple's documentation: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html * - * @see https://facebook.github.io/react-native/docs/appstateios.html#content + * @see https://facebook.github.io/react-native/docs/appstate#app-states */ -export type AppStateEvent = 'change' | 'memoryWarning'; +export type AppStateEvent = 'change' | 'memoryWarning' | 'blur' | 'focus'; export type AppStateStatus = 'active' | 'background' | 'inactive'; export interface AppStateStatic { diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 0535b72de2..ce2046dfe6 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -372,6 +372,8 @@ function appStateListener(state: string) { function appStateTest() { console.log("Current state: " + AppState.currentState); AppState.addEventListener("change", appStateListener); + AppState.addEventListener("blur", appStateListener); + AppState.addEventListener("focus", appStateListener); } // ViewPagerAndroid