fix(ios): NativeCallPlugin Swift compile errors
- didReceiveIncomingPush: normalise payload.dictionaryPayload ([AnyHashable:Any]) to [String:Any] before storing/using (the reported build error at :121). - CXProviderConfiguration(localizedName:) instead of the no-arg init (available on all deployment targets, avoids an availability edge). - Make two 'calls[uuid] ?? [:]' bindings explicitly [String:Any] to avoid empty- literal inference ambiguity. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -38,7 +38,7 @@ public class NativeCallPlugin: CAPPlugin, CAPBridgedPlugin, PKPushRegistryDelega
|
|||||||
private var calls: [UUID: [String: Any]] = [:]
|
private var calls: [UUID: [String: Any]] = [:]
|
||||||
|
|
||||||
override public func load() {
|
override public func load() {
|
||||||
let config = CXProviderConfiguration()
|
let config = CXProviderConfiguration(localizedName: "Biz Connect")
|
||||||
config.supportsVideo = true
|
config.supportsVideo = true
|
||||||
config.maximumCallGroups = 1
|
config.maximumCallGroups = 1
|
||||||
config.maximumCallsPerCallGroup = 1
|
config.maximumCallsPerCallGroup = 1
|
||||||
@@ -114,7 +114,9 @@ public class NativeCallPlugin: CAPPlugin, CAPBridgedPlugin, PKPushRegistryDelega
|
|||||||
|
|
||||||
// Incoming VoIP push. iOS 13+: we MUST report a call to CallKit before completion() or the app is killed.
|
// Incoming VoIP push. iOS 13+: we MUST report a call to CallKit before completion() or the app is killed.
|
||||||
public func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
|
public func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
|
||||||
let dict = payload.dictionaryPayload
|
// payload.dictionaryPayload is [AnyHashable: Any]; normalise to [String: Any] for CallKit + notifyListeners.
|
||||||
|
var dict: [String: Any] = [:]
|
||||||
|
for (k, v) in payload.dictionaryPayload { if let ks = k as? String { dict[ks] = v } }
|
||||||
let uuid = UUID(uuidString: (dict["callUUID"] as? String) ?? "") ?? UUID()
|
let uuid = UUID(uuidString: (dict["callUUID"] as? String) ?? "") ?? UUID()
|
||||||
let callerName = (dict["callerName"] as? String) ?? (dict["groupName"] as? String) ?? "Incoming call"
|
let callerName = (dict["callerName"] as? String) ?? (dict["groupName"] as? String) ?? "Incoming call"
|
||||||
let hasVideo = (dict["hasVideo"] as? Bool) ?? false
|
let hasVideo = (dict["hasVideo"] as? Bool) ?? false
|
||||||
@@ -140,14 +142,14 @@ public class NativeCallPlugin: CAPPlugin, CAPBridgedPlugin, PKPushRegistryDelega
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
|
public func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
|
||||||
var data = calls[action.callUUID] ?? [:]
|
var data: [String: Any] = calls[action.callUUID] ?? [:]
|
||||||
data["callUUID"] = action.callUUID.uuidString
|
data["callUUID"] = action.callUUID.uuidString
|
||||||
notifyListeners("answerCall", data: data)
|
notifyListeners("answerCall", data: data)
|
||||||
action.fulfill()
|
action.fulfill()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
|
public func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
|
||||||
var data = calls[action.callUUID] ?? [:]
|
var data: [String: Any] = calls[action.callUUID] ?? [:]
|
||||||
data["callUUID"] = action.callUUID.uuidString
|
data["callUUID"] = action.callUUID.uuidString
|
||||||
notifyListeners("endCall", data: data)
|
notifyListeners("endCall", data: data)
|
||||||
calls.removeValue(forKey: action.callUUID)
|
calls.removeValue(forKey: action.callUUID)
|
||||||
@@ -169,10 +171,10 @@ public class NativeCallPlugin: CAPPlugin, CAPBridgedPlugin, PKPushRegistryDelega
|
|||||||
public func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
|
public func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
|
||||||
try? audioSession.setCategory(.playAndRecord, mode: .voiceChat, options: [.allowBluetooth, .allowBluetoothA2DP])
|
try? audioSession.setCategory(.playAndRecord, mode: .voiceChat, options: [.allowBluetooth, .allowBluetoothA2DP])
|
||||||
try? audioSession.setActive(true)
|
try? audioSession.setActive(true)
|
||||||
notifyListeners("audioActivated", data: [:])
|
notifyListeners("audioActivated", data: ["ok": true])
|
||||||
}
|
}
|
||||||
|
|
||||||
public func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
|
public func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
|
||||||
notifyListeners("audioDeactivated", data: [:])
|
notifyListeners("audioDeactivated", data: ["ok": true])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user