I'm facing the same problem. Could you please tell me how you solved it?
oc
PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
pushRegistry.delegate = self;
pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
(void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void(^)(void))completion{
NSLog(@"Received void push notification data");
if (type == PKPushTypeVoIP) {
NSDictionary *callKit = [payload.dictionaryPayload objectForKey:@"callkit"];
NSString *handle = [callKit objectForKey:@"handle"];
NSString *uuidString = [callKit objectForKey:@"uuid"];
self.callInfo = payload.dictionaryPayload;
// 发起对话
if (@available(iOS 17.4, *)) {
[[LiveCommunicationWrapper shared] startConversationWithTargetHandleValue:handle uuid:uuidString completion:^(BOOL status, NSError * _Nullable error) {
completion();
}];
} else {
completion();
}
} else {
NSLog(@"Received push notification of type: %@", type);
completion();
}
}
swift
@available(iOS 17.4, *)
@objc class LiveCommunicationWrapper: NSObject, ConversationManagerDelegate {
@objc static let shared = LiveCommunicationWrapper()
let conversationManager = ConversationManager(configuration: ConversationManager.Configuration(ringtoneName: "default_ringtone", iconTemplateImageData: nil, maximumConversationGroups: 1, maximumConversationsPerConversationGroup: 1, includesConversationInRecents: false, supportsVideo: false, supportedHandleTypes: [.generic]))
private override init() {
super.init()
conversationManager.delegate = self
print("conversationManager init.")
}
@objc func startConversation(targetHandleValue : String,uuid : String, completion: @escaping (Bool, Error?) -> Void ){
guard let conversationUUID = UUID(uuidString: uuid) else {
let error = NSError(domain: "InvalidUUID", code: 1, userInfo: [NSLocalizedDescriptionKey: "Invalid UUID string"])
completion(false, error)
return
}
let hasVideo = false;
var update = Conversation.Update(members: [Handle(type: .generic, value: uuid, displayName: uuid)])
if hasVideo {
update.capabilities = [.video, .playingTones]
} else {
update.capabilities = .playingTones
}
let incomingCallerHandle = Handle(type: .generic, value: targetHandleValue ,displayName: targetHandleValue)
Task {
do {
try await conversationManager.reportNewIncomingConversation(uuid: conversationUUID, update: update)
completion(true, nil)
} catch {
print("An error occurred: \(error.localizedDescription)")
completion(false, error)
}
}
}