VoIP -Push -Benachrichtigungen sind im Hintergrund unzuverlässig oder beendet den Zustand auf iOSIOS

Programmierung für iOS
Anonymous
 VoIP -Push -Benachrichtigungen sind im Hintergrund unzuverlässig oder beendet den Zustand auf iOS

Post by Anonymous »

Ich versuche, zuverlässige voIP Push -Benachrichtigungen in meiner iOS -App zu implementieren, damit immer eingehende Anrufe empfangen werden, auch wenn die App im Hintergrund oder beendet ist. Das Problem ist, dass VoIP zwar im Vordergrund die Arbeit wie erwartet drückt, sie jedoch unzuverlässig sind, wenn sich die App im Hintergrund befindet oder beendet ist. In einigen Fällen kommt überhaupt keine Benachrichtigung ein. Die App befindet sich im Hintergrund oder beendet.

Code: Select all

func registerForVoIPPushes() {
self.voipRegistry = PKPushRegistry(queue: nil)
self.voipRegistry?.delegate = self
self.voipRegistry?.desiredPushTypes = [.voIP]
}

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
registerForVoIPPushes()
return true
}
Push -Registrierungshandhabung:

Code: Select all

func pushRegistry(_ registry: PKPushRegistry,
didReceiveIncomingPushWith payload: PKPushPayload,
for type: PKPushType) {
guard let payloadInfo = payload.dictionaryPayload["data"] as? [AnyHashable: Any] else {
print("Unidentifiable payload data received")
return
}
print("pushRegistry didReceiveIncomingPushWith \(payloadInfo)")

guard
type == .voIP,
let callId = payloadInfo["callId"] as? String,
let _ = payloadInfo["deviceId"] as? String,
let sender = payloadInfo["senderName"] as? String,
let type = payloadInfo["type"] as? String
else {
print("Unknown PushKit notification received")
return
}

let uuid = GlobalMethods().uuidFromString(callId)
switch type {
case "NewVoipCallStarted":
CallManager.shared.processForIncomingCall(sender: sender, uuid: uuid)
case "CancelVoipCall":
CallManager.shared.cancelIncomingCall(uuid: uuid)
default:
print("Unknown type of voIP notification received")
return
}
}
Callkit -Integration:
func processForIncomingCall(sender: String, uuid: UUID) {
let configuration = CXProviderConfiguration()
configuration.supportsVideo = true
configuration.includesCallsInRecents = true
configuration.supportedHandleTypes = [.generic]
configuration.maximumCallsPerCallGroup = 1
configuration.includesCallsInRecents = true

provider = CXProvider(configuration: configuration)
provider?.setDelegate(self, queue: nil)

let update = CXCallUpdate()
update.remoteHandle = CXHandle(type: .generic, value: sender)
update.hasVideo = true

provider?.reportNewIncomingCall(with: uuid, update: update) { error in
if let error = error {
print("Error reporting incoming call: \(error.localizedDescription)")
} else {
print("Incoming call successfully reported.")
}
}
}
< /code>
Was ich ausprobiert habe: < /strong>
• Überprüft, ob das VoIP-Push-Zertifikat ordnungsgemäß gültig ist. Jedes Mal, wenn die App startet. immer ankommen und pushregistry aufrufen (_: didreceieComingpushwith: für :),

auch wenn die App im Hintergrund oder beendet ist. < /p.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post