Skip to content
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

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

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)

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
callUpdate.supportsDTMF = true
callUpdate.supportsHolding = true
callUpdate.supportsGrouping = false
Expand Down
Loading