In my SIP app, I built-in Linphone to it. I can do outgoing calls and obtain incoming calls efficiently when app is open, however however as a brand new characteristic, I need to have the ability to obtain this name when the applying is closed. I researched some documentations and I discovered Callkit and Pushkit would possibly work for this intention. However I dont know when somebody calls me how can I set off this incoming name in background. I adopted the github difficulty beneath, but it surely did not assist.
https://github.com/BelledonneCommunications/linphone-iphone/points/612
You possibly can look how did I combine Pushkit and Callkit to my codes.
import UIKit
import CallKit
import PushKit
class SplashScreen : UIViewController, CXProviderDelegate, PKPushRegistryDelegate {
@IBOutlet weak var logoHeightConstraint: NSLayoutConstraint!
@IBOutlet weak var logoWidthConstraint: NSLayoutConstraint!
@IBOutlet weak var launcherIcon: UIImageView!
personal var registeredToBackgroundEvents = false
let TAG = "SplashScreen"
/// register to again from backround occasion
personal func registerToBackFromBackground() {
if(!registeredToBackgroundEvents) {
NotificationCenter.default.addObserver(self,
selector: #selector(viewDidBecomeActive),
identify: UIApplication.didBecomeActiveNotification, object: nil)
registeredToBackgroundEvents = true
}
}
/// unregister from again from backround occasion
personal func unregisterFromBackFromBackground() {
if(registeredToBackgroundEvents) {
NotificationCenter.default.removeObserver(self,
identify: UIApplication.didBecomeActiveNotification, object: nil)
registeredToBackgroundEvents = false
}
}
@objc func viewDidBecomeActive()","viewDidBecomeActive()->jumpToWelcomeScreen()")
jumpToWelcomeScreen()
override func viewDidLoad() {
tremendous.viewDidLoad()
MyApp.currentUIViewController = self
let registry = PKPushRegistry(queue: nil)
registry.delegate = self
registry.desiredPushTypes = [PKPushType.voIP]
}
override func viewDidAppear(_ animated: Bool) {
self.navigationController?.isNavigationBarHidden = true
MyApp.currentUIViewController = self
}
override func viewWillDisappear(_ animated: Bool) {
unregisterFromBackFromBackground()
}
func providerDidReset(_ supplier: CXProvider) {
MyApp.writeLog(TAG, "providerDidReset")
}
func supplier(_ supplier: CXProvider, carry out motion: CXAnswerCallAction) {
motion.fulfill()
MyApp.writeLog(TAG, "reply name motion")
}
func supplier(_ supplier: CXProvider, carry out motion: CXEndCallAction) {
motion.fulfill()
MyApp.writeLog(TAG, "finish name motion")
}
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for kind: PKPushType) {
MyApp.writeLog(TAG, "push registry didUpdate")
MyApp.writeLog(TAG, pushCredentials.token.map { String(format: "%02.2hhx", $0) }.joined())
print(pushCredentials.token.map { String(format: "%02.2hhx", $0) }.joined())
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for kind: PKPushType, completion: @escaping () -> Void) {
MyApp.writeLog(TAG, "push registry didReceiveIncomingPushWith")
let config = CXProviderConfiguration(localizedName: "My App")
config.includesCallsInRecents = false
config.supportsVideo = true
let supplier = CXProvider(configuration: config)
supplier.setDelegate(self, queue: nil)
let replace = CXCallUpdate()
replace.remoteHandle = CXHandle(kind: .generic, worth: "Somebody")
replace.hasVideo = true
supplier.reportNewIncomingCall(with: UUID(), replace: replace, completion: { error in })
}
}
Truly, after I write these codes in command line (terminal), take a look at notifications come to me.
curl -v -d '{"aps":{"alert":"good day"}}' --http2 --cert YeniCallKit.pem:202148 https://api.growth.push.apple.com/3/machine/177e7861396ad0256886673d1efb3c82d5adb54e86dc5cfd781356c1672cfa07
I wish to obtain background calls that when app is closed or iphone is locked. So anybody can assist me on this difficulty?