You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { NativeModules, NativeEventEmitter } from 'react-native';
  2. /**
  3. * Thin wrapper around Apple's CallKit functionality.
  4. *
  5. * In CallKit requests are performed via actions (either user or system started)
  6. * and async events are reported via dedicated methods. This class exposes that
  7. * functionality in the form of methods and events. One important thing to note
  8. * is that even if an action is started by the system (because the user pressed
  9. * the "end call" button in the CallKit view, for example) the event will be
  10. * emitted in the same way as it would if the action originated from calling
  11. * the "endCall" method in this class, for example.
  12. *
  13. * Emitted events:
  14. * - performAnswerCallAction: The user pressed the answer button.
  15. * - performEndCallAction: The call should be ended.
  16. * - performSetMutedCallAction: The call muted state should change. The
  17. * ancillary `data` object contains a `muted` attribute.
  18. * - providerDidReset: The system has reset, all calls should be terminated.
  19. * This event gets no associated data.
  20. *
  21. * All events get a `data` object with a `callUUID` property, unless stated
  22. * otherwise.
  23. */
  24. let CallKit = NativeModules.RNCallKit;
  25. // XXX Rather than wrapping RNCallKit in a new class and forwarding the many
  26. // methods of the latter to the former, add the one additional method that we
  27. // need to RNCallKit.
  28. if (CallKit) {
  29. const eventEmitter = new NativeEventEmitter(CallKit);
  30. CallKit = {
  31. ...CallKit,
  32. addListener: eventEmitter.addListener.bind(eventEmitter)
  33. };
  34. }
  35. export default CallKit;