I'm using callkit & pushkit to implement voip calling.
To call, this is the code
callManager?.startCall(handle: String(format: "%@", "Jane Doe"), video: false)
Im getting voip push as well but in that, I'm not getting UUID of the receiver, is there any way to get it so that the call can received. In the
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType) {
guard type == .voIP else { return }
print("\(#function) incoming voip notfication: \(payload.dictionaryPayload)")
let uuidString = payload.dictionaryPayload["UUID"] as? String {
let uuid = UUID(uuidString: uuidString)
print(uuid) // this is always nil
let backgroundTaskIdentifier = UIApplication.shared.beginBackgroundTask(expirationHandler: nil)
self.displayIncomingCall(uuid: uuid, handle: "Jane Doe"", hasVideo: false) { _ in
UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier)
}
}
}
Do we need to send something to the server so that it can give details in the voip push, please point me what im doing wrong.
UUID can be generated and stored from iOS App itself. But UUID should be unique for every call and when the call is ended, the same UUID for that call to be used.
For generating UUID,
NSUUID *callUUID = [NSUUID UUID];
Sometimes this could be nil, use the below code for alternative,
CFUUIDRef newUniqueID = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef newUniqueIDString = CFUUIDCreateString(kCFAllocatorDefault, newUniqueID);
NSString *uuid = (__bridge NSString *)newUniqueIDString;
CFRelease(newUniqueIDString);
CFRelease(newUniqueID);
Note: the above code written in Objective-C.