Place a call
Add a NXMCall property to the interface to hold a reference to any call in progress:
@interface ViewController () <NXMClientDelegate>
@property UIButton *callButton;
@property UILabel *connectionStatusLabel;
@property NXMClient *client;
@property NXMCall * call;
@end
Based on the object referenced by the call property, the callButtonPressed method can now be used to either place or end calls; the placeCall and endCall methods are triggered for each case.
Please make sure to replace PHONE_NUMBER below with the actual phone number you want to call. Note: must be the same one as the one specified in the gist NCCO:
- (void)callButtonPressed {
if (!self.call) {
[self placeCall];
} else {
[self endCall];
}
}
- (void)placeCall {
[self.client serverCallWithCallee:@"PHONE_NUMBER" customData:nil completionHandler:^(NSError * _Nullable error, NXMCall * _Nullable call) {
if (error) {
self.connectionStatusLabel.text = error.localizedDescription;
return;
}
self.call = call;
dispatch_async(dispatch_get_main_queue(), ^{
[self.callButton setTitle:@"End call" forState:UIControlStateNormal];
});
}];
}
- (void)endCall {
[self.call hangup];
self.call = nil;
[self.callButton setTitle:@"Call" forState:UIControlStateNormal];
}
NOTE: Please make sure to replace PHONE_NUMBER below with the actual phone number you want to call, in the E.164 format (for example, 447700900000).
NOTE: Also, please make sure that the webhook server you built in the previous steps is still running.
That's it! You can now build, run and place the call! Magic!
Once the call comes through you can answer it and hear the in-app voice call.
Also, as the call progresses through various stages, /voice/event is being sent events:
Also, as the call progresses through various stages, /voice/event is being sent events:
NOTE: As the call is completed, events will also contain duration and pricing information.
Making an in-app voice call
You make a voice call from an iOS app to a phone.