Skip to content

Commit ef3d399

Browse files
authored
Merge pull request #574 from Paltap-io/fix/issue-406-rtceventemitter-sync
Fixes issue 406: Use Objective-C Key Value Coding(KVC) to sync _RTCEventEmitter_ `_listenerCount`.
2 parents 4dabb11 + 06cb30d commit ef3d399

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)