Skip to content

Commit 875cd6e

Browse files
committed
Trigger non-fired events when JS bridge is up
1 parent 48c6b88 commit 875cd6e

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

actions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ const checkReachability = handler =>
5959
const didLoadWithEvents = handler =>
6060
eventEmitter.addListener(RNCallKeepDidLoadWithEvents, handler);
6161

62+
export const emit = (eventName, payload) => eventEmitter.emit(eventName, payload);
63+
6264
export const listeners = {
6365
didReceiveStartCallAction,
6466
answerCall,
@@ -71,5 +73,5 @@ export const listeners = {
7173
didPerformDTMFAction,
7274
didResetProvider,
7375
checkReachability,
74-
didLoadWithEvents
76+
didLoadWithEvents,
7577
};

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NativeModules, Platform, Alert } from 'react-native';
22

3-
import { listeners } from './actions'
3+
import { listeners, emit } from './actions'
44

55
const RNCallKeepModule = NativeModules.RNCallKeep;
66
const isIOS = Platform.OS === 'ios';
@@ -22,6 +22,12 @@ class RNCallKeep {
2222

2323
constructor() {
2424
this._callkeepEventHandlers = new Map();
25+
26+
this.addEventListener('didLoadWithEvents', (events) => {
27+
events.forEach(event => {
28+
emit(evemt.name, event.data);
29+
});
30+
});
2531
}
2632

2733
addEventListener = (type, handler) => {

ios/RNCallKeep/RNCallKeep.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ @implementation RNCallKeep
4141
BOOL _isStartCallActionEventListenerAdded;
4242
bool _hasListeners;
4343
NSMutableArray *_delayedEvents;
44-
4544
}
4645

4746
static CXProvider* sharedProvider;

0 commit comments

Comments
 (0)