Skip to content

Commit

Permalink
readme: stored completion() and call on js side usage
Browse files Browse the repository at this point in the history
  • Loading branch information
zxcpoiu committed Apr 30, 2020
1 parent eda5288 commit 9455386
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ Make sure you enabled the folowing in `Xcode` -> `Signing & Capabilities`:
// --- Handle incoming pushes (for ios >= 11)
- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion {

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

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

// --- this is optional, only required if you want to call `completion()` on the js side
[RNVoipPushNotificationManager addCompletionHandler:uuid completionHandler:completion];

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

// --- You should make sure to report to callkit BEFORE execute `completion()`
[RNCallKeep reportNewIncomingCall:uuid handle:handle handleType:@"generic" hasVideo:false localizedCallerName:callerName fromPushKit: YES payload:nil];


// --- You don't need to call it if you stored `completion()` and will call it on the js side.
completion();
}
...
Expand Down Expand Up @@ -220,6 +225,11 @@ class MyComponent extends React.Component {
VoipPushNotification.wakeupByPush = false;
}


// --- optionally, if you `addCompletionHandler` from the native side, once you have done the js jobs to initiate a call, call `completion()`
VoipPushNotification.onVoipNotificationCompleted(notification.getData().uuid);


/**
* Local Notification Payload
*
Expand All @@ -235,7 +245,6 @@ class MyComponent extends React.Component {
});
}
...

}

```
Expand Down

0 comments on commit 9455386

Please sign in to comment.