Home » Use Cases

Enable Anonymous Calls Between Drivers and Riders

Web and In-App Calls - Ridesharing - high-level overview

Communication is key in any industry, especially in ridesharing. There are multiple reasons why any ridesharing company needs to enable riders and drivers to communicate with each other, the main one being pick-up coordination. Cancellation rates can spike when there’s a miscommunication and riders and their drivers cannot find each other.

Finding the right spot and the right passenger or car can be a challenging task in dense urban surroundings or in situations where there are large crowds. One example of this type of setting can be mass gatherings of people after sport events or concerts. Providing riders with an option of real-time conversation means giving them the tools to resolve issues that can arise from miscommunication.  

But at the same time both drivers and riders need to feel secure and protected. This implies that sharing personal data, including but not limited to, their names and phone numbers, is not an option.

In-app calls are an effective solution to both challenges, with a few added bonuses. Depending on data or internet availability of users these types of calls can be free of charge for them. Additionally, the call is established through the application itself and both types of users can still be engaged in obtaining a satisfactory end result for both parties – a 5-star ride.

This use case will show you how to implement simple an in-app calling feature in your online ridesharing application. Under pro tips you can find information on other solution types that Infobip is offering which may be more suitable for you depending on your use case.

Process Workflow

User Registration Flow

Web and In-App Calls - Ridesharing use case - user registration flow

Call Flow

Web and In-App Calls - Ridesharing use case - process flow

IMPLEMENTATION STEPS

Steps over SDK

NOTE

In order to use Infobip RTC, you need to have Web and In-App Calls enabled on your account.

  1. First and foremost, include Infobip RTC SDK(s) in your application(s):

  2. Register your users on the Infobip platform over API. Users are registered with their identity – a unique alphanumeric string. Once completed, the Infobip platform will return an authorization token. 

Request example:

POST /webrtc/1/token HTTP/1.1
Host: {base_url}
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json
{
	"identity":"Alice",
	"displayName":"Alice in Wonderland"
}

Response example:

{
  "token": "3981e92d-141e-48bb-8e10-f751e0b4bfb5",
  "expirationTime": "2019-02-06T11:10:00.123Z"
}
  1. Initiate a call from one registered user towards the other registered user via the call method. Authorization token needs to be supplied that you will have received from the previous response.

Example:

import Foundation
import InfobipRTCclass Foo {
    func makeCall() {
        let token = obtainToken()
        let callRequest = CallRequest(token, destination: "Alice", callDelegate: self)
        do {
            let outgoingCall = try InfobipRTC.call(callRequest)
        } catch CallError.callInProgress {
            print("Failed to make a call, already running active call.")
        } catch CallError.invalidDestination {
            print("Failed to make call, invalid destination.")
        } catch CallError.noInternetConnection {
            print("Failed to make call, no internet connection.")
        } catch CallError.missingMicrophonePermission {
            print("Failed to make call, missing microphone permission.")
        } catch {
            print("Failed to make call")
        }
    }
}extension Foo: CallDelegate {
    func onEstablished(_ callEstablishedEvent: CallEstablishedEvent) {
        print("Call with Alice established.")
    }    
    func onHangup(_ callHangupEvent: CallHangupEvent) {
        print("Call with Alice finished.")
    }    
    func onError(_ callErrorEvent: CallErrorEvent) {}    
    func onEarlyMedia(_ callEarlyMediaEvent: CallEarlyMediaEvent) {}    
    func onRinging(_ callRingingEvent: CallRingingEvent) {}
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
    if type == .voIP {
        if var incomingCall = InfobipRTC.handleIncomingCall(payload) {
            incomingCall.delegate = self
            incomingCall.accept() // or incomingCall.decline()
        }
    }
}
PRO TIP

If the called user is currently offline and the call cannot be established over the internet then you can implement failover calls to the GSM network. Initiate a call towards a landline or mobile phone by using the callPhoneNumber method.

Example:

let token = obtainToken()
let callRequest = CallRequest(token, destination: "41793026727", callDelegate: self)
do {
    let outgoingCall = try InfobipRTC.callPhoneNumber(callRequest, CallPhoneNumberOptions(from: "33755531044"))
} catch {
    print("Failed to make phone call.")
}
PRO TIP

Take a look at our Dynamic Destination Resolving for a full integration of phone and VoIP calls.

PRO TIP

In case you are interested in phone calls only, then Infobip Number Masking solution might be the right solution for you.