Skip to content

Commit 7fbcf0e

Browse files
committed
moved displayIncomingCall callback moved to addEventListener.
1 parent 786d28a commit 7fbcf0e

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ Initialise RNCallKit with options
137137
- **hasVideo**: boolean (optional)
138138
- false (default)
139139
- **localizedCallerName**: string (optional)
140-
- **callback**: (error?: string) => void (optional)
141140

142141
Call when you receive incoming calls to display system UI
143142

index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ export default class RNCallKit {
4242
RNCallKitDidActivateAudioSession,
4343
() => { handler(); }
4444
);
45+
} else if (type === 'didDisplayIncomingCall') {
46+
listener = _RNCallKitEmitter.addListener(
47+
RNCallKitDidDisplayIncomingCall,
48+
(data) => { handler(data.error); }
49+
);
4550
}
51+
4652
_callkitEventHandlers.set(handler, listener);
4753
}
4854

@@ -67,16 +73,8 @@ export default class RNCallKit {
6773
_RNCallKit.setup(options);
6874
}
6975

70-
static displayIncomingCall(uuid, handle, handleType = 'number', hasVideo = false, localizedCallerName?: String, callback) {
76+
static displayIncomingCall(uuid, handle, handleType = 'number', hasVideo = false, localizedCallerName?: String) {
7177
if (Platform.OS !== 'ios') return;
72-
if (callback) {
73-
_callkitEventHandlers.set(
74-
callback,
75-
_RNCallKitEmitter.addListener(
76-
RNCallKitDidDisplayIncomingCall,
77-
(data) => { callback(data.error); }
78-
));
79-
}
8078
_RNCallKit.displayIncomingCall(uuid, handle, handleType, hasVideo, localizedCallerName);
8179
}
8280

ios/RNCallKit/RNCallKit.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ - (void)dealloc
106106
callUpdate.localizedCallerName = localizedCallerName;
107107

108108
[self.callKitProvider reportNewIncomingCallWithUUID:uuid update:callUpdate completion:^(NSError * _Nullable error) {
109-
// Invoking the displayIncomingCall callback
110109
[self sendEventWithName:RNCallKitDidDisplayIncomingCall body:@{ @"error": error ? error.localizedDescription : @"" }];
111110
if (error == nil) {
112111
// Workaround per https://forums.developer.apple.com/message/169511

0 commit comments

Comments
 (0)