admin管理员组

文章数量:1201801

call ended automatically after 2-3 seconds when receive a voip notification in the terminated case

and this is my code:-

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
      guard  type == .voIP else { return }
          let typeStr = payload.dictionaryPayload["type"] as? String ?? ""
          if typeStr == "call_audio" {
              
              print("PushKit - didReceiveIncomingPushWith: \(payload.dictionaryPayload)")
              
              let uuidStr = payload.dictionaryPayload["uuid"] as? String ?? ""
              let id = payload.dictionaryPayload["id"] as? String ?? ""
              let nameCaller = payload.dictionaryPayload["callerName"] as? String ?? ""
              let handle = payload.dictionaryPayload["handle"] as? String ?? ""
              
              let data = flutter_callkit_incoming.Data(id: uuidStr, nameCaller: nameCaller, handle: "Incoming Call",type: 0)
              data.extra = ["platform": "ios", "type":type, "uuid": id, "callerName": nameCaller, "handle": handle, "isVideo": false,"id": id]
              data.appName="Randomly"
              data.uuid=uuidStr
              data.nameCaller=nameCaller
              data.duration=60000
              data.type=0
              data.handleType="email"
              data.supportsDTMF=false
              data.supportsGrouping=false
              data.audioSessionMode="voiceChat"
              data.audioSessionPreferredSampleRate=44100
              data.audioSessionPreferredIOBufferDuration=0.005
              data.audioSessionActive=true
              data.maximumCallsPerCallGroup=1
              data.supportsHolding=false
              data.supportsUngrouping=false
              data.maximumCallGroups=1
              SwiftFlutterCallkitIncomingPlugin.sharedInstance?.showCallkitIncoming(data, fromPushKit: true)
              DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
                  completion()
              }
              
              
          }
          else if typeStr == "missed_call" {
              SwiftFlutterCallkitIncomingPlugin.sharedInstance?.endAllCalls()
              completion()
          }
          
      }

after I close the app (be terminated) the issue happened and if I receive another call this will work as expected so this issue happened in first time I receive call after being terminated that the call ended immediately after 2-3 sec how can I solve this?

本文标签: swiftFlutterCallkitIncomingCall issue with iOS in terminated caseStack Overflow