Skip to content

Commit 06cb30d

Browse files
author
Gabriel Lesperance
committed
Fixes issue 406: Use Objective-C Key Value Coding(KVC) to sync _RTCEventEmitter_ _listenerCount.
see #406
1 parent 3e9a3ed commit 06cb30d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ios/RNCallKeep/RNCallKeep.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ - (void)startObserving
131131
- (void)stopObserving
132132
{
133133
_hasListeners = FALSE;
134+
135+
// Fix for https://github.com/react-native-webrtc/react-native-callkeep/issues/406
136+
// We use Objective-C Key Value Coding(KVC) to sync _RTCEventEmitter_ `_listenerCount`.
137+
@try {
138+
[self setValue:@0 forKey:@"_listenerCount"];
139+
}
140+
@catch ( NSException *e ){
141+
NSLog(@"[RNCallKeep][stopObserving] exception: %@",e);
142+
NSLog(@"[RNCallKeep][stopObserving] RNCallKeep parent class RTCEventEmitter might have a broken state.");
143+
NSLog(@"[RNCallKeep][stopObserving] Please verify that the parent RTCEventEmitter.m has iVar `_listenerCount`.");
144+
}
134145
}
135146

136147
- (void)onAudioRouteChange:(NSNotification *)notification

0 commit comments

Comments
 (0)