Skip to content

Fetch display name from the Phonebook instead showing 'Unknown Caller… #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ios/Classes/SwiftTwilioVoicePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand

var from:String = callInvite.from ?? defaultCaller
from = from.replacingOccurrences(of: "client:", with: "")

self.sendPhoneCallEvents(description: "Ringing|\(from)|\(callInvite.to)|Incoming\(formatCustomParams(params: callInvite.customParameters))", isError: false)
reportIncomingCall(from: from, uuid: callInvite.uuid)
self.callInvite = callInvite
Expand Down Expand Up @@ -865,12 +865,14 @@ public class SwiftTwilioVoicePlugin: NSObject, FlutterPlugin, FlutterStreamHand
}
}

func reportIncomingCall(from: String, uuid: UUID) {
let callHandle = CXHandle(type: .generic, value: from)
func reportIncomingCall(from: String, uuid: UUID) {
// Using .phoneNumber to fetch display name from the Phonebook if the number is saved otherwise show literal string 'from'.
let callHandle = CXHandle(type: .phoneNumber, value: from)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition, though not all apps using twilio_voice make use of contacts or "from" values.


let callUpdate = CXCallUpdate()
callUpdate.remoteHandle = callHandle
callUpdate.localizedCallerName = clients[from] ?? self.clients["defaultCaller"] ?? defaultCaller
/// Apparently localizedCallerName overrides remoteHandle, so it was commented out fix "Unknown Caller" issue.
// callUpdate.localizedCallerName = from ?? self.clients["defaultCaller"] ?? defaultCaller
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't respect saved clients, integrating this change will affect others making use of the registerClient feature.

I'm working on an different approach allowing the developer to interpret the name directly from the custom parameters, clients map, etc.

callUpdate.supportsDTMF = true
callUpdate.supportsHolding = true
callUpdate.supportsGrouping = false
Expand Down