Skip to content

Commit 9455386

Browse files
committed
readme: stored completion() and call on js side usage
1 parent eda5288 commit 9455386

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

README.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ Make sure you enabled the folowing in `Xcode` -> `Signing & Capabilities`:
128128
// --- Handle incoming pushes (for ios >= 11)
129129
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {
130130

131-
// --- Process the received push
132-
[RNVoipPushNotificationManager didReceiveIncomingPushWithPayload:payload forType:(NSString *)type];
133131

134132
// --- NOTE: apple forced us to invoke callkit ASAP when we receive voip push
135133
// --- see: react-native-callkeep
@@ -139,9 +137,16 @@ Make sure you enabled the folowing in `Xcode` -> `Signing & Capabilities`:
139137
NSString *callerName = [NSString stringWithFormat:@"%@ (Connecting...)", payload.dictionaryPayload[@"callerName"]];
140138
NSString *handle = payload.dictionaryPayload[@"handle"];
141139

140+
// --- this is optional, only required if you want to call `completion()` on the js side
141+
[RNVoipPushNotificationManager addCompletionHandler:uuid completionHandler:completion];
142+
143+
// --- Process the received push
144+
[RNVoipPushNotificationManager didReceiveIncomingPushWithPayload:payload forType:(NSString *)type];
145+
142146
// --- You should make sure to report to callkit BEFORE execute `completion()`
143147
[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES payload:nil];
144-
148+
149+
// --- You don't need to call it if you stored `completion()` and will call it on the js side.
145150
completion();
146151
}
147152
...
@@ -220,6 +225,11 @@ class MyComponent extends React.Component {
220225
VoipPushNotification.wakeupByPush = false;
221226
}
222227

228+
229+
// --- optionally, if you `addCompletionHandler` from the native side, once you have done the js jobs to initiate a call, call `completion()`
230+
VoipPushNotification.onVoipNotificationCompleted(notification.getData().uuid);
231+
232+
223233
/**
224234
* Local Notification Payload
225235
*
@@ -235,7 +245,6 @@ class MyComponent extends React.Component {
235245
});
236246
}
237247
...
238-
239248
}
240249

241250
```

0 commit comments

Comments
 (0)