iOS Call Receive Issue

Hello,

I am stuck with one issue related to Call Receive in iOS. Please check below:

– When an iOS user or Android user is calling to iOS, then we are not getting any notification or call into the iOS device.
– After login with iOS, I have checked on the Sendbird server, and the token is registered on the back-end.
– Application ID =. 183A15D9-E04B-4522-94A2-562D220D5D45
– I have also uploaded certificates on Sendbird and Voip is also enabled.
– We are registering for “registerVoIPPush” for Sendbird Call.

– For Reference:
---- Tokens are logged on server. My Chat and Call iOS tokens are different on Sendbird Backend. That is because, For Chat we are logging the Push-Notification Token. While for Call, we are logging the Voip Token, as per the demo. So I assume that it is correct.

– Below is my authenticate method for your review.


//MARK: - Sendbird Login Auth

func sendBirdCallsLoginAuth(userId : String, accessTokens : String)
{
    // Authenticate
    let authParams = AuthenticateParams(userId: userId, accessToken: nil)

    SendBirdCall.authenticate(with: authParams) { (user, error) in

        guard user != nil else {

            // Failed

            DispatchQueue.main.async {

                //completionHandler(error ?? CredentialErrors.unknown)

                print("sendBirdCallsLoginAuth = \(String(describing: error?.localizedDescription))")

            }

            return

        }

        print("sendBirdCallsLoginAuth = \(String(describing: error?.localizedDescription))")

        // Succeed
        // create credential object with updated information
        //let credential = Credential(accessToken: accessTokens)
        let credential = Credential(accessToken: nil)
        //credential.accessToken
        let credentialManager = CredentialManager.shared
        credentialManager.updateCredential(credential) // update credential for sendbird call function
        print("SendBirdCall registered successfully")

        // register push token
        SendBirdCall.registerVoIPPush(token: UserDefaults.standard.voipPushToken, unique: false) { error in

            if let error = error { print(error) }

            print("SendBirdCall.registerVoIPPush registered successfully")

        }

    }

}

Note: When I am calling from iOS to Android, then the call is working and we are connected to each other.

Please guide as soon as possible, so we can execute it further.

Hello @Ibrahim_Malada, thanks for reaching out.

Have you implemented PushKit and CallKit for handling received push notifications on your application? You can find related guide in VoIP notifications | Calls iOS SDK | Sendbird Docs

Hello @mininny

Yes, I have implemented PushKit and CallKit. Below is the code for same:

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType) {
    SendBirdCall.pushRegistry(registry, didReceiveIncomingPushWith: payload, for: type, completionHandler: nil)
}
func voipRegistration() {
    self.voipRegistry = PKPushRegistry(queue: DispatchQueue.main)
    self.voipRegistry?.delegate = self
    self.voipRegistry?.desiredPushTypes = [.voIP]
}
//Sendbird - 9spl - Video

// MARK: - Other methods with common Pushregistry
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
    let deviceId = UIDevice.current.identifierForVendor!.uuidString
    
    let sub = Subscription()
    sub.notificationChannel = .APNSVOIP
    sub.deviceUDID = deviceId
    sub.deviceToken = registry.pushToken(for: .voIP)
    Request.createSubscription(sub, successBlock: { (sub) in
        NSLog("Create Subscription request - Success")
    }) { (err) in
        NSLog("Create Subscription request - Error")
    }
    
    //Sendbird - 9spl - Video
    UserDefaults.standard.voipPushToken = pushCredentials.token
    print("Push token is \(pushCredentials.token.toHexString())")
    SendBirdCall.registerVoIPPush(token: pushCredentials.token, unique: true) { error in
        guard error == nil else { return }
    }
    //Sendbird - 9spl - Video
}

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () → Void) {

    //Sendbird - 9spl - Video
    //..............sendbird calls
    SendBirdCall.pushRegistry(registry, didReceiveIncomingPushWith: payload, for: type) { uuid in
        guard uuid != nil else {
            let update = CXCallUpdate()
            update.remoteHandle = CXHandle(type: .generic, value: "invalid")
            let randomUUID = UUID()
            
            CXCallManager.shared.reportIncomingCall(with: randomUUID, update: update) { _ in
                CXCallManager.shared.endCall(for: randomUUID, endedAt: Date(), reason: .acceptFailed)
            }
            completion()
            return
        }
        
        completion()
    }
    //Sendbird - 9spl - Video

}

Anything else we need to add?

Also, please note that, after login, I am executing below method.

        SendBirdCall.registerVoIPPush(token: UserDefaults.standard.voipPushToken, unique: false) { error in
            if let error = error { print(error) }
            
            print("SendBirdCall.registerVoIPPush registered successfully")
            
        }

Voip Token is also registered successful. But I am not registering the push-token using below method:
SendBirdCall.registerRemotePush

I hope that is fine.

Please let me know.

Hello @mininny

Did you get a chance to review this? Currently, I have added the “Default Alert” certificate on Sendbird panel, so when someone calls, then I can get push-notification. Currently, this is working, but basically I want the “Voip” notification, so notification can have “Accept/Reject” button when my app is in background/killed mode. (Please note that, when I am uploading the “Voip” certificate on Sendbird panel, then my default notification stops to work and nothing comes when someone calls.)

One more thing, I have enabled the option to add the “Call” related message (missed call, voice call, video call) in Chat Message through Chat → Messages section on Sendbird panel.
Chat → Messages → Calls integration to Chat

But when I am calling to someone then this is not adding under the Chat Message. So, for that, do we need to do anything more for that?

Please review above and let me know your input.

Thank you.

Hello @Ibrahim_Malada ,
Instead of “Default Alerts”, can you try uploading a VoIP certificate as “VoIP Calls” notification type on the dashboard, and remove the original default alerts certificate? Your code for uploading VoIP push token seems to be correct, so once you upload the certificate correctly, it should work.

To use chat integration with calls, you have to pass the channelURL of the group channel through the SendBirdChatOptions parameter of DialParam when making a call. Please take a look at our guide Calls integration to Chat | Calls iOS SDK | Sendbird Docs for a better look.