Remove all CallKit // PushKit related code from CallTutorial
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
6604166024D451F40064FC6C /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6604165F24D451F40064FC6C /* Preview Assets.xcassets */; };
|
||||
6604166324D451F40064FC6C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6604166124D451F40064FC6C /* LaunchScreen.storyboard */; };
|
||||
6604166B24D453240064FC6C /* CallExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6604166A24D453240064FC6C /* CallExample.swift */; };
|
||||
66B14FBB24DAF68E0041952F /* CallKitProviderDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66B14FBA24DAF68E0041952F /* CallKitProviderDelegate.swift */; };
|
||||
E1569C6E0564D0FD3FF9B4AF /* Pods_CallTutorial.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DC1D5CBF786F45B5E0D811F /* Pods_CallTutorial.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@@ -30,7 +29,6 @@
|
||||
6604166424D451F40064FC6C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
6604166A24D453240064FC6C /* CallExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallExample.swift; sourceTree = "<group>"; };
|
||||
66A3B37A24E138ED00E94540 /* CallTutorial.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = CallTutorial.entitlements; sourceTree = "<group>"; };
|
||||
66B14FBA24DAF68E0041952F /* CallKitProviderDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallKitProviderDelegate.swift; sourceTree = "<group>"; };
|
||||
79CE65CD0070AF94E21BFCE7 /* Pods-CallTutorial.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CallTutorial.debug.xcconfig"; path = "Target Support Files/Pods-CallTutorial/Pods-CallTutorial.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
C26219FCE26251F1C3C2E96E /* Pods-CallTutorial.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CallTutorial.release.xcconfig"; path = "Target Support Files/Pods-CallTutorial/Pods-CallTutorial.release.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
@@ -88,7 +86,6 @@
|
||||
66A3B37A24E138ED00E94540 /* CallTutorial.entitlements */,
|
||||
6604165624D451F10064FC6C /* AppDelegate.swift */,
|
||||
6604165824D451F10064FC6C /* SceneDelegate.swift */,
|
||||
66B14FBA24DAF68E0041952F /* CallKitProviderDelegate.swift */,
|
||||
6604166A24D453240064FC6C /* CallExample.swift */,
|
||||
6604165A24D451F10064FC6C /* ContentView.swift */,
|
||||
6604165C24D451F40064FC6C /* Assets.xcassets */,
|
||||
@@ -226,7 +223,6 @@
|
||||
6604165724D451F10064FC6C /* AppDelegate.swift in Sources */,
|
||||
6604165924D451F10064FC6C /* SceneDelegate.swift in Sources */,
|
||||
6604165B24D451F10064FC6C /* ContentView.swift in Sources */,
|
||||
66B14FBB24DAF68E0041952F /* CallKitProviderDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -373,7 +369,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.belledonne.Wtest;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = BC.CallTutorial;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
@@ -395,7 +391,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.belledonne.Wtest;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = BC.CallTutorial;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
|
||||
@@ -39,13 +39,9 @@ class CallExampleContext : ObservableObject
|
||||
@Published var passwd : String = "peche5"
|
||||
@Published var loggedIn: Bool = false
|
||||
|
||||
var mProviderDelegate : CallKitProviderDelegate!
|
||||
let outgoingCallName = "Outgoing call example"
|
||||
let incomingCallName = "Incoming call example"
|
||||
|
||||
init()
|
||||
{
|
||||
mProviderDelegate = CallKitProviderDelegate(context : self)
|
||||
mCallStateTracer.tutorialContext = self
|
||||
mRegistrationDelegate.tutorialContext = self
|
||||
|
||||
@@ -123,7 +119,6 @@ class CallExampleContext : ObservableObject
|
||||
print("Could not place call to \(dest)\n")
|
||||
} else {
|
||||
print("Call to \(dest) is in progress...")
|
||||
mProviderDelegate.outgoingCallUUID = UUID()
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -144,7 +139,12 @@ class CallExampleContext : ObservableObject
|
||||
callAlreadyStopped = true;
|
||||
// terminate the call
|
||||
print("Terminating the call...\n")
|
||||
mProviderDelegate.stopCall()
|
||||
do {
|
||||
try mCall.terminate()
|
||||
} catch
|
||||
{
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,10 +192,6 @@ class LinphoneRegistrationDelegate: CoreDelegate {
|
||||
print("New registration state \(cstate) for user id \( String(describing: cfg.identityAddress?.asString()))\n")
|
||||
if (cstate == .Ok)
|
||||
{
|
||||
if (!tutorialContext.loggedIn)
|
||||
{
|
||||
tutorialContext.mProviderDelegate.registerForVoIPPushes()
|
||||
}
|
||||
tutorialContext.loggedIn = true
|
||||
}
|
||||
}
|
||||
@@ -232,12 +228,6 @@ class CallStateDelegate: CoreDelegate {
|
||||
tutorialContext.callRunning = true
|
||||
} else if (cstate == .End) {
|
||||
// Call has been terminated by any side
|
||||
if (!tutorialContext.callAlreadyStopped)
|
||||
{
|
||||
// Report to CallKit that the call is over
|
||||
tutorialContext.mProviderDelegate.stopCall()
|
||||
tutorialContext.callAlreadyStopped = false
|
||||
}
|
||||
tutorialContext.callRunning = false
|
||||
tutorialContext.isCallIncoming = false
|
||||
} else if (cstate == .StreamsRunning)
|
||||
@@ -246,7 +236,6 @@ class CallStateDelegate: CoreDelegate {
|
||||
tutorialContext.callRunning = true
|
||||
} else if (cstate == .PushIncomingReceived)
|
||||
{
|
||||
print("PushTrace -- push incoming")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,171 +0,0 @@
|
||||
//
|
||||
// ProviderDelegate.swift
|
||||
// CallTutorial
|
||||
//
|
||||
// Created by QuentinArguillere on 05/08/2020.
|
||||
// Copyright © 2020 BelledonneCommunications. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CallKit
|
||||
import PushKit
|
||||
import linphonesw
|
||||
import AVFoundation
|
||||
|
||||
|
||||
class CallKitProviderDelegate : NSObject
|
||||
{
|
||||
private var voipRegistry: PKPushRegistry!
|
||||
private let provider: CXProvider
|
||||
let mCallController = CXCallController()
|
||||
var tutorialContext : CallExampleContext!
|
||||
|
||||
var incomingCallUUID : UUID!
|
||||
var outgoingCallUUID : UUID!
|
||||
|
||||
init(context : CallExampleContext)
|
||||
{
|
||||
tutorialContext = context
|
||||
let providerConfiguration = CXProviderConfiguration(localizedName: Bundle.main.infoDictionary!["CFBundleName"] as! String)
|
||||
providerConfiguration.supportsVideo = true
|
||||
providerConfiguration.supportedHandleTypes = [.generic]
|
||||
|
||||
providerConfiguration.maximumCallsPerCallGroup = 1
|
||||
providerConfiguration.maximumCallGroups = 1
|
||||
|
||||
provider = CXProvider(configuration: providerConfiguration)
|
||||
super.init()
|
||||
provider.setDelegate(self, queue: nil)
|
||||
|
||||
}
|
||||
|
||||
func incomingCall() {
|
||||
incomingCallUUID = UUID()
|
||||
let update = CXCallUpdate()
|
||||
update.remoteHandle = CXHandle(type:.generic, value: tutorialContext.incomingCallName)
|
||||
update.hasVideo = tutorialContext.videoEnabled
|
||||
|
||||
provider.reportNewIncomingCall(with: incomingCallUUID, update: update, completion: { error in })
|
||||
}
|
||||
|
||||
func outgoingCall()
|
||||
{
|
||||
outgoingCallUUID = UUID()
|
||||
let handle = CXHandle(type: .generic, value: tutorialContext.outgoingCallName)
|
||||
let startCallAction = CXStartCallAction(call: outgoingCallUUID, handle: handle)
|
||||
let transaction = CXTransaction(action: startCallAction)
|
||||
|
||||
provider.reportOutgoingCall(with: outgoingCallUUID, connectedAt: nil)
|
||||
mCallController.request(transaction, completion: { error in })
|
||||
}
|
||||
|
||||
func stopCall()
|
||||
{
|
||||
var callId = UUID();
|
||||
if (tutorialContext.isCallIncoming) {
|
||||
callId = incomingCallUUID
|
||||
} else if (tutorialContext.callRunning) {
|
||||
callId = outgoingCallUUID
|
||||
}
|
||||
let endCallAction = CXEndCallAction(call: callId)
|
||||
let transaction = CXTransaction(action: endCallAction)
|
||||
|
||||
mCallController.request(transaction, completion: { error in })
|
||||
}
|
||||
|
||||
func registerForVoIPPushes() {
|
||||
voipRegistry = PKPushRegistry(queue: nil)
|
||||
voipRegistry.delegate = self
|
||||
voipRegistry.desiredPushTypes = [PKPushType.voIP]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
extension CallKitProviderDelegate: CXProviderDelegate {
|
||||
|
||||
func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
|
||||
if (tutorialContext.mCall.state != Call.State.End)
|
||||
{
|
||||
try? tutorialContext.mCall.terminate()
|
||||
}
|
||||
action.fulfill()
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
|
||||
tutorialContext.acceptCall()
|
||||
action.fulfill()
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, perform action: CXSetHeldCallAction) {
|
||||
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
|
||||
tutorialContext.outgoingCallExample()
|
||||
action.fulfill()
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, perform action: CXSetMutedCallAction) {
|
||||
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, perform action: CXPlayDTMFCallAction) {
|
||||
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, timedOutPerforming action: CXAction) {
|
||||
|
||||
}
|
||||
|
||||
func providerDidReset(_ provider: CXProvider) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
|
||||
tutorialContext.mCore.activateAudioSession(actived: true)
|
||||
}
|
||||
|
||||
func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) {
|
||||
tutorialContext.mCore.activateAudioSession(actived: false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension CallKitProviderDelegate: PKPushRegistryDelegate {
|
||||
|
||||
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
|
||||
print("PushTrace -- pushRegistry 1")
|
||||
|
||||
/*
|
||||
let deviceTokenString = pushCredentials.token.map { String(format: "%02x", $0) }.joined() /*convert push tocken into hex string to be compliant with flexisip format*/
|
||||
let aStr = String(format: "pn-provider=apns.dev;pn-prid=%@:voip;pn-param=Z2V957B3D6.org.linphone.tutorials.callkit.voip"
|
||||
,deviceTokenString)
|
||||
*/
|
||||
let deviceTokenString = pushCredentials.token.map { String(format: "%02x", $0) }.joined() /*convert push tocken into hex string to be compliant with flexisip format*/
|
||||
let aStr = String(format: "pn-provider=apns.dev;pn-prid=%@:voip;pn-param=Z2V957B3D6.com.belledonne.Wtest.voip"
|
||||
,deviceTokenString)
|
||||
|
||||
tutorialContext.proxy_cfg.edit()
|
||||
tutorialContext.proxy_cfg.pushNotificationAllowed = true
|
||||
tutorialContext.proxy_cfg.contactUriParameters = aStr
|
||||
|
||||
do {
|
||||
try tutorialContext.proxy_cfg.done()
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
|
||||
print("PushTrace -- pushRegistry 2")
|
||||
incomingCall();
|
||||
}
|
||||
|
||||
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor: PKPushType)
|
||||
{
|
||||
print("PushTrace -- pushRegistry 3")
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>aps-environment</key>
|
||||
<string>development</string>
|
||||
</dict>
|
||||
<dict/>
|
||||
</plist>
|
||||
|
||||
@@ -116,7 +116,7 @@ struct ContentView: View {
|
||||
self.tutorialContext.acceptCall()
|
||||
}
|
||||
else {
|
||||
self.tutorialContext.mProviderDelegate.outgoingCall()
|
||||
self.tutorialContext.outgoingCallExample()
|
||||
}
|
||||
})
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user