diff --git a/types/react-native-navigation/index.d.ts b/types/react-native-navigation/index.d.ts index 88bb8fe29e..3edf071e98 100644 --- a/types/react-native-navigation/index.d.ts +++ b/types/react-native-navigation/index.d.ts @@ -18,6 +18,7 @@ export namespace Navigation { function handleDeepLink(params?: { link: string; payload?: string; }): void; function registerScreen(screenId: string, generator: () => React.ComponentType): void; function getCurrentlyVisibleScreenId(): Promise; + function isAppLaunched(): Promise; } export interface TabBasedApp { @@ -118,7 +119,7 @@ export interface LightBox { } export interface NavigatorEvent { - id: 'willAppear' | 'didAppear' | 'willDisappear' | 'didDisappear' | 'willCommitPreview'; + id: 'willAppear' | 'didAppear' | 'willDisappear' | 'didDisappear' | 'willCommitPreview' | 'backPress'; } export class Navigator { @@ -155,6 +156,11 @@ export class ScreenVisibilityListener { unregister(): void; } +export class NativeEventsReceiver { + constructor(); + appLaunched(callback: () => void): void; +} + export interface ScreenVisibilityListenerParams { willAppear?: (params: ListenerParams) => void; didAppear?: (params: ListenerParams) => void; diff --git a/types/react-native-navigation/react-native-navigation-tests.tsx b/types/react-native-navigation/react-native-navigation-tests.tsx index 371465b1c9..e99bfd47dc 100644 --- a/types/react-native-navigation/react-native-navigation-tests.tsx +++ b/types/react-native-navigation/react-native-navigation-tests.tsx @@ -1,6 +1,13 @@ import * as React from 'react'; import { Text, View } from 'react-native'; -import { Navigation, NavigationComponentProps, NavigatorStyle, NavigatorButtons, NavigatorEvent } from 'react-native-navigation'; +import { + Navigation, + NavigationComponentProps, + NavigatorStyle, + NavigatorButtons, + NavigatorEvent, + NativeEventsReceiver, +} from 'react-native-navigation'; type Props = NavigationComponentProps & { height: number }; @@ -83,6 +90,17 @@ Navigation.registerComponent('example.Screen1', () => Screen1, {}, TestProvider, Navigation.registerComponent('example.Screen2', () => Screen2); Navigation.registerComponent('example.Drawer', () => Drawer); +Navigation.isAppLaunched().then(appLaunched => { + if (appLaunched) { + startApp(); // App is launched -> show UI + } + new NativeEventsReceiver().appLaunched(startApp); // App hasn't been launched yet -> show the UI only when needed. +}); + +function startApp() { + // do something here +} + Navigation.startTabBasedApp({ tabs: [ {