Tutorials
Anonymize Calls Between Users
Anonymize Calls Between Users

Anonymize Calls Between Users

Using number masking to set up a scenario where two or more parties can call each other anonymously. A common scenario when you need to set this up is with in-app calls in ridesharing or in ecommerce, for example, where you want to enable drivers to call the user without knowing their real number.

There are multiple ways to implement this using the Infobip platform and Voice & Video as a channel. This tutorial shows you how to implement a simple in-app calling feature in your online application.

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

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

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 (opens in a new tab) 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:

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

    Response example:

    json
     
        {
        "token": "3981e92d-141e-48bb-8e10-f751e0b4bfb5",
        "expirationTime": "2019-02-06T11:10:00.123Z"
        }
     
  3. 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:

    swift
     
        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) {}
        }
     
    swift
     
        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:

    swift
     
        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.

Need assistance

Explore Infobip tutorials

Encountering issues

Contact our support

What's new? Check out

Release notes

Unsure about a term? See

Glossary

Research panel

Help shape the future of our products
Service Terms & ConditionsPrivacy policyTerms of use