NativeLinking.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @flow strict-local
  8. * @format
  9. */
  10. 'use strict';
  11. import type {TurboModule} from '../TurboModule/RCTExport';
  12. import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
  13. import Platform from '../Utilities/Platform';
  14. export interface Spec extends TurboModule {
  15. // Common interface
  16. +getInitialURL: () => Promise<string>;
  17. +canOpenURL: (url: string) => Promise<boolean>;
  18. +openURL: (url: string) => Promise<void>;
  19. +openSettings: () => Promise<void>;
  20. // Android only
  21. +sendIntent: (
  22. action: string,
  23. extras: ?Array<{
  24. key: string,
  25. value: string | number | boolean,
  26. ...
  27. }>,
  28. ) => Promise<void>;
  29. // Events
  30. +addListener: (eventName: string) => void;
  31. +removeListeners: (count: number) => void;
  32. }
  33. export default ((Platform.OS === 'android'
  34. ? TurboModuleRegistry.getEnforcing<Spec>('IntentAndroid')
  35. : TurboModuleRegistry.getEnforcing<Spec>('LinkingManager')): Spec);