react-native-incall-manager icon indicating copy to clipboard operation
react-native-incall-manager copied to clipboard

'WiredHeadset' event not working on iOS

Open mikesholiu opened this issue 7 years ago • 3 comments
trafficstars

I'm using the below pattern (1.) per the docs, but the 'WiredHeadset' event doesn't seem to be firing on iOS. I also tried with NativeEventEmitter (doing this by using NativeModules to get the InCallManager then wrapping it in NativeEventEmitter, see 2.). I'm on version 0.53 of RN.

import { DeviceEventEmitter } from 'react-native';

DeviceEventEmitter.addListener('WiredHeadset', function (data) {
    // --- do something with events
});

const InCallManagerEvent = new NativeEventEmitter(NativeModules.InCallManager)

mikesholiu avatar Mar 01 '18 09:03 mikesholiu

import { DeviceEventEmitter } from 'react-native';

DeviceEventEmitter.addListener('WiredHeadset', function (data) { // --- do something with events });

not working android ...

nppull avatar Jun 26 '18 07:06 nppull

same problem

whck6 avatar Aug 01 '18 17:08 whck6

i'm resolve

import {
  NativeModules,
  NativeEventEmitter,
} from 'react-native';

const nativeBridge = NativeModules.InCallManager;
const NativeModule = new NativeEventEmitter(nativeBridge);

this.wiredHeadsetListener = NativeModule.addListener('WiredHeadset', (data) => {
  // do something
});

and i found native code return the array, not like subscribe on README, so not work so for, should be object of [self sendEventWithName:@"WiredHeadset" body:@{}]

whck6 avatar Aug 02 '18 06:08 whck6